From e55184ef2826ab0d66f48376019e874e299989cb Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Fri, 21 May 2004 21:29:24 +0300 Subject: [PATCH] imported winuaesrc0827b1.zip --- blitter.c | 13 +- cfgfile.c | 47 +- cia.c | 27 +- compemu_fpp.c | 4 +- compemu_support.c | 52 +- custom.c | 50 +- custom2.c | 5527 +++++++++++++++++++++++ debug.c | 3 + disk.c | 216 +- driveclick.c | 3 +- fdi2raw.c | 1629 ++++--- fdi2raw2.c | 1986 ++++++++ fdi2raw_old.c | 1835 ++++++++ filesys.c | 20 +- fpp.c | 4 +- gencomp.c | 16 +- gencpu.c | 71 +- identify.c | 4 + include/autoconf.h | 1 + include/custom.h | 17 +- include/fdi2raw.h | 3 +- include/memory.h | 13 +- include/moduleripper.h | 4 + include/newcpu.h | 6 +- include/options.h | 2 +- include/savestate.h | 2 +- include/sysdeps.h | 1 + main.c | 9 +- memory.c | 28 +- missing.c | 4 +- moduleripper.c | 93 + native2amiga.c | 18 +- newcpu.c | 47 +- od-win32/avioutput.c | 6 +- od-win32/avioutput.h | 4 +- od-win32/bsdsock.c | 8 +- od-win32/caps/CapsAPI.h | 6 + od-win32/caps/caps_win32.c | 62 +- od-win32/caps/caps_win32.h | 3 +- od-win32/dinput.c | 8 +- od-win32/makeexe.bat | 15 +- od-win32/midi.c | 28 +- od-win32/opengl.c | 174 +- od-win32/resources/resource.h | 2 +- od-win32/resources/winuae.rc | 42 +- od-win32/resources/winuae_minimal.rc | 926 ++-- od-win32/screenshot.c | 4 +- od-win32/srcrelease.bat | 4 +- od-win32/sysconfig.h | 5 + od-win32/win32.c | 87 +- od-win32/win32.h | 2 +- od-win32/win32_filesys.c | 6 +- od-win32/win32_nogui.c | 6 +- od-win32/win32gfx.c | 119 +- od-win32/win32gfx.h | 2 +- od-win32/win32gui.c | 653 ++- od-win32/win32gui.h | 1 + od-win32/winuae.nsi | 10 +- od-win32/winuae_msvc/winuae_msvc.vcproj | 2537 ++++++++++- prowizard/INSTALL | 20 + prowizard/README | 67 + prowizard/_types_ | 389 ++ prowizard/depack/ac1d.c | 205 + prowizard/depack/ambk.c | 150 + prowizard/depack/di.c | 198 + prowizard/depack/eureka.c | 150 + prowizard/depack/fc-m.c | 126 + prowizard/depack/fuchs.c | 245 + prowizard/depack/fuzzac.c | 262 ++ prowizard/depack/gmc.c | 196 + prowizard/depack/gnpl.c | 269 ++ prowizard/depack/gpmo.c | 83 + prowizard/depack/heatseek.c | 175 + prowizard/depack/hrt.c | 139 + prowizard/depack/kris.c | 240 + prowizard/depack/ksm.c | 322 ++ prowizard/depack/mp.c | 103 + prowizard/depack/newtron.c | 91 + prowizard/depack/nfh.c | 106 + prowizard/depack/noiserun.c | 266 ++ prowizard/depack/np1.c | 237 + prowizard/depack/np2.c | 224 + prowizard/depack/np3.c | 234 + prowizard/depack/p22a.c | 285 ++ prowizard/depack/p30a.c | 344 ++ prowizard/depack/p40.c | 394 ++ prowizard/depack/p41a.c | 386 ++ prowizard/depack/p50a.c | 462 ++ prowizard/depack/p60a.c | 484 ++ prowizard/depack/p61a.c | 725 +++ prowizard/depack/pha.c | 256 ++ prowizard/depack/pm.c | 109 + prowizard/depack/pm01.c | 190 + prowizard/depack/pm10c.c | 258 ++ prowizard/depack/pm18a.c | 249 + prowizard/depack/pm20.c | 256 ++ prowizard/depack/pm40.c | 414 ++ prowizard/depack/polka.c | 116 + prowizard/depack/pp10.c | 140 + prowizard/depack/pp21.c | 197 + prowizard/depack/pp30.c | 195 + prowizard/depack/prun1.c | 112 + prowizard/depack/prun2.c | 160 + prowizard/depack/qc.c | 320 ++ prowizard/depack/skyt.c | 174 + prowizard/depack/soundfx.c | 219 + prowizard/depack/starpack.c | 178 + prowizard/depack/stim.c | 207 + prowizard/depack/stk26.c | 105 + prowizard/depack/tdd.c | 192 + prowizard/depack/tp1.c | 204 + prowizard/depack/tp2.c | 250 + prowizard/depack/tp3.c | 259 ++ prowizard/depack/unic.c | 228 + prowizard/depack/unic2.c | 195 + prowizard/depack/wn.c | 123 + prowizard/depack/xann.c | 317 ++ prowizard/depack/zen.c | 237 + prowizard/docs/COPYING | 340 ++ prowizard/docs/CREDITS | 19 + prowizard/docs/KNOWN_FORMATS | 238 + prowizard/docs/MISC | 126 + prowizard/docs/TODO | 17 + prowizard/docs/changelog | 339 ++ prowizard/include/extern.h | 313 ++ prowizard/include/globals.h | 176 + prowizard/include/ptktable.h | 49 + prowizard/include/tuning.h | 58 + prowizard/include/vars.h | 24 + prowizard/interf/INTERF.H | 1 + prowizard/interf/INTFDUMB.C | 3 + prowizard/interf/INTFGTK.C | 2 + prowizard/makefile | 98 + prowizard/makefile.amiga | 93 + prowizard/makefile.dos | 145 + prowizard/makefile.mingwin32 | 102 + prowizard/makefile.unix | 92 + prowizard/misc/misc.c | 411 ++ prowizard/misc/testbag.c | 37 + prowizard/prowiz.c | 2124 +++++++++ prowizard/rips/ac1d.c | 34 + prowizard/rips/ambk.c | 24 + prowizard/rips/bp.c | 25 + prowizard/rips/bsifc.c | 36 + prowizard/rips/bytek30.c | 59 + prowizard/rips/bytekil.c | 93 + prowizard/rips/bytekp10.c | 93 + prowizard/rips/crmaddr.c | 59 + prowizard/rips/dblatn.c | 50 + prowizard/rips/defjam32.c | 65 + prowizard/rips/di.c | 27 + prowizard/rips/digibst.c | 29 + prowizard/rips/eureka.c | 31 + prowizard/rips/fc13.c | 29 + prowizard/rips/fc14.c | 30 + prowizard/rips/fc_m.c | 37 + prowizard/rips/fuchs.c | 32 + prowizard/rips/fuzzac.c | 29 + prowizard/rips/gmc.c | 24 + prowizard/rips/gnpl.c | 43 + prowizard/rips/gpmo.c | 32 + prowizard/rips/heatseek.c | 26 + prowizard/rips/hqc2.c | 97 + prowizard/rips/hrt.c | 38 + prowizard/rips/jamcrack.c | 54 + prowizard/rips/kris.c | 41 + prowizard/rips/ksm.c | 31 + prowizard/rips/maxpac12.c | 59 + prowizard/rips/mc30addr.c | 55 + prowizard/rips/mcobj.c | 77 + prowizard/rips/mcrun.c | 61 + prowizard/rips/med.c | 33 + prowizard/rips/mp.c | 79 + prowizard/rips/newtron.c | 25 + prowizard/rips/nfh.c | 34 + prowizard/rips/noiserun.c | 28 + prowizard/rips/npd1.c | 26 + prowizard/rips/npd2.c | 26 + prowizard/rips/npd3.c | 26 + prowizard/rips/p22a.c | 45 + prowizard/rips/p30a.c | 45 + prowizard/rips/p40a.c | 50 + prowizard/rips/p40b.c | 50 + prowizard/rips/p41a.c | 50 + prowizard/rips/p50a.c | 30 + prowizard/rips/p60a.c | 30 + prowizard/rips/p61a.c | 31 + prowizard/rips/pha.c | 52 + prowizard/rips/pm.c | 39 + prowizard/rips/pm01.c | 35 + prowizard/rips/pm10c.c | 29 + prowizard/rips/pm18a.c | 29 + prowizard/rips/pm20.c | 29 + prowizard/rips/pm40.c | 31 + prowizard/rips/polka.c | 23 + prowizard/rips/powerp23.c | 52 + prowizard/rips/powerp30.c | 53 + prowizard/rips/powerp40.c | 52 + prowizard/rips/powerp4l.c | 68 + prowizard/rips/pp10.c | 29 + prowizard/rips/pp21.c | 29 + prowizard/rips/pp30.c | 29 + prowizard/rips/ppbk.c | 30 + prowizard/rips/prun1.c | 33 + prowizard/rips/prun2.c | 29 + prowizard/rips/ptk.c | 24 + prowizard/rips/qc.c | 31 + prowizard/rips/relokit.c | 82 + prowizard/rips/skyt.c | 38 + prowizard/rips/soundfx.c | 33 + prowizard/rips/soundtk.c | 25 + prowizard/rips/spike.c | 52 + prowizard/rips/starpack.c | 24 + prowizard/rips/startrek.c | 24 + prowizard/rips/stc270.c | 59 + prowizard/rips/stc299.c | 54 + prowizard/rips/stc299b.c | 54 + prowizard/rips/stc299d.c | 54 + prowizard/rips/stc300.c | 54 + prowizard/rips/stc310.c | 54 + prowizard/rips/stim.c | 26 + prowizard/rips/stk26.c | 38 + prowizard/rips/superc27.c | 61 + prowizard/rips/syncro.c | 59 + prowizard/rips/tdd.c | 28 + prowizard/rips/time17.c | 92 + prowizard/rips/tnmc11.c | 84 + prowizard/rips/tp1.c | 26 + prowizard/rips/tp2.c | 84 + prowizard/rips/tp3.c | 87 + prowizard/rips/tpack102.c | 58 + prowizard/rips/tpack21.c | 58 + prowizard/rips/tpack22.c | 58 + prowizard/rips/tryit101.c | 59 + prowizard/rips/turbosqueezer61.c | 73 + prowizard/rips/unic.c | 46 + prowizard/rips/unic2.c | 28 + prowizard/rips/wn.c | 28 + prowizard/rips/xann.c | 30 + prowizard/rips/xm.c | 58 + prowizard/rips/zen.c | 27 + prowizard/tests/ac1d.c | 51 + prowizard/tests/ambk.c | 51 + prowizard/tests/arcd.c | 48 + prowizard/tests/bp.c | 60 + prowizard/tests/bsifc.c | 42 + prowizard/tests/bytek13.c | 90 + prowizard/tests/bytek20.c | 87 + prowizard/tests/bytek30.c | 80 + prowizard/tests/bytekp10.c | 78 + prowizard/tests/crmaddr.c | 81 + prowizard/tests/crnd.c | 29 + prowizard/tests/dblatn.c | 87 + prowizard/tests/defja32p.c | 72 + prowizard/tests/defjam32.c | 90 + prowizard/tests/di.c | 138 + prowizard/tests/digibst.c | 78 + prowizard/tests/eureka.c | 157 + prowizard/tests/fc13.c | 67 + prowizard/tests/fc14.c | 67 + prowizard/tests/fc_m.c | 37 + prowizard/tests/fuchs.c | 98 + prowizard/tests/fuzzac.c | 53 + prowizard/tests/gmc.c | 147 + prowizard/tests/gnpl.c | 45 + prowizard/tests/gpmo.c | 107 + prowizard/tests/heatseek.c | 151 + prowizard/tests/hqc2.c | 79 + prowizard/tests/hrt.c | 32 + prowizard/tests/jamcrack.c | 71 + prowizard/tests/kris.c | 41 + prowizard/tests/ksm.c | 60 + prowizard/tests/maxpac12.c | 84 + prowizard/tests/mc30addr.c | 82 + prowizard/tests/mcobj.c | 75 + prowizard/tests/mcrun10.c | 76 + prowizard/tests/mcrun12.c | 76 + prowizard/tests/mmd0.c | 68 + prowizard/tests/mp.c | 177 + prowizard/tests/newtron.c | 110 + prowizard/tests/nfh.c | 87 + prowizard/tests/noiserun.c | 107 + prowizard/tests/npd1.c | 144 + prowizard/tests/npd2.c | 164 + prowizard/tests/npd3.c | 175 + prowizard/tests/p40a.c | 71 + prowizard/tests/p41a.c | 70 + prowizard/tests/p50a.c | 238 + prowizard/tests/p60a.c | 394 ++ prowizard/tests/p61a.c | 526 +++ prowizard/tests/pha.c | 86 + prowizard/tests/pm.c | 42 + prowizard/tests/pm01.c | 135 + prowizard/tests/pm10c.c | 56 + prowizard/tests/pm20.c | 38 + prowizard/tests/pm40.c | 58 + prowizard/tests/pmz.c | 57 + prowizard/tests/polka.c | 95 + prowizard/tests/powerp23.c | 78 + prowizard/tests/powerp30.c | 77 + prowizard/tests/powerp40.c | 78 + prowizard/tests/powerp4l.c | 78 + prowizard/tests/pp10.c | 143 + prowizard/tests/pp21.c | 104 + prowizard/tests/pp30.c | 143 + prowizard/tests/ppbk.c | 48 + prowizard/tests/prun1.c | 32 + prowizard/tests/prun2.c | 42 + prowizard/tests/ptk.c | 100 + prowizard/tests/qc.c | 46 + prowizard/tests/relokit.c | 75 + prowizard/tests/skyt.c | 40 + prowizard/tests/soundfx.c | 133 + prowizard/tests/soundtk.c | 150 + prowizard/tests/spike.c | 77 + prowizard/tests/starpack.c | 180 + prowizard/tests/stc270.c | 80 + prowizard/tests/stc299.c | 78 + prowizard/tests/stc299b.c | 78 + prowizard/tests/stc299d.c | 78 + prowizard/tests/stc300.c | 78 + prowizard/tests/stc310.c | 78 + prowizard/tests/stim.c | 81 + prowizard/tests/stk26.c | 43 + prowizard/tests/superc27.c | 77 + prowizard/tests/syncro.c | 89 + prowizard/tests/tdd.c | 189 + prowizard/tests/time17.c | 75 + prowizard/tests/tnmc11.c | 84 + prowizard/tests/tp1.c | 91 + prowizard/tests/tp2.c | 108 + prowizard/tests/tp3.c | 98 + prowizard/tests/tpack102.c | 75 + prowizard/tests/tpack21.c | 74 + prowizard/tests/tpack22.c | 100 + prowizard/tests/tryit101.c | 81 + prowizard/tests/turbosqueezer61.c | 81 + prowizard/tests/unic.c | 444 ++ prowizard/tests/unic2.c | 158 + prowizard/tests/wn.c | 35 + prowizard/tests/xann.c | 104 + prowizard/tests/xm.c | 51 + prowizard/tests/zen.c | 118 + savestate.c | 2 +- zfile.c | 29 +- 345 files changed, 47412 insertions(+), 1822 deletions(-) create mode 100755 custom2.c create mode 100755 fdi2raw2.c create mode 100755 fdi2raw_old.c create mode 100755 include/moduleripper.h create mode 100755 moduleripper.c create mode 100755 prowizard/INSTALL create mode 100755 prowizard/README create mode 100755 prowizard/_types_ create mode 100755 prowizard/depack/ac1d.c create mode 100755 prowizard/depack/ambk.c create mode 100755 prowizard/depack/di.c create mode 100755 prowizard/depack/eureka.c create mode 100755 prowizard/depack/fc-m.c create mode 100755 prowizard/depack/fuchs.c create mode 100755 prowizard/depack/fuzzac.c create mode 100755 prowizard/depack/gmc.c create mode 100755 prowizard/depack/gnpl.c create mode 100755 prowizard/depack/gpmo.c create mode 100755 prowizard/depack/heatseek.c create mode 100755 prowizard/depack/hrt.c create mode 100755 prowizard/depack/kris.c create mode 100755 prowizard/depack/ksm.c create mode 100755 prowizard/depack/mp.c create mode 100755 prowizard/depack/newtron.c create mode 100755 prowizard/depack/nfh.c create mode 100755 prowizard/depack/noiserun.c create mode 100755 prowizard/depack/np1.c create mode 100755 prowizard/depack/np2.c create mode 100755 prowizard/depack/np3.c create mode 100755 prowizard/depack/p22a.c create mode 100755 prowizard/depack/p30a.c create mode 100755 prowizard/depack/p40.c create mode 100755 prowizard/depack/p41a.c create mode 100755 prowizard/depack/p50a.c create mode 100755 prowizard/depack/p60a.c create mode 100755 prowizard/depack/p61a.c create mode 100755 prowizard/depack/pha.c create mode 100755 prowizard/depack/pm.c create mode 100755 prowizard/depack/pm01.c create mode 100755 prowizard/depack/pm10c.c create mode 100755 prowizard/depack/pm18a.c create mode 100755 prowizard/depack/pm20.c create mode 100755 prowizard/depack/pm40.c create mode 100755 prowizard/depack/polka.c create mode 100755 prowizard/depack/pp10.c create mode 100755 prowizard/depack/pp21.c create mode 100755 prowizard/depack/pp30.c create mode 100755 prowizard/depack/prun1.c create mode 100755 prowizard/depack/prun2.c create mode 100755 prowizard/depack/qc.c create mode 100755 prowizard/depack/skyt.c create mode 100755 prowizard/depack/soundfx.c create mode 100755 prowizard/depack/starpack.c create mode 100755 prowizard/depack/stim.c create mode 100755 prowizard/depack/stk26.c create mode 100755 prowizard/depack/tdd.c create mode 100755 prowizard/depack/tp1.c create mode 100755 prowizard/depack/tp2.c create mode 100755 prowizard/depack/tp3.c create mode 100755 prowizard/depack/unic.c create mode 100755 prowizard/depack/unic2.c create mode 100755 prowizard/depack/wn.c create mode 100755 prowizard/depack/xann.c create mode 100755 prowizard/depack/zen.c create mode 100755 prowizard/docs/COPYING create mode 100755 prowizard/docs/CREDITS create mode 100755 prowizard/docs/KNOWN_FORMATS create mode 100755 prowizard/docs/MISC create mode 100755 prowizard/docs/TODO create mode 100755 prowizard/docs/changelog create mode 100755 prowizard/include/extern.h create mode 100755 prowizard/include/globals.h create mode 100755 prowizard/include/ptktable.h create mode 100755 prowizard/include/tuning.h create mode 100755 prowizard/include/vars.h create mode 100755 prowizard/interf/INTERF.H create mode 100755 prowizard/interf/INTFDUMB.C create mode 100755 prowizard/interf/INTFGTK.C create mode 100755 prowizard/makefile create mode 100755 prowizard/makefile.amiga create mode 100755 prowizard/makefile.dos create mode 100755 prowizard/makefile.mingwin32 create mode 100755 prowizard/makefile.unix create mode 100755 prowizard/misc/misc.c create mode 100755 prowizard/misc/testbag.c create mode 100755 prowizard/prowiz.c create mode 100755 prowizard/rips/ac1d.c create mode 100755 prowizard/rips/ambk.c create mode 100755 prowizard/rips/bp.c create mode 100755 prowizard/rips/bsifc.c create mode 100755 prowizard/rips/bytek30.c create mode 100755 prowizard/rips/bytekil.c create mode 100755 prowizard/rips/bytekp10.c create mode 100755 prowizard/rips/crmaddr.c create mode 100755 prowizard/rips/dblatn.c create mode 100755 prowizard/rips/defjam32.c create mode 100755 prowizard/rips/di.c create mode 100755 prowizard/rips/digibst.c create mode 100755 prowizard/rips/eureka.c create mode 100755 prowizard/rips/fc13.c create mode 100755 prowizard/rips/fc14.c create mode 100755 prowizard/rips/fc_m.c create mode 100755 prowizard/rips/fuchs.c create mode 100755 prowizard/rips/fuzzac.c create mode 100755 prowizard/rips/gmc.c create mode 100755 prowizard/rips/gnpl.c create mode 100755 prowizard/rips/gpmo.c create mode 100755 prowizard/rips/heatseek.c create mode 100755 prowizard/rips/hqc2.c create mode 100755 prowizard/rips/hrt.c create mode 100755 prowizard/rips/jamcrack.c create mode 100755 prowizard/rips/kris.c create mode 100755 prowizard/rips/ksm.c create mode 100755 prowizard/rips/maxpac12.c create mode 100755 prowizard/rips/mc30addr.c create mode 100755 prowizard/rips/mcobj.c create mode 100755 prowizard/rips/mcrun.c create mode 100755 prowizard/rips/med.c create mode 100755 prowizard/rips/mp.c create mode 100755 prowizard/rips/newtron.c create mode 100755 prowizard/rips/nfh.c create mode 100755 prowizard/rips/noiserun.c create mode 100755 prowizard/rips/npd1.c create mode 100755 prowizard/rips/npd2.c create mode 100755 prowizard/rips/npd3.c create mode 100755 prowizard/rips/p22a.c create mode 100755 prowizard/rips/p30a.c create mode 100755 prowizard/rips/p40a.c create mode 100755 prowizard/rips/p40b.c create mode 100755 prowizard/rips/p41a.c create mode 100755 prowizard/rips/p50a.c create mode 100755 prowizard/rips/p60a.c create mode 100755 prowizard/rips/p61a.c create mode 100755 prowizard/rips/pha.c create mode 100755 prowizard/rips/pm.c create mode 100755 prowizard/rips/pm01.c create mode 100755 prowizard/rips/pm10c.c create mode 100755 prowizard/rips/pm18a.c create mode 100755 prowizard/rips/pm20.c create mode 100755 prowizard/rips/pm40.c create mode 100755 prowizard/rips/polka.c create mode 100755 prowizard/rips/powerp23.c create mode 100755 prowizard/rips/powerp30.c create mode 100755 prowizard/rips/powerp40.c create mode 100755 prowizard/rips/powerp4l.c create mode 100755 prowizard/rips/pp10.c create mode 100755 prowizard/rips/pp21.c create mode 100755 prowizard/rips/pp30.c create mode 100755 prowizard/rips/ppbk.c create mode 100755 prowizard/rips/prun1.c create mode 100755 prowizard/rips/prun2.c create mode 100755 prowizard/rips/ptk.c create mode 100755 prowizard/rips/qc.c create mode 100755 prowizard/rips/relokit.c create mode 100755 prowizard/rips/skyt.c create mode 100755 prowizard/rips/soundfx.c create mode 100755 prowizard/rips/soundtk.c create mode 100755 prowizard/rips/spike.c create mode 100755 prowizard/rips/starpack.c create mode 100755 prowizard/rips/startrek.c create mode 100755 prowizard/rips/stc270.c create mode 100755 prowizard/rips/stc299.c create mode 100755 prowizard/rips/stc299b.c create mode 100755 prowizard/rips/stc299d.c create mode 100755 prowizard/rips/stc300.c create mode 100755 prowizard/rips/stc310.c create mode 100755 prowizard/rips/stim.c create mode 100755 prowizard/rips/stk26.c create mode 100755 prowizard/rips/superc27.c create mode 100755 prowizard/rips/syncro.c create mode 100755 prowizard/rips/tdd.c create mode 100755 prowizard/rips/time17.c create mode 100755 prowizard/rips/tnmc11.c create mode 100755 prowizard/rips/tp1.c create mode 100755 prowizard/rips/tp2.c create mode 100755 prowizard/rips/tp3.c create mode 100755 prowizard/rips/tpack102.c create mode 100755 prowizard/rips/tpack21.c create mode 100755 prowizard/rips/tpack22.c create mode 100755 prowizard/rips/tryit101.c create mode 100755 prowizard/rips/turbosqueezer61.c create mode 100755 prowizard/rips/unic.c create mode 100755 prowizard/rips/unic2.c create mode 100755 prowizard/rips/wn.c create mode 100755 prowizard/rips/xann.c create mode 100755 prowizard/rips/xm.c create mode 100755 prowizard/rips/zen.c create mode 100755 prowizard/tests/ac1d.c create mode 100755 prowizard/tests/ambk.c create mode 100755 prowizard/tests/arcd.c create mode 100755 prowizard/tests/bp.c create mode 100755 prowizard/tests/bsifc.c create mode 100755 prowizard/tests/bytek13.c create mode 100755 prowizard/tests/bytek20.c create mode 100755 prowizard/tests/bytek30.c create mode 100755 prowizard/tests/bytekp10.c create mode 100755 prowizard/tests/crmaddr.c create mode 100755 prowizard/tests/crnd.c create mode 100755 prowizard/tests/dblatn.c create mode 100755 prowizard/tests/defja32p.c create mode 100755 prowizard/tests/defjam32.c create mode 100755 prowizard/tests/di.c create mode 100755 prowizard/tests/digibst.c create mode 100755 prowizard/tests/eureka.c create mode 100755 prowizard/tests/fc13.c create mode 100755 prowizard/tests/fc14.c create mode 100755 prowizard/tests/fc_m.c create mode 100755 prowizard/tests/fuchs.c create mode 100755 prowizard/tests/fuzzac.c create mode 100755 prowizard/tests/gmc.c create mode 100755 prowizard/tests/gnpl.c create mode 100755 prowizard/tests/gpmo.c create mode 100755 prowizard/tests/heatseek.c create mode 100755 prowizard/tests/hqc2.c create mode 100755 prowizard/tests/hrt.c create mode 100755 prowizard/tests/jamcrack.c create mode 100755 prowizard/tests/kris.c create mode 100755 prowizard/tests/ksm.c create mode 100755 prowizard/tests/maxpac12.c create mode 100755 prowizard/tests/mc30addr.c create mode 100755 prowizard/tests/mcobj.c create mode 100755 prowizard/tests/mcrun10.c create mode 100755 prowizard/tests/mcrun12.c create mode 100755 prowizard/tests/mmd0.c create mode 100755 prowizard/tests/mp.c create mode 100755 prowizard/tests/newtron.c create mode 100755 prowizard/tests/nfh.c create mode 100755 prowizard/tests/noiserun.c create mode 100755 prowizard/tests/npd1.c create mode 100755 prowizard/tests/npd2.c create mode 100755 prowizard/tests/npd3.c create mode 100755 prowizard/tests/p40a.c create mode 100755 prowizard/tests/p41a.c create mode 100755 prowizard/tests/p50a.c create mode 100755 prowizard/tests/p60a.c create mode 100755 prowizard/tests/p61a.c create mode 100755 prowizard/tests/pha.c create mode 100755 prowizard/tests/pm.c create mode 100755 prowizard/tests/pm01.c create mode 100755 prowizard/tests/pm10c.c create mode 100755 prowizard/tests/pm20.c create mode 100755 prowizard/tests/pm40.c create mode 100755 prowizard/tests/pmz.c create mode 100755 prowizard/tests/polka.c create mode 100755 prowizard/tests/powerp23.c create mode 100755 prowizard/tests/powerp30.c create mode 100755 prowizard/tests/powerp40.c create mode 100755 prowizard/tests/powerp4l.c create mode 100755 prowizard/tests/pp10.c create mode 100755 prowizard/tests/pp21.c create mode 100755 prowizard/tests/pp30.c create mode 100755 prowizard/tests/ppbk.c create mode 100755 prowizard/tests/prun1.c create mode 100755 prowizard/tests/prun2.c create mode 100755 prowizard/tests/ptk.c create mode 100755 prowizard/tests/qc.c create mode 100755 prowizard/tests/relokit.c create mode 100755 prowizard/tests/skyt.c create mode 100755 prowizard/tests/soundfx.c create mode 100755 prowizard/tests/soundtk.c create mode 100755 prowizard/tests/spike.c create mode 100755 prowizard/tests/starpack.c create mode 100755 prowizard/tests/stc270.c create mode 100755 prowizard/tests/stc299.c create mode 100755 prowizard/tests/stc299b.c create mode 100755 prowizard/tests/stc299d.c create mode 100755 prowizard/tests/stc300.c create mode 100755 prowizard/tests/stc310.c create mode 100755 prowizard/tests/stim.c create mode 100755 prowizard/tests/stk26.c create mode 100755 prowizard/tests/superc27.c create mode 100755 prowizard/tests/syncro.c create mode 100755 prowizard/tests/tdd.c create mode 100755 prowizard/tests/time17.c create mode 100755 prowizard/tests/tnmc11.c create mode 100755 prowizard/tests/tp1.c create mode 100755 prowizard/tests/tp2.c create mode 100755 prowizard/tests/tp3.c create mode 100755 prowizard/tests/tpack102.c create mode 100755 prowizard/tests/tpack21.c create mode 100755 prowizard/tests/tpack22.c create mode 100755 prowizard/tests/tryit101.c create mode 100755 prowizard/tests/turbosqueezer61.c create mode 100755 prowizard/tests/unic.c create mode 100755 prowizard/tests/unic2.c create mode 100755 prowizard/tests/wn.c create mode 100755 prowizard/tests/xann.c create mode 100755 prowizard/tests/xm.c create mode 100755 prowizard/tests/zen.c diff --git a/blitter.c b/blitter.c index 7bd8b957..e36dbf20 100755 --- a/blitter.c +++ b/blitter.c @@ -35,8 +35,7 @@ static int blitline, blitfc, blitfill, blitife, blitsing, blitdesc; static int blitonedot,blitsign; static int blit_add; static int blit_modadda, blit_modaddb, blit_modaddc, blit_modaddd; -static int blit_ch, blit_starting; -static unsigned int blit_starts; +static int blit_ch; int blit_singlechannel; #ifdef BLITTER_DEBUG @@ -178,8 +177,8 @@ static void blitter_done (void) eventtab[ev_blitter].active = 0; unset_special (SPCFLAG_BLTNASTY); #ifdef BLITTER_DEBUG - write_log ("cycles %d, missed %d, total %d\n", - blit_cyclecounter, blit_misscyclecounter, blit_cyclecounter + blit_misscyclecounter); + write_log ("vpos=%d, cycles %d, missed %d, total %d\n", + vpos, blit_cyclecounter, blit_misscyclecounter, blit_cyclecounter + blit_misscyclecounter); #endif } @@ -703,10 +702,6 @@ void decide_blitter (int hpos) decide_blitter_line (hpos); return; } - if (blit_starting && get_cycles () - blit_starts < 4 * CYCLE_UNIT) { - blit_last_hpos = hpos + 1; - return; - } hpos++; if (dmaen (DMA_BLITTER)) { while (blit_last_hpos < hpos) { @@ -936,8 +931,6 @@ void do_blitter (int hpos) blitter_dma_cycles_line = blt_info.hblitsize * blit_dmacount2; if (blit_ch == 0) blit_maxcyclecounter = blt_info.hblitsize * blt_info.vblitsize; - blit_starts = get_cycles (); - blit_starting = 1; return; } diff --git a/cfgfile.c b/cfgfile.c index ff08248d..022aacee 100755 --- a/cfgfile.c +++ b/cfgfile.c @@ -24,6 +24,8 @@ #include "savestate.h" #include "memory.h" +#define CONFIG_BLEN 2560 + static int config_newfilesystem; static struct strlist *temp_lines; @@ -178,7 +180,7 @@ char *cfgfile_subst_path (const char *path, const char *subst, const char *file) void cfgfile_write (FILE *f, char *format,...) { va_list parms; - char tmp[1000]; + char tmp[CONFIG_BLEN]; va_start (parms, format); vsprintf (tmp, format, parms); @@ -533,7 +535,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value) int i; char *section = 0; char *tmpp; - char tmpbuf[256]; + char tmpbuf[CONFIG_BLEN]; if (memcmp (option, "input.", 6) == 0) { read_inputdevice_config (p, option, value); @@ -560,8 +562,11 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value) } for (i = 0; i < MAX_SPARE_DRIVES; i++) { sprintf (tmpbuf, "diskimage%d", i); - if (cfgfile_string (option, value, tmpbuf, p->dfxlist[i], 256)) + if (cfgfile_string (option, value, tmpbuf, p->dfxlist[i], 256)) { + if (i < 4 && !p->df[i][0]) + strcpy (p->df[i], p->dfxlist[i]); return 1; + } } if (cfgfile_intval (option, value, "sound_max_buff", &p->sound_maxbsiz, 1) @@ -781,9 +786,9 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value) static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *value) { - int tmpval; - int dummy; + int tmpval, dummy, i; char *section = 0; + char tmpbuf[CONFIG_BLEN]; if (cfgfile_yesno (option, value, "immediate_blits", &p->immediate_blits) || cfgfile_yesno (option, value, "fast_copper", &p->fast_copper) @@ -828,11 +833,7 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu || cfgfile_strval (option, value, "collision_level", &p->collision_level, collmode, 0) || cfgfile_strval (option, value, "comp_flushmode", &p->comp_hardflush, flushmode, 0)) return 1; - if (cfgfile_string (option, value, "floppy0", p->df[0], 256) - || cfgfile_string (option, value, "floppy1", p->df[1], 256) - || cfgfile_string (option, value, "floppy2", p->df[2], 256) - || cfgfile_string (option, value, "floppy3", p->df[3], 256) - || cfgfile_string (option, value, "kickstart_rom_file", p->romfile, 256) + if (cfgfile_string (option, value, "kickstart_rom_file", p->romfile, 256) || cfgfile_string (option, value, "kickstart_ext_rom_file", p->romextfile, 256) || cfgfile_string (option, value, "kickstart_key_file", p->keyfile, 256) || cfgfile_string (option, value, "flash_file", p->flashfile, 256) @@ -840,6 +841,14 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu || cfgfile_string (option, value, "pci_devices", p->pci_devices, 256)) return 1; + for (i = 0; i < 4; i++) { + sprintf (tmpbuf, "floppy%d", i); + if (cfgfile_string (option, value, tmpbuf, p->df[i], 256)) { + strcpy (p->dfxlist[i], p->df[i]); + return 1; + } + } + if (cfgfile_intval (option, value, "chipmem_size", &dummy, 1)) { if (!dummy) p->chipmem_size = 0x40000; @@ -878,7 +887,8 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu int factor = OFFICIAL_CYCLE_UNIT / CYCLE_UNIT; p->m68k_speed = (p->m68k_speed + factor - 1) / factor; } - if (strcasecmp (value, "max") == 0) p->m68k_speed = -1; + if (strcasecmp (value, "max") == 0) + p->m68k_speed = -1; return 1; } @@ -1096,7 +1106,7 @@ static int isobsolete (char *s) static void cfgfile_parse_separated_line (struct uae_prefs *p, char *line1b, char *line2b, int type) { - char line3b[2560], line4b[2560]; + char line3b[CONFIG_BLEN], line4b[CONFIG_BLEN]; struct strlist *sl; int ret; @@ -1123,7 +1133,7 @@ static void cfgfile_parse_separated_line (struct uae_prefs *p, char *line1b, cha void cfgfile_parse_line (struct uae_prefs *p, char *line, int type) { - char line1b[2560], line2b[2560]; + char line1b[CONFIG_BLEN], line2b[CONFIG_BLEN]; if (!separate_line (line, line1b, line2b)) return; @@ -1179,7 +1189,7 @@ static int cfgfile_load_2 (struct uae_prefs *p, const char *filename, int real, { int i; FILE *fh; - char line[2560], line1b[2560], line2b[2560]; + char line[CONFIG_BLEN], line1b[CONFIG_BLEN], line2b[CONFIG_BLEN]; struct strlist *sl; int type1 = 0, type2 = 0, askedtype = 0; @@ -1202,9 +1212,8 @@ static int cfgfile_load_2 (struct uae_prefs *p, const char *filename, int real, while (cfg_fgets (line, sizeof (line), fh) != 0) { int len = strlen (line); /* Delete trailing whitespace. */ - while (len > 0 && strcspn (line + len - 1, "\t \r\n") == 0) { + while (len > 0 && strcspn (line + len - 1, "\t \r\n") == 0) line[--len] = '\0'; - } if (strlen (line) > 0) { if (line[0] == '#') continue; @@ -1642,7 +1651,7 @@ int parse_cmdline_option (struct uae_prefs *p, char c, char *arg) void cfgfile_addcfgparam (char *line) { struct strlist *u; - char line1b[2560], line2b[2560]; + char line1b[CONFIG_BLEN], line2b[CONFIG_BLEN]; if (!line) { struct strlist **ps = &temp_lines; @@ -1668,7 +1677,7 @@ void cfgfile_addcfgparam (char *line) uae_u32 cfgfile_uaelib(int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen) { - char tmp[2000]; + char tmp[CONFIG_BLEN]; int i; struct strlist *sl; @@ -1871,7 +1880,7 @@ void default_prefs (struct uae_prefs *p, int type) #endif #ifdef UAE_MINI - default_prefs_mini (p); + default_prefs_mini (p, 0); #endif inputdevice_default_prefs (p); diff --git a/cia.c b/cia.c index 2cc108e4..a271c8ce 100755 --- a/cia.c +++ b/cia.c @@ -33,7 +33,8 @@ #endif #include "debug.h" -//#define CIA_DEBUG +//#define CIA_DEBUG_R +//#define CIA_DEBUG_W //#define DONGLE_DEBUG #define TOD_HACK @@ -441,7 +442,7 @@ static uae_u8 ReadCIAA (unsigned int addr) compute_passed_time (); -#ifdef CIA_DEBUG +#ifdef CIA_DEBUG_R write_log("R_CIAA: %02.2X %08.8X\n", addr, m68k_getpc()); #endif @@ -535,7 +536,7 @@ static uae_u8 ReadCIAB (unsigned int addr) { unsigned int tmp; -#ifdef CIA_DEBUG +#ifdef CIA_DEBUG_R write_log("R_CIAB: %02.2X %08.8X\n", addr, m68k_getpc()); #endif @@ -612,7 +613,7 @@ static uae_u8 ReadCIAB (unsigned int addr) static void WriteCIAA (uae_u16 addr,uae_u8 val) { -#ifdef CIA_DEBUG +#ifdef CIA_DEBUG_W write_log("W_CIAA: %02.2X %02.2X %08.8X\n", addr, val, m68k_getpc()); #endif switch (addr & 0xf) { @@ -757,7 +758,7 @@ static void WriteCIAA (uae_u16 addr,uae_u8 val) static void WriteCIAB (uae_u16 addr,uae_u8 val) { -#ifdef CIA_DEBUG +#ifdef CIA_DEBUG_W write_log("W_CIAB: %02.2X %02.2X %08.8X\n", addr, val, m68k_getpc()); #endif switch (addr & 0xf) { @@ -911,7 +912,7 @@ void CIA_reset (void) ciaaicr = ciabicr = ciaaimask = ciabimask = 0; ciaacra = ciaacrb = ciabcra = ciabcrb = 0x4; /* outmode = toggle; */ ciaala = ciaalb = ciabla = ciablb = ciaata = ciaatb = ciabta = ciabtb = 0xFFFF; - ciaaalarm = ciabalarm = 0; + ciaaalarm = ciabalarm = 0xffffff; ciabpra = 0x8C; ciabdra = 0; div10 = 0; ciaasdr_cnt = 0; ciaasdr = 0; @@ -940,12 +941,14 @@ void CIA_reset (void) void dumpcia (void) { - write_log("A: CRA %02x CRB %02x ICR %02x IM %02x TOD %06x %c%c TA %04x (%04x) TB %04x (%04x)\n", - ciaacra, ciaacrb, ciaaicr, ciaaimask, ciaatod, - ciaatlatch ? 'L' : ' ', ciaatodon ? ' ' : 'S', ciaata, ciaala, ciaatb, ciaalb); - write_log("B: CRA %02x CRB %02x ICR %02x IM %02x TOD %06x %c%c TA %04x (%04x) TB %04x (%04x)\n", - ciabcra, ciabcrb, ciaaicr, ciabimask, ciabtod, - ciabtlatch ? 'L' : ' ', ciabtodon ? ' ' : 'S', ciabta, ciabla, ciabtb, ciablb); + write_log("A: CRA %02x CRB %02x ICR %02x IM %02x TA %04x (%04x) TB %04x (%04x)\n", + ciaacra, ciaacrb, ciaaicr, ciaaimask, ciaata, ciaala, ciaatb, ciaalb); + write_log("TOD %06x ALARM %06x %c%c\n", + ciaatod, ciaaalarm, ciaatlatch ? 'L' : ' ', ciaatodon ? ' ' : 'S'); + write_log("B: CRA %02x CRB %02x ICR %02x IM %02x TA %04x (%04x) TB %04x (%04x)\n", + ciabcra, ciabcrb, ciaaicr, ciabimask, ciabta, ciabla, ciabtb, ciablb); + write_log("TOD %06x ALARM %06x %c%c\n", + ciabtod, ciabalarm, ciabtlatch ? 'L' : ' ', ciabtodon ? ' ' : 'S'); } /* CIA memory access */ diff --git a/compemu_fpp.c b/compemu_fpp.c index 377dcb92..7d475949 100755 --- a/compemu_fpp.c +++ b/compemu_fpp.c @@ -167,6 +167,8 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra) uae_u32 address=start_pc+((char *)comp_pc_p-(char *)start_pc_p)+ m68k_pc_offset; ad=S1; + if (size == 6) + address++; mov_l_ri(ad,address); m68k_pc_offset+=sz2[size]; break; @@ -220,7 +222,7 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra) fmov_rm(FS1,(uae_u32)(temp_fp)); break; case 6: - readword(ad,S2,S3); /* fetch word but use only low 8-bits */ + readbyte(ad,S2,S3); sign_extend_8_rr(S2,S2); mov_l_mr((uae_u32)temp_fp,S2); delay2; diff --git a/compemu_support.c b/compemu_support.c index 5143c61e..26c4988e 100755 --- a/compemu_support.c +++ b/compemu_support.c @@ -376,7 +376,7 @@ static __inline__ blockinfo* get_blockinfo_addr_new(void* addr, int setstate) } } if (!bi) { - fprintf(stderr,"Looking for blockinfo, can't find free one\n"); + write_log ("Looking for blockinfo, can't find free one\n"); abort(); } @@ -763,7 +763,7 @@ static __inline__ void writeback_const(int r) if (!isconst(r)) return; Dif (live.state[r].needflush==NF_HANDLER) { - fprintf(stderr,"Trying to write back constant NF_HANDLER!\n"); + write_log ("Trying to write back constant NF_HANDLER!\n"); abort(); } @@ -792,7 +792,7 @@ static void evict(int r) Dif (live.nat[rr].locked && live.nat[rr].nholds==1) { - fprintf(stderr,"register %d in nreg %d is locked!\n",r,live.state[r].realreg); + write_log ("register %d in nreg %d is locked!\n",r,live.state[r].realreg); abort(); } @@ -1427,7 +1427,7 @@ static void f_evict(int r) Dif (live.fat[rr].locked && live.fat[rr].nholds==1) { - fprintf(stderr,"FPU register %d in nreg %d is locked!\n",r,live.fate[r].realreg); + write_log ("FPU register %d in nreg %d is locked!\n",r,live.fate[r].realreg); abort(); } @@ -1937,7 +1937,7 @@ MIDFUNC(2,rol_l_rr,(RW4 d, R1 r)) r=readreg_specific(r,1,SHIFTCOUNT_NREG); d=rmw(d,4,4); Dif (r!=1) { - fprintf(stderr,"Illegal register %d in raw_rol_b\n",r); + write_log ("Illegal register %d in raw_rol_b\n",r); abort(); } raw_rol_l_rr(d,r) ; @@ -1957,7 +1957,7 @@ MIDFUNC(2,rol_w_rr,(RW2 d, R1 r)) r=readreg_specific(r,1,SHIFTCOUNT_NREG); d=rmw(d,2,2); Dif (r!=1) { - fprintf(stderr,"Illegal register %d in raw_rol_b\n",r); + write_log ("Illegal register %d in raw_rol_b\n",r); abort(); } raw_rol_w_rr(d,r) ; @@ -1978,7 +1978,7 @@ MIDFUNC(2,rol_b_rr,(RW1 d, R1 r)) r=readreg_specific(r,1,SHIFTCOUNT_NREG); d=rmw(d,1,1); Dif (r!=1) { - fprintf(stderr,"Illegal register %d in raw_rol_b\n",r); + write_log ("Illegal register %d in raw_rol_b\n",r); abort(); } raw_rol_b_rr(d,r) ; @@ -1998,7 +1998,7 @@ MIDFUNC(2,shll_l_rr,(RW4 d, R1 r)) r=readreg_specific(r,1,SHIFTCOUNT_NREG); d=rmw(d,4,4); Dif (r!=1) { - fprintf(stderr,"Illegal register %d in raw_rol_b\n",r); + write_log ("Illegal register %d in raw_rol_b\n",r); abort(); } raw_shll_l_rr(d,r) ; @@ -2018,7 +2018,7 @@ MIDFUNC(2,shll_w_rr,(RW2 d, R1 r)) r=readreg_specific(r,1,SHIFTCOUNT_NREG); d=rmw(d,2,2); Dif (r!=1) { - fprintf(stderr,"Illegal register %d in raw_shll_b\n",r); + write_log ("Illegal register %d in raw_shll_b\n",r); abort(); } raw_shll_w_rr(d,r) ; @@ -2039,7 +2039,7 @@ MIDFUNC(2,shll_b_rr,(RW1 d, R1 r)) r=readreg_specific(r,1,SHIFTCOUNT_NREG); d=rmw(d,1,1); Dif (r!=1) { - fprintf(stderr,"Illegal register %d in raw_shll_b\n",r); + write_log ("Illegal register %d in raw_shll_b\n",r); abort(); } raw_shll_b_rr(d,r) ; @@ -2138,7 +2138,7 @@ MIDFUNC(2,shrl_l_rr,(RW4 d, R1 r)) r=readreg_specific(r,1,SHIFTCOUNT_NREG); d=rmw(d,4,4); Dif (r!=1) { - fprintf(stderr,"Illegal register %d in raw_rol_b\n",r); + write_log ("Illegal register %d in raw_rol_b\n",r); abort(); } raw_shrl_l_rr(d,r) ; @@ -2158,7 +2158,7 @@ MIDFUNC(2,shrl_w_rr,(RW2 d, R1 r)) r=readreg_specific(r,1,SHIFTCOUNT_NREG); d=rmw(d,2,2); Dif (r!=1) { - fprintf(stderr,"Illegal register %d in raw_shrl_b\n",r); + write_log ("Illegal register %d in raw_shrl_b\n",r); abort(); } raw_shrl_w_rr(d,r) ; @@ -2179,7 +2179,7 @@ MIDFUNC(2,shrl_b_rr,(RW1 d, R1 r)) r=readreg_specific(r,1,SHIFTCOUNT_NREG); d=rmw(d,1,1); Dif (r!=1) { - fprintf(stderr,"Illegal register %d in raw_shrl_b\n",r); + write_log ("Illegal register %d in raw_shrl_b\n",r); abort(); } raw_shrl_b_rr(d,r) ; @@ -2307,7 +2307,7 @@ MIDFUNC(2,shra_l_rr,(RW4 d, R1 r)) r=readreg_specific(r,1,SHIFTCOUNT_NREG); d=rmw(d,4,4); Dif (r!=1) { - fprintf(stderr,"Illegal register %d in raw_rol_b\n",r); + write_log ("Illegal register %d in raw_rol_b\n",r); abort(); } raw_shra_l_rr(d,r) ; @@ -2327,7 +2327,7 @@ MIDFUNC(2,shra_w_rr,(RW2 d, R1 r)) r=readreg_specific(r,1,SHIFTCOUNT_NREG); d=rmw(d,2,2); Dif (r!=1) { - fprintf(stderr,"Illegal register %d in raw_shra_b\n",r); + write_log ("Illegal register %d in raw_shra_b\n",r); abort(); } raw_shra_w_rr(d,r) ; @@ -2348,7 +2348,7 @@ MIDFUNC(2,shra_b_rr,(RW1 d, R1 r)) r=readreg_specific(r,1,SHIFTCOUNT_NREG); d=rmw(d,1,1); Dif (r!=1) { - fprintf(stderr,"Illegal register %d in raw_shra_b\n",r); + write_log ("Illegal register %d in raw_shra_b\n",r); abort(); } raw_shra_b_rr(d,r) ; @@ -5274,13 +5274,13 @@ void alloc_cache(void) if (compiled_code) { flush_icache_hard(6); cache_free(compiled_code); - cache_free(popallspace); - cache_free(veccode); } - popallspace = NULL; - compiled_code=NULL; - veccode=NULL; - if (currprefs.cachesize==0) + if (veccode == NULL) + veccode = cache_alloc (256); + if (popallspace == NULL) + popallspace = cache_alloc (1024); + compiled_code = NULL; + if (currprefs.cachesize == 0) return; while (!compiled_code && currprefs.cachesize) { @@ -5292,7 +5292,6 @@ void alloc_cache(void) max_compile_start=compiled_code+currprefs.cachesize*1024-BYTES_PER_INST; current_compile_p=compiled_code; } - veccode = cache_alloc (256); } extern unsigned long op_illg_1 (uae_u32 opcode) REGPARAM; @@ -5391,7 +5390,7 @@ static void cache_miss(void) return; } Dif (!bi2 || bi==bi2) { - fprintf(stderr,"Unexplained cache miss %p %p\n",bi,bi2); + write_log ("Unexplained cache miss %p %p\n",bi,bi2); abort(); } raise_in_cl_list(bi); @@ -5454,7 +5453,6 @@ static __inline__ void create_popalls(void) { int i,r; - popallspace = cache_alloc (1024); current_compile_p=popallspace; set_target(current_compile_p); #if USE_PUSH_POP @@ -5691,11 +5689,11 @@ void build_comp(void) if (compfunctbl[opcode]) count++; } - fprintf(stderr,"Supposedly %d compileable opcodes!\n",count); + write_log ("Supposedly %d compileable opcodes!\n",count); /* Initialise state */ - create_popalls(); alloc_cache(); + create_popalls(); reset_lists(); for (i=0;i= 2 ? 20 : 4; + int c = currprefs.cpu_level >= 2 ? (compiled_code ? 4 : 20) : 4; int i; if (!(imask && (intena & 0x4000))) { @@ -2450,7 +2455,9 @@ static int intlev_2 (void) } for (i = 14; i >= 0; i--) { if (imask & (1 << i)) { +#ifdef INTDELAY if (!(irqdelay[i] && (cycles - irqcycles[i]) < c * CYCLE_UNIT)) { +#endif irqdelay[i] = 0; if (i == 13 || i == 14) return 6; @@ -2465,7 +2472,9 @@ static int intlev_2 (void) else return 1; } +#ifdef INTDELAY } +#endif } return -1; } @@ -2498,7 +2507,7 @@ STATIC_INLINE void INTENA (uae_u16 v) { setclr (&intena,v); #if 0 - if (v & 0x100) + if (v & 0x40) write_log("INTENA %04.4X (%04.4X) %p\n", intena, v, m68k_getpc()); #endif if (v & 0x8000) @@ -2517,7 +2526,7 @@ void INTREQ (uae_u16 v) serial_check_irq (); rethink_cias (); #if 0 - if (v & 0x100) + if (1 || (v & 0x100)) write_log("INTREQ %04.4X (%04.4X) %p\n", intreq, v, m68k_getpc()); #endif } @@ -2534,16 +2543,6 @@ static void ADKCON (int hpos, uae_u16 v) serial_uartbreak ((adkcon >> 11) & 1); } -static void dumpsync (void) -{ -#if 0 - write_log ("BEAMCON0 = %04.4X VTOTAL=%04.4X HTOTAL=%04.4X\n", new_beamcon0, vtotal, htotal); - write_log ("HSSTOP=%04.4X HBSTRT=%04.4X HBSTOP=%04.4X\n", hsstop, hbstrt, hbstop); - write_log ("VSSTOP=%04.4X VBSTRT=%04.4X VBSTOP=%04.4X\n", vsstop, vbstrt, vbstop); - write_log ("HSSTRT=%04.4X VSSTRT=%04.4X HCENTER=%04.4X\n", hsstrt, vsstrt, hcenter); -#endif -} - static void BEAMCON0 (uae_u16 v) { if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) { @@ -2557,6 +2556,18 @@ static void BEAMCON0 (uae_u16 v) } } +#ifndef CUSTOM_SIMPLE + +static void dumpsync (void) +{ +#if 0 + write_log ("BEAMCON0 = %04.4X VTOTAL=%04.4X HTOTAL=%04.4X\n", new_beamcon0, vtotal, htotal); + write_log ("HSSTOP=%04.4X HBSTRT=%04.4X HBSTOP=%04.4X\n", hsstop, hbstrt, hbstop); + write_log ("VSSTOP=%04.4X VBSTRT=%04.4X VBSTOP=%04.4X\n", vsstop, vbstrt, vbstop); + write_log ("HSSTRT=%04.4X VSSTRT=%04.4X HCENTER=%04.4X\n", hsstrt, vsstrt, hcenter); +#endif +} + static void varsync (void) { #ifdef PICASSO96 @@ -2578,7 +2589,7 @@ static void varsync (void) hack_vpos = -1; dumpsync (); } - +#endif static void BPLxPTH (int hpos, uae_u16 v, int num) { @@ -2700,6 +2711,8 @@ STATIC_INLINE void BPL1DAT (int hpos, uae_u16 v) maybe_first_bpl1dat (hpos); } + +#if 0 /* We could do as well without those... */ STATIC_INLINE void BPL2DAT (uae_u16 v) { bpl2dat = v; } STATIC_INLINE void BPL3DAT (uae_u16 v) { bpl3dat = v; } @@ -2708,6 +2721,7 @@ STATIC_INLINE void BPL5DAT (uae_u16 v) { bpl5dat = v; } STATIC_INLINE void BPL6DAT (uae_u16 v) { bpl6dat = v; } STATIC_INLINE void BPL7DAT (uae_u16 v) { bpl7dat = v; } STATIC_INLINE void BPL8DAT (uae_u16 v) { bpl8dat = v; } +#endif static void DIWSTRT (int hpos, uae_u16 v) { @@ -4180,6 +4194,8 @@ static void frh_handler(void) while (diff32 (curr_time, vsyncmintime + vsynctime) > 0) { vsyncmintime += vsynctime * N_LINES / maxvpos; gonebad++; + if (turbo_emulation) + break; } } } @@ -4909,6 +4925,7 @@ int REGPARAM2 custom_wput_1 (int hpos, uaecptr addr, uae_u32 value, int noget) #endif case 0x110: BPL1DAT (hpos, value); break; +#if 0 /* no point */ case 0x112: BPL2DAT (value); break; case 0x114: BPL3DAT (value); break; case 0x116: BPL4DAT (value); break; @@ -4916,6 +4933,7 @@ int REGPARAM2 custom_wput_1 (int hpos, uaecptr addr, uae_u32 value, int noget) case 0x11A: BPL6DAT (value); break; case 0x11C: BPL7DAT (value); break; case 0x11E: BPL8DAT (value); break; +#endif case 0x180: case 0x182: case 0x184: case 0x186: case 0x188: case 0x18A: case 0x18C: case 0x18E: case 0x190: case 0x192: case 0x194: case 0x196: @@ -4959,6 +4977,7 @@ int REGPARAM2 custom_wput_1 (int hpos, uaecptr addr, uae_u32 value, int noget) case 0x10C: BPLCON4 (hpos, value); break; #endif +#ifndef CUSTOM_SIMPLE case 0x1DC: BEAMCON0 (value); break; case 0x1C0: if (htotal != value) { htotal = value; varsync (); } break; case 0x1C2: if (hsstop != value) { hsstop = value; varsync (); } break; @@ -4971,6 +4990,7 @@ int REGPARAM2 custom_wput_1 (int hpos, uaecptr addr, uae_u32 value, int noget) case 0x1DE: if (hsstrt != value) { hsstrt = value; varsync (); } break; case 0x1E0: if (vsstrt != value) { vsstrt = value; varsync (); } break; case 0x1E2: if (hcenter != value) { hcenter = value; varsync (); } break; +#endif #ifdef AGA case 0x1FC: FMODE (value); break; diff --git a/custom2.c b/custom2.c new file mode 100755 index 00000000..7d7a8b73 --- /dev/null +++ b/custom2.c @@ -0,0 +1,5527 @@ + /* + * UAE - The Un*x Amiga Emulator + * + * Custom chip emulation + * + * Copyright 1995-2002 Bernd Schmidt + * Copyright 1995 Alessandro Bissacco + * Copyright 2000-2004 Toni Wilen + */ + +//#define CUSTOM_DEBUG +#define DEBUG_COPPER 0 +#define SPRITE_DEBUG 0 +#define SPRITE_DEBUG_MINY 0 +#define SPRITE_DEBUG_MAXY 400 +//#define DISABLE_SPRITES +#define SPR0_HPOS 0x15 +#define MAX_SPRITES 8 +#define SPRITE_COLLISIONS +#define SPEEDUP + +#include "sysconfig.h" +#include "sysdeps.h" + +#include +#include + +#include "config.h" +#include "options.h" +#include "threaddep/thread.h" +#include "uae.h" +#include "gensound.h" +#include "sounddep/sound.h" +#include "events.h" +#include "memory.h" +#include "custom.h" +#include "newcpu.h" +#include "cia.h" +#include "disk.h" +#include "blitter.h" +#include "xwin.h" +#include "inputdevice.h" +#include "audio.h" +#include "keybuf.h" +#include "serial.h" +#include "osemu.h" +#include "autoconf.h" +#include "gui.h" +#include "picasso96.h" +#include "drawing.h" +#include "savestate.h" +#include "ar.h" +#include "avioutput.h" +#include "debug.h" +#include "akiko.h" +#include "enforcer.h" + +void uae_abort (const char *format,...) +{ + va_list parms; + char buffer[1000]; + + va_start (parms, format); + _vsnprintf( buffer, sizeof (buffer) -1, format, parms ); + va_end (parms); + gui_message (buffer); + activate_debugger (); +} + +#if 0 +void customhack_put (struct customhack *ch, uae_u16 v, int hpos) +{ + ch->v = v; + ch->vpos = vpos; + ch->hpos = hpos; +} + +uae_u16 customhack_get (struct customhack *ch, int hpos) +{ + if (ch->vpos == vpos && ch->hpos == hpos) { + ch->vpos = -1; + return 0xffff; + } + return ch->v; +} +#endif + +static uae_u16 last_custom_value; + +static unsigned int n_consecutive_skipped = 0; +static unsigned int total_skipped = 0; + +STATIC_INLINE void sync_copper (int hpos); + +/* Events */ + +unsigned long int event_cycles, nextevent, is_lastline, currcycle; +long cycles_to_next_event; +long max_cycles_to_next_event; +long cycles_to_hsync_event; + +static int rpt_did_reset; +struct ev eventtab[ev_max]; + +volatile frame_time_t vsynctime, vsyncmintime; + +int ievent_alive = 0; +#ifdef JIT +extern uae_u8* compiled_code; +#endif + +int vpos; +int hack_vpos; +static uae_u16 lof; +static int next_lineno; +static enum nln_how nextline_how; +static int lof_changed = 0; + +static uae_u32 sprtaba[256],sprtabb[256]; +static uae_u32 sprite_ab_merge[256]; +/* Tables for collision detection. */ +static uae_u32 sprclx[16], clxmask[16]; + +/* + * Hardware registers of all sorts. + */ + +static int custom_wput_1 (int, uaecptr, uae_u32, int) REGPARAM; + +static uae_u16 cregs[256]; + +uae_u16 intena,intreq; +uae_u16 dmacon; +uae_u16 adkcon; /* used by audio code */ + +static uae_u32 cop1lc,cop2lc,copcon; + +int maxhpos = MAXHPOS_PAL; +int maxvpos = MAXVPOS_PAL; +int minfirstline = VBLANK_ENDLINE_PAL; +int vblank_hz = VBLANK_HZ_PAL, fake_vblank_hz, vblank_skip; +unsigned long syncbase; +static int fmode; +unsigned int beamcon0, new_beamcon0; +uae_u16 vtotal = MAXVPOS_PAL, htotal = MAXHPOS_PAL; +static uae_u16 hsstop, hbstrt, hbstop, vsstop, vbstrt, vbstop, hsstrt, vsstrt, hcenter; + +#define HSYNCTIME (maxhpos * CYCLE_UNIT); + +/* This is but an educated guess. It seems to be correct, but this stuff + * isn't documented well. */ +struct sprite { + uaecptr pt; + int xpos; + int vstart; + int vstop; + int armed; + int dmastate; + int dmacycle; +}; + +static struct sprite spr[MAX_SPRITES]; + +static int sprite_vblank_endline = VBLANK_SPRITE_PAL; + +static unsigned int sprctl[MAX_SPRITES], sprpos[MAX_SPRITES]; +#ifdef AGA +static uae_u16 sprdata[MAX_SPRITES][4], sprdatb[MAX_SPRITES][4]; +#else +static uae_u16 sprdata[MAX_SPRITES][1], sprdatb[MAX_SPRITES][1]; +#endif +static int sprite_last_drawn_at[MAX_SPRITES]; +static int last_sprite_point, nr_armed; +static int sprite_width, sprres, sprite_buffer_res; + +#ifdef CPUEMU_6 +uae_u8 cycle_line[256]; +#endif + +static uae_u32 bpl1dat, bpl2dat, bpl3dat, bpl4dat, bpl5dat, bpl6dat, bpl7dat, bpl8dat; +static uae_s16 bpl1mod, bpl2mod; + +static uaecptr bplpt[8]; +uae_u8 *real_bplpt[8]; +/* Used as a debugging aid, to offset any bitplane temporarily. */ +int bpl_off[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + +/*static int blitcount[256]; blitter debug */ + +static struct color_entry current_colors; +static unsigned int bplcon0, bplcon1, bplcon2, bplcon3, bplcon4; +static unsigned int diwstrt, diwstop, diwhigh; +static int diwhigh_written; +static unsigned int ddfstrt, ddfstop, ddfstrt_old, ddfstrt_old_hpos, ddfstrt_old_vpos; +static int ddf_change; +static unsigned int bplcon0_at_start; + +/* The display and data fetch windows */ + +enum diw_states +{ + DIW_waiting_start, DIW_waiting_stop +}; + +int plffirstline, plflastline; +int plfstrt, plfstop; +static int last_diw_pix_hpos, last_ddf_pix_hpos, last_decide_line_hpos; +static int last_fetch_hpos, last_sprite_hpos; +int diwfirstword, diwlastword; +static enum diw_states diwstate, hdiwstate, ddfstate; + +/* Sprite collisions */ +static unsigned int clxdat, clxcon, clxcon2, clxcon_bpl_enable, clxcon_bpl_match; + +enum copper_states { + COP_stop, + COP_read1_in2, + COP_read1_wr_in4, + COP_read1_wr_in2, + COP_read1, + COP_read2_wr_in2, + COP_read2, + COP_bltwait, + COP_wait_in4, + COP_wait_in2, + COP_skip_in4, + COP_skip_in2, + COP_wait1, + COP_wait, + COP_skip1, + COP_strobe_delay +}; + +struct copper { + /* The current instruction words. */ + unsigned int i1, i2; + unsigned int saved_i1, saved_i2; + enum copper_states state; + /* Instruction pointer. */ + uaecptr ip, saved_ip; + int hpos, vpos; + unsigned int ignore_next; + int vcmp, hcmp; + + /* When we schedule a copper event, knowing a few things about the future + of the copper list can reduce the number of sync_with_cpu calls + dramatically. */ + unsigned int first_sync; + unsigned int regtypes_modified; + int strobe; /* COPJMP1 / COPJMP2 accessed */ +}; + +#define REGTYPE_NONE 0 +#define REGTYPE_COLOR 1 +#define REGTYPE_SPRITE 2 +#define REGTYPE_PLANE 4 +#define REGTYPE_BLITTER 8 +#define REGTYPE_JOYPORT 16 +#define REGTYPE_DISK 32 +#define REGTYPE_POS 64 +#define REGTYPE_AUDIO 128 + +#define REGTYPE_ALL 255 +/* Always set in regtypes_modified, to enable a forced update when things like + DMACON, BPLCON0, COPJMPx get written. */ +#define REGTYPE_FORCE 256 + + +static unsigned int regtypes[512]; + +static struct copper cop_state; +static int copper_enabled_thisline; +static int cop_min_waittime; + +/* + * Statistics + */ + +/* Used also by bebox.cpp */ +unsigned long int frametime = 0, lastframetime = 0, timeframes = 0, hsync_counter = 0; +unsigned long int idletime; +int bogusframe; + +#if DEBUG_COPPER +/* 10000 isn't enough! */ +#define NR_COPPER_RECORDS 40000 +#else +#define NR_COPPER_RECORDS 1 +#endif + +/* Record copper activity for the debugger. */ +struct cop_record +{ + int hpos, vpos; + uaecptr addr; +}; +static struct cop_record cop_record[2][NR_COPPER_RECORDS]; +static int nr_cop_records[2]; +static int curr_cop_set; + +/* Recording of custom chip register changes. */ +static int current_change_set; + +#ifdef OS_WITHOUT_MEMORY_MANAGEMENT +/* sam: Those arrays uses around 7Mb of BSS... That seems */ +/* too much for AmigaDOS (uae crashes as soon as one loads */ +/* it. So I use a different strategy here (realloc the */ +/* arrays when needed. That strategy might be usefull for */ +/* computer with low memory. */ +struct sprite_entry *sprite_entries[2]; +struct color_change *color_changes[2]; +static int max_sprite_entry = 400; +static int delta_sprite_entry = 0; +static int max_color_change = 400; +static int delta_color_change = 0; +#else +struct sprite_entry sprite_entries[2][MAX_SPR_PIXELS / 16]; +struct color_change color_changes[2][MAX_REG_CHANGE]; +#endif + +struct decision line_decisions[2 * (MAXVPOS + 1) + 1]; +struct draw_info line_drawinfo[2][2 * (MAXVPOS + 1) + 1]; +struct color_entry color_tables[2][(MAXVPOS + 1) * 2]; + +static int next_sprite_entry = 0; +static int prev_next_sprite_entry; +static int next_sprite_forced = 1; + +struct sprite_entry *curr_sprite_entries, *prev_sprite_entries; +struct color_change *curr_color_changes, *prev_color_changes; +struct draw_info *curr_drawinfo, *prev_drawinfo; +struct color_entry *curr_color_tables, *prev_color_tables; + +static int next_color_change; +static int next_color_entry, remembered_color_entry; +static int color_src_match, color_dest_match, color_compare_result; + +static uae_u32 thisline_changed; + +#ifdef SMART_UPDATE +#define MARK_LINE_CHANGED do { thisline_changed = 1; } while (0) +#else +#define MARK_LINE_CHANGED do { ; } while (0) +#endif + +static struct decision thisline_decision; +static int passed_plfstop, fetch_cycle; + +enum fetchstate { + fetch_not_started, + fetch_started, + fetch_was_plane0 +} fetch_state; + +/* + * helper functions + */ + +uae_u32 get_copper_address (int copno) +{ + switch (copno) { + case 1: return cop1lc; + case 2: return cop2lc; + default: return 0; + } +} + +STATIC_INLINE void record_copper (uaecptr addr, int hpos, int vpos) +{ +#if DEBUG_COPPER + int t = nr_cop_records[curr_cop_set]; + if (t < NR_COPPER_RECORDS) { + cop_record[curr_cop_set][t].addr = addr; + cop_record[curr_cop_set][t].hpos = hpos; + cop_record[curr_cop_set][t].vpos = vpos; + nr_cop_records[curr_cop_set] = t + 1; + } +#endif +} + +int find_copper_record (uaecptr addr, int *phpos, int *pvpos) +{ + int s = curr_cop_set ^ 1; + int t = nr_cop_records[s]; + int i; + for (i = 0; i < t; i++) { + if (cop_record[s][i].addr == addr) { + *phpos = cop_record[s][i].hpos; + *pvpos = cop_record[s][i].vpos; + return 1; + } + } + return 0; +} + +int rpt_available = 0; + +void reset_frame_rate_hack (void) +{ + if (currprefs.m68k_speed != -1) + return; + + if (! rpt_available) { + currprefs.m68k_speed = 0; + return; + } + + rpt_did_reset = 1; + is_lastline = 0; + vsyncmintime = read_processor_time() + vsynctime; + write_log ("Resetting frame rate hack\n"); +} + +STATIC_INLINE void setclr (uae_u16 *p, uae_u16 val) +{ + if (val & 0x8000) + *p |= val & 0x7FFF; + else + *p &= ~val; +} + +STATIC_INLINE int current_hpos (void) +{ + return (get_cycles () - eventtab[ev_hsync].oldcycles) / CYCLE_UNIT; +} + +STATIC_INLINE uae_u8 *pfield_xlateptr (uaecptr plpt, int bytecount) +{ + if (!chipmem_bank.check (plpt, bytecount)) { + static int count = 0; + if (!count) + count++, write_log ("Warning: Bad playfield pointer\n"); + return NULL; + } + return chipmem_bank.xlateaddr (plpt); +} + +STATIC_INLINE void docols (struct color_entry *colentry) +{ + int i; + +#ifdef AGA + if (currprefs.chipset_mask & CSMASK_AGA) { + for (i = 0; i < 256; i++) { + int v = color_reg_get (colentry, i); + if (v < 0 || v > 16777215) + continue; + colentry->acolors[i] = CONVERT_RGB (v); + } + } else { +#endif + for (i = 0; i < 32; i++) { + int v = color_reg_get (colentry, i); + if (v < 0 || v > 4095) + continue; + colentry->acolors[i] = xcolors[v]; + } +#ifdef AGA + } +#endif +} + +void notice_new_xcolors (void) +{ + int i; + + docols(¤t_colors); +/* docols(&colors_for_drawing);*/ + for (i = 0; i < (MAXVPOS + 1)*2; i++) { + docols(color_tables[0]+i); + docols(color_tables[1]+i); + } +} + +static void do_sprites (int currhp); + +static void remember_ctable (void) +{ + if (remembered_color_entry == -1) { + /* The colors changed since we last recorded a color map. Record a + * new one. */ + color_reg_cpy (curr_color_tables + next_color_entry, ¤t_colors); + remembered_color_entry = next_color_entry++; + } + thisline_decision.ctable = remembered_color_entry; + if (color_src_match == -1 || color_dest_match != remembered_color_entry + || line_decisions[next_lineno].ctable != color_src_match) + { + /* The remembered comparison didn't help us - need to compare again. */ + int oldctable = line_decisions[next_lineno].ctable; + int changed = 0; + + if (oldctable == -1) { + changed = 1; + color_src_match = color_dest_match = -1; + } else { + color_compare_result = color_reg_cmp (&prev_color_tables[oldctable], ¤t_colors) != 0; + if (color_compare_result) + changed = 1; + color_src_match = oldctable; + color_dest_match = remembered_color_entry; + } + thisline_changed |= changed; + } else { + /* We know the result of the comparison */ + if (color_compare_result) + thisline_changed = 1; + } +} + +static void remember_ctable_for_border (void) +{ + remember_ctable (); +} + +/* Called to determine the state of the horizontal display window state + * machine at the current position. It might have changed since we last + * checked. */ +static void decide_diw (int hpos) +{ + int pix_hpos = coord_diw_to_window_x (hpos == 227 ? 455 : hpos * 2); /* (227.5*2 = 455) */ + if (hdiwstate == DIW_waiting_start && thisline_decision.diwfirstword == -1 + && pix_hpos >= diwfirstword && last_diw_pix_hpos < diwfirstword) + { + thisline_decision.diwfirstword = diwfirstword < 0 ? 0 : diwfirstword; + hdiwstate = DIW_waiting_stop; + } + if (hdiwstate == DIW_waiting_stop && thisline_decision.diwlastword == -1 + && pix_hpos >= diwlastword && last_diw_pix_hpos < diwlastword) + { + thisline_decision.diwlastword = diwlastword < 0 ? 0 : diwlastword; + hdiwstate = DIW_waiting_start; + } + last_diw_pix_hpos = pix_hpos; +} + +/* The HRM says 0xD8, but that can't work... */ +#define HARD_DDF_STOP 0xd4 +#define HARD_DDF_START 0x18 + +static void add_modulos (void) +{ + int m1, m2; + + if (fmode & 0x4000) { + if (((diwstrt >> 8) ^ vpos) & 1) + m1 = m2 = bpl2mod; + else + m1 = m2 = bpl1mod; + } else { + m1 = bpl1mod; + m2 = bpl2mod; + } + + switch (GET_PLANES (bplcon0)) { +#ifdef AGA + case 8: bplpt[7] += m2; + case 7: bplpt[6] += m1; +#endif + case 6: bplpt[5] += m2; + case 5: bplpt[4] += m1; + case 4: bplpt[3] += m2; + case 3: bplpt[2] += m1; + case 2: bplpt[1] += m2; + case 1: bplpt[0] += m1; + } +} + +static void finish_playfield_line (void) +{ + /* The latter condition might be able to happen in interlaced frames. */ + if (vpos >= minfirstline && (thisframe_first_drawn_line == -1 || vpos < thisframe_first_drawn_line)) + thisframe_first_drawn_line = vpos; + thisframe_last_drawn_line = vpos; + + /* These are for comparison. */ + thisline_decision.bplcon0 = bplcon0; + thisline_decision.bplcon2 = bplcon2; +#ifdef AGA + thisline_decision.bplcon3 = bplcon3; + thisline_decision.bplcon4 = bplcon4; +#endif + +#ifdef SMART_UPDATE + if (line_decisions[next_lineno].plflinelen != thisline_decision.plflinelen + || line_decisions[next_lineno].plfleft != thisline_decision.plfleft + || line_decisions[next_lineno].bplcon0 != thisline_decision.bplcon0 + || line_decisions[next_lineno].bplcon2 != thisline_decision.bplcon2 +#ifdef AGA + || line_decisions[next_lineno].bplcon3 != thisline_decision.bplcon3 + || line_decisions[next_lineno].bplcon4 != thisline_decision.bplcon4 +#endif + ) +#endif /* SMART_UPDATE */ + thisline_changed = 1; +} + +static int fetchmode; + +/* The fetch unit mainly controls ddf stop. It's the number of cycles that + are contained in an indivisible block during which ddf is active. E.g. + if DDF starts at 0x30, and fetchunit is 8, then possible DDF stops are + 0x30 + n * 8. */ +static int fetchunit, fetchunit_mask; +/* The delay before fetching the same bitplane again. Can be larger than + the number of bitplanes; in that case there are additional empty cycles + with no data fetch (this happens for high fetchmodes and low + resolutions). */ +static int fetchstart, fetchstart_shift, fetchstart_mask; +/* fm_maxplane holds the maximum number of planes possible with the current + fetch mode. This selects the cycle diagram: + 8 planes: 73516240 + 4 planes: 3120 + 2 planes: 10. */ +static int fm_maxplane, fm_maxplane_shift; + +/* The corresponding values, by fetchmode and display resolution. */ +static int fetchunits[] = { 8,8,8,0, 16,8,8,0, 32,16,8,0 }; +static int fetchstarts[] = { 3,2,1,0, 4,3,2,0, 5,4,3,0 }; +static int fm_maxplanes[] = { 3,2,1,0, 3,3,2,0, 3,3,3,0 }; + +static uae_u8 cycle_diagram_table[3][3][9][32]; +static uae_u8 cycle_diagram_free_cycles[3][3][9]; +static uae_u8 cycle_diagram_total_cycles[3][3][9]; +static uae_u8 *curr_diagram; +static uae_u8 cycle_sequences[3*8] = { 2,1,2,1,2,1,2,1, 4,2,3,1,4,2,3,1, 8,4,6,2,7,3,5,1 }; + +static void debug_cycle_diagram(void) +{ + int fm, res, planes, cycle, v; + char aa; + + for (fm = 0; fm < 3; fm++) { + write_log ("FMODE %d\n=======\n", fm); + for (res = 0; res <= 2; res++) { + for (planes = 0; planes <= 8; planes++) { + write_log("%d: ",planes); + for (cycle = 0; cycle < 32; cycle++) { + v=cycle_diagram_table[fm][res][planes][cycle]; + if (v==0) aa='-'; else if(v>0) aa='1'; else aa='X'; + write_log("%c",aa); + } + write_log(" %d:%d\n", + cycle_diagram_free_cycles[fm][res][planes], cycle_diagram_total_cycles[fm][res][planes]); + } + write_log("\n"); + } + } + fm=0; +} + +static void create_cycle_diagram_table(void) +{ + int fm, res, cycle, planes, v; + int fetch_start, max_planes, freecycles; + uae_u8 *cycle_sequence; + + for (fm = 0; fm <= 2; fm++) { + for (res = 0; res <= 2; res++) { + max_planes = fm_maxplanes[fm * 4 + res]; + fetch_start = 1 << fetchstarts[fm * 4 + res]; + cycle_sequence = &cycle_sequences[(max_planes - 1) * 8]; + max_planes = 1 << max_planes; + for (planes = 0; planes <= 8; planes++) { + freecycles = 0; + for (cycle = 0; cycle < 32; cycle++) + cycle_diagram_table[fm][res][planes][cycle] = -1; + if (planes <= max_planes) { + for (cycle = 0; cycle < fetch_start; cycle++) { + if (cycle < max_planes && planes >= cycle_sequence[cycle & 7]) { + v = 1; + } else { + v = 0; + freecycles++; + } + cycle_diagram_table[fm][res][planes][cycle] = v; + } + } + cycle_diagram_free_cycles[fm][res][planes] = freecycles; + cycle_diagram_total_cycles[fm][res][planes] = fetch_start; + } + } + } +#if 0 + debug_cycle_diagram (); +#endif +} + + +/* Used by the copper. */ +static int estimated_last_fetch_cycle; +static int cycle_diagram_shift; + +static void estimate_last_fetch_cycle (int hpos) +{ + int fetchunit = fetchunits[fetchmode * 4 + GET_RES (bplcon0)]; + + if (! passed_plfstop) { + int stop = plfstop < hpos || plfstop > HARD_DDF_STOP ? HARD_DDF_STOP : plfstop; + /* We know that fetching is up-to-date up until hpos, so we can use fetch_cycle. */ + int fetch_cycle_at_stop = fetch_cycle + (stop - hpos); + int starting_last_block_at = (fetch_cycle_at_stop + fetchunit - 1) & ~(fetchunit - 1); + + estimated_last_fetch_cycle = hpos + (starting_last_block_at - fetch_cycle) + fetchunit; + } else { + int starting_last_block_at = (fetch_cycle + fetchunit - 1) & ~(fetchunit - 1); + if (passed_plfstop == 2) + starting_last_block_at -= fetchunit; + + estimated_last_fetch_cycle = hpos + (starting_last_block_at - fetch_cycle) + fetchunit; + } +} + +static uae_u32 outword[MAX_PLANES]; +static int out_nbits, out_offs; +static uae_u32 todisplay[MAX_PLANES][4]; +static uae_u32 fetched[MAX_PLANES]; +#ifdef AGA +static uae_u32 fetched_aga0[MAX_PLANES]; +static uae_u32 fetched_aga1[MAX_PLANES]; +#endif + +/* Expansions from bplcon0/bplcon1. */ +static int toscr_res, toscr_res_first, toscr_nr_planes, fetchwidth; +static int toscr_delay1x, toscr_delay2x, toscr_delay1, toscr_delay2; + +/* The number of bits left from the last fetched words. + This is an optimization - conceptually, we have to make sure the result is + the same as if toscr is called in each clock cycle. However, to speed this + up, we accumulate display data; this variable keeps track of how much. + Thus, once we do call toscr_nbits (which happens at least every 16 bits), + we can do more work at once. */ +static int toscr_nbits; + +static int delayoffset; + +STATIC_INLINE void compute_delay_offset (void) +{ + delayoffset = ((plfstrt - HARD_DDF_START) & fetchstart_mask) << 1; + if (delayoffset & 8) + delayoffset = 8; + else if (delayoffset & 16) + delayoffset = 16; + else if (delayoffset & 32) + delayoffset = 32; + else + delayoffset = 0; +} + +static void expand_fmodes (void) +{ + int res = GET_RES(bplcon0); + int fm = fetchmode; + fetchunit = fetchunits[fm * 4 + res]; + fetchunit_mask = fetchunit - 1; + fetchstart_shift = fetchstarts[fm * 4 + res]; + fetchstart = 1 << fetchstart_shift; + fetchstart_mask = fetchstart - 1; + fm_maxplane_shift = fm_maxplanes[fm * 4 + res]; + fm_maxplane = 1 << fm_maxplane_shift; + curr_diagram = cycle_diagram_table[fm][res][GET_PLANES (bplcon0)]; +} + +static int maxplanes_ocs[]={ 6,4,0,0 }; +static int maxplanes_ecs[]={ 6,4,2,0 }; +static int maxplanes_aga[]={ 8,4,2,0, 8,8,4,0, 8,8,8,0 }; + +/* Expand bplcon0/bplcon1 into the toscr_xxx variables. */ +static void compute_toscr_delay_1 (void) +{ + int delay1 = (bplcon1 & 0x0f) | ((bplcon1 & 0x0c00) >> 6); + int delay2 = ((bplcon1 >> 4) & 0x0f) | (((bplcon1 >> 4) & 0x0c00) >> 6); + int delaymask; + int fetchwidth = 16 << fetchmode; + + delay1 += delayoffset; + delay2 += delayoffset; + delaymask = (fetchwidth - 1) >> toscr_res; + toscr_delay1x = (delay1 & delaymask) << toscr_res; + toscr_delay2x = (delay2 & delaymask) << toscr_res; +} + +static int get_maxplanes (int res) +{ + int *planes; + if (currprefs.chipset_mask & CSMASK_AGA) + planes = maxplanes_aga; + else if (! (currprefs.chipset_mask & CSMASK_ECS_DENISE)) + planes = maxplanes_ocs; + else + planes = maxplanes_ecs; + return planes[fetchmode * 4 + res]; +} + +static void compute_toscr_delay (int hpos) +{ + int v = bplcon0; + /* Disable bitplane DMA if planes > maxplanes. This is needed e.g. by the + Sanity WOC demo (at the "Party Effect"). */ + if (GET_PLANES(v) > get_maxplanes (GET_RES(v))) + v &= ~0x7010; + toscr_res = GET_RES (v); + toscr_nr_planes = GET_PLANES (v); + compute_toscr_delay_1 (); +} + +STATIC_INLINE void maybe_first_bpl1dat (int hpos) +{ + if (thisline_decision.plfleft == -1) { + thisline_decision.plfleft = hpos; + compute_delay_offset (); + compute_toscr_delay_1 (); + } +} + +STATIC_INLINE void fetch (int nr, int fm) +{ + uaecptr p; + if (nr >= toscr_nr_planes) + return; + p = bplpt[nr] + bpl_off[nr]; + switch (fm) { + case 0: + fetched[nr] = last_custom_value = chipmem_wget (p); + bplpt[nr] += 2; + break; +#ifdef AGA + case 1: + fetched_aga0[nr] = chipmem_lget (p); + last_custom_value = (uae_u16)fetched_aga0[nr]; + bplpt[nr] += 4; + break; + case 2: + fetched_aga1[nr] = chipmem_lget (p); + fetched_aga0[nr] = chipmem_lget (p + 4); + last_custom_value = (uae_u16)fetched_aga0[nr]; + bplpt[nr] += 8; + break; +#endif + } + if (passed_plfstop == 2 && fetch_cycle >= (fetch_cycle & ~fetchunit_mask) + fetchunit - fetchstart) { + int mod; + if (fmode & 0x4000) { + if (((diwstrt >> 8) ^ vpos) & 1) + mod = bpl2mod; + else + mod = bpl1mod; + } else if (nr & 1) + mod = bpl2mod; + else + mod = bpl1mod; + bplpt[nr] += mod; + } + if (nr == 0) + fetch_state = fetch_was_plane0; +} + +static void clear_fetchbuffer (uae_u32 *ptr, int nwords) +{ + int i; + + if (! thisline_changed) + for (i = 0; i < nwords; i++) + if (ptr[i]) { + thisline_changed = 1; + break; + } + + memset (ptr, 0, nwords * 4); +} + +static void update_toscr_planes (void) +{ + if (toscr_nr_planes > thisline_decision.nr_planes) { + int j; + for (j = thisline_decision.nr_planes; j < toscr_nr_planes; j++) + clear_fetchbuffer ((uae_u32 *)(line_data[next_lineno] + 2 * MAX_WORDS_PER_LINE * j), out_offs); +#if 0 + if (thisline_decision.nr_planes > 0) + printf ("Planes from %d to %d\n", thisline_decision.nr_planes, toscr_nr_planes); +#endif + thisline_decision.nr_planes = toscr_nr_planes; + } +} + +STATIC_INLINE void toscr_3_ecs (int nbits) +{ + int delay1 = toscr_delay1; + int delay2 = toscr_delay2; + int i; + uae_u32 mask = 0xFFFF >> (16 - nbits); + + for (i = 0; i < toscr_nr_planes; i += 2) { + outword[i] <<= nbits; + outword[i] |= (todisplay[i][0] >> (16 - nbits + delay1)) & mask; + todisplay[i][0] <<= nbits; + } + for (i = 1; i < toscr_nr_planes; i += 2) { + outword[i] <<= nbits; + outword[i] |= (todisplay[i][0] >> (16 - nbits + delay2)) & mask; + todisplay[i][0] <<= nbits; + } +} + +STATIC_INLINE void shift32plus (uae_u32 *p, int n) +{ + uae_u32 t = p[1]; + t <<= n; + t |= p[0] >> (32 - n); + p[1] = t; +} + +#ifdef AGA +STATIC_INLINE void aga_shift (uae_u32 *p, int n, int fm) +{ + if (fm == 2) { + shift32plus (p + 2, n); + shift32plus (p + 1, n); + } + shift32plus (p + 0, n); + p[0] <<= n; +} + +STATIC_INLINE void toscr_3_aga (int nbits, int fm) +{ + int delay1 = toscr_delay1; + int delay2 = toscr_delay2; + int i; + uae_u32 mask = 0xFFFF >> (16 - nbits); + + { + int offs = (16 << fm) - nbits + delay1; + int off1 = offs >> 5; + if (off1 == 3) + off1 = 2; + offs -= off1 * 32; + for (i = 0; i < toscr_nr_planes; i += 2) { + uae_u32 t0 = todisplay[i][off1]; + uae_u32 t1 = todisplay[i][off1 + 1]; + uae_u64 t = (((uae_u64)t1) << 32) | t0; + outword[i] <<= nbits; + outword[i] |= (t >> offs) & mask; + aga_shift (todisplay[i], nbits, fm); + } + } + { + int offs = (16 << fm) - nbits + delay2; + int off1 = offs >> 5; + if (off1 == 3) + off1 = 2; + offs -= off1 * 32; + for (i = 1; i < toscr_nr_planes; i += 2) { + uae_u32 t0 = todisplay[i][off1]; + uae_u32 t1 = todisplay[i][off1 + 1]; + uae_u64 t = (((uae_u64)t1) << 32) | t0; + outword[i] <<= nbits; + outword[i] |= (t >> offs) & mask; + aga_shift (todisplay[i], nbits, fm); + } + } +} + +#endif + +static void toscr_2_0 (int nbits) { toscr_3_ecs (nbits); } +#ifdef AGA +static void toscr_2_1 (int nbits) { toscr_3_aga (nbits, 1); } +static void toscr_2_2 (int nbits) { toscr_3_aga (nbits, 2); } +#endif + +STATIC_INLINE void toscr_1 (int nbits, int fm) +{ + switch (fm) { + case 0: + toscr_2_0 (nbits); + break; +#ifdef AGA + case 1: + toscr_2_1 (nbits); + break; + case 2: + toscr_2_2 (nbits); + break; +#endif + } + out_nbits += nbits; + if (out_nbits == 32) { + int i; + uae_u8 *dataptr = line_data[next_lineno] + out_offs * 4; + for (i = 0; i < thisline_decision.nr_planes; i++) { + uae_u32 *dataptr32 = (uae_u32 *)dataptr; + if (i >= toscr_nr_planes) + outword[i] = 0; + if (*dataptr32 != outword[i]) + thisline_changed = 1; + *dataptr32 = outword[i]; + dataptr += MAX_WORDS_PER_LINE * 2; + } + out_offs++; + out_nbits = 0; + } +} + +static void toscr_fm0 (int); +static void toscr_fm1 (int); +static void toscr_fm2 (int); + +STATIC_INLINE void toscr (int nbits, int fm) +{ + switch (fm) { + case 0: toscr_fm0 (nbits); break; +#ifdef AGA + case 1: toscr_fm1 (nbits); break; + case 2: toscr_fm2 (nbits); break; +#endif + } +} + +STATIC_INLINE void toscr_0 (int nbits, int fm) +{ + int t; + + if (nbits > 16) { + toscr (16, fm); + nbits -= 16; + } + + t = 32 - out_nbits; + if (t < nbits) { + toscr_1 (t, fm); + nbits -= t; + } + toscr_1 (nbits, fm); +} + +static void toscr_fm0 (int nbits) { toscr_0 (nbits, 0); } +static void toscr_fm1 (int nbits) { toscr_0 (nbits, 1); } +static void toscr_fm2 (int nbits) { toscr_0 (nbits, 2); } + +static int flush_plane_data (int fm) +{ + int i = 0; + int fetchwidth = 16 << fm; + + if (out_nbits <= 16) { + i += 16; + toscr_1 (16, fm); + } + if (out_nbits != 0) { + i += 32 - out_nbits; + toscr_1 (32 - out_nbits, fm); + } + i += 32; + + toscr_1 (16, fm); + toscr_1 (16, fm); + return i >> (1 + toscr_res); +} + +STATIC_INLINE void flush_display (int fm) +{ + if (toscr_nbits > 0 && thisline_decision.plfleft != -1) + toscr (toscr_nbits, fm); + toscr_nbits = 0; +} + +/* Called when all planes have been fetched, i.e. when a new block + of data is available to be displayed. The data in fetched[] is + moved into todisplay[]. */ +STATIC_INLINE void beginning_of_plane_block (int pos, int fm) +{ + int i; + + flush_display (fm); + if (fm == 0) + for (i = 0; i < MAX_PLANES; i++) + todisplay[i][0] |= fetched[i]; +#ifdef AGA + else + for (i = 0; i < MAX_PLANES; i++) { + if (fm == 2) + todisplay[i][1] = fetched_aga1[i]; + todisplay[i][0] = fetched_aga0[i]; + } +#endif + maybe_first_bpl1dat (pos); + toscr_delay1 = toscr_delay1x; + toscr_delay2 = toscr_delay2x; +} + +#ifdef SPEEDUP + +/* The usual inlining tricks - don't touch unless you know what you are doing. */ +STATIC_INLINE void long_fetch_ecs (int plane, int nwords, int weird_number_of_bits, int dma) +{ + uae_u16 *real_pt = (uae_u16 *)pfield_xlateptr (bplpt[plane] + bpl_off[plane], nwords * 2); + int delay = (plane & 1) ? toscr_delay2 : toscr_delay1; + int tmp_nbits = out_nbits; + uae_u32 shiftbuffer = todisplay[plane][0]; + uae_u32 outval = outword[plane]; + uae_u32 fetchval = fetched[plane]; + uae_u32 *dataptr = (uae_u32 *)(line_data[next_lineno] + 2 * plane * MAX_WORDS_PER_LINE + 4 * out_offs); + + if (dma) + bplpt[plane] += nwords * 2; + + if (real_pt == 0) + /* @@@ Don't do this, fall back on chipmem_wget instead. */ + return; + + while (nwords > 0) { + int bits_left = 32 - tmp_nbits; + uae_u32 t; + + shiftbuffer |= fetchval; + + t = (shiftbuffer >> delay) & 0xFFFF; + + if (weird_number_of_bits && bits_left < 16) { + outval <<= bits_left; + outval |= t >> (16 - bits_left); + thisline_changed |= *dataptr ^ outval; + *dataptr++ = outval; + + outval = t; + tmp_nbits = 16 - bits_left; + shiftbuffer <<= 16; + } else { + outval = (outval << 16) | t; + shiftbuffer <<= 16; + tmp_nbits += 16; + if (tmp_nbits == 32) { + thisline_changed |= *dataptr ^ outval; + *dataptr++ = outval; + tmp_nbits = 0; + } + } + nwords--; + if (dma) { + fetchval = do_get_mem_word (real_pt); + real_pt++; + } + } + fetched[plane] = fetchval; + todisplay[plane][0] = shiftbuffer; + outword[plane] = outval; +} + +#ifdef AGA +STATIC_INLINE void long_fetch_aga (int plane, int nwords, int weird_number_of_bits, int fm, int dma) +{ + uae_u32 *real_pt = (uae_u32 *)pfield_xlateptr (bplpt[plane] + bpl_off[plane], nwords * 2); + int delay = (plane & 1) ? toscr_delay2 : toscr_delay1; + int tmp_nbits = out_nbits; + uae_u32 *shiftbuffer = todisplay[plane]; + uae_u32 outval = outword[plane]; + uae_u32 fetchval0 = fetched_aga0[plane]; + uae_u32 fetchval1 = fetched_aga1[plane]; + uae_u32 *dataptr = (uae_u32 *)(line_data[next_lineno] + 2 * plane * MAX_WORDS_PER_LINE + 4 * out_offs); + int offs = (16 << fm) - 16 + delay; + int off1 = offs >> 5; + if (off1 == 3) + off1 = 2; + offs -= off1 * 32; + + if (dma) + bplpt[plane] += nwords * 2; + + if (real_pt == 0) + /* @@@ Don't do this, fall back on chipmem_wget instead. */ + return; + + while (nwords > 0) { + int i; + + shiftbuffer[0] = fetchval0; + if (fm == 2) + shiftbuffer[1] = fetchval1; + + for (i = 0; i < (1 << fm); i++) { + int bits_left = 32 - tmp_nbits; + + uae_u32 t0 = shiftbuffer[off1]; + uae_u32 t1 = shiftbuffer[off1 + 1]; + uae_u64 t = (((uae_u64)t1) << 32) | t0; + + t0 = (uae_u32)((t >> offs) & 0xFFFF); + + if (weird_number_of_bits && bits_left < 16) { + outval <<= bits_left; + outval |= t0 >> (16 - bits_left); + + thisline_changed |= *dataptr ^ outval; + *dataptr++ = outval; + + outval = t0; + tmp_nbits = 16 - bits_left; + aga_shift (shiftbuffer, 16, fm); + } else { + outval = (outval << 16) | t0; + aga_shift (shiftbuffer, 16, fm); + tmp_nbits += 16; + if (tmp_nbits == 32) { + thisline_changed |= *dataptr ^ outval; + *dataptr++ = outval; + tmp_nbits = 0; + } + } + } + + nwords -= 1 << fm; + + if (dma) { + if (fm == 1) + fetchval0 = do_get_mem_long (real_pt); + else { + fetchval1 = do_get_mem_long (real_pt); + fetchval0 = do_get_mem_long (real_pt + 1); + } + real_pt += fm; + } + } + fetched_aga0[plane] = fetchval0; + fetched_aga1[plane] = fetchval1; + outword[plane] = outval; +} +#endif + +static void long_fetch_ecs_0 (int hpos, int nwords, int dma) { long_fetch_ecs (hpos, nwords, 0, dma); } +static void long_fetch_ecs_1 (int hpos, int nwords, int dma) { long_fetch_ecs (hpos, nwords, 1, dma); } +#ifdef AGA +static void long_fetch_aga_1_0 (int hpos, int nwords, int dma) { long_fetch_aga (hpos, nwords, 0, 1, dma); } +static void long_fetch_aga_1_1 (int hpos, int nwords, int dma) { long_fetch_aga (hpos, nwords, 1, 1, dma); } +static void long_fetch_aga_2_0 (int hpos, int nwords, int dma) { long_fetch_aga (hpos, nwords, 0, 2, dma); } +static void long_fetch_aga_2_1 (int hpos, int nwords, int dma) { long_fetch_aga (hpos, nwords, 1, 2, dma); } +#endif + +static void do_long_fetch (int hpos, int nwords, int dma, int fm) +{ + int i; + + flush_display (fm); + switch (fm) { + case 0: + if (out_nbits & 15) { + for (i = 0; i < toscr_nr_planes; i++) + long_fetch_ecs_1 (i, nwords, dma); + } else { + for (i = 0; i < toscr_nr_planes; i++) + long_fetch_ecs_0 (i, nwords, dma); + } + break; +#ifdef AGA + case 1: + if (out_nbits & 15) { + for (i = 0; i < toscr_nr_planes; i++) + long_fetch_aga_1_1 (i, nwords, dma); + } else { + for (i = 0; i < toscr_nr_planes; i++) + long_fetch_aga_1_0 (i, nwords, dma); + } + break; + case 2: + if (out_nbits & 15) { + for (i = 0; i < toscr_nr_planes; i++) + long_fetch_aga_2_1 (i, nwords, dma); + } else { + for (i = 0; i < toscr_nr_planes; i++) + long_fetch_aga_2_0 (i, nwords, dma); + } + break; +#endif + } + + out_nbits += nwords * 16; + out_offs += out_nbits >> 5; + out_nbits &= 31; + + if (dma && toscr_nr_planes > 0) + fetch_state = fetch_was_plane0; +} + +#endif + +/* make sure fetch that goes beyond maxhpos is finished */ +static void finish_final_fetch (int i, int fm) +{ + if (thisline_decision.plfleft == -1) + return; + if (passed_plfstop == 3) + return; + passed_plfstop = 3; + ddfstate = DIW_waiting_start; + i += flush_plane_data (fm); + thisline_decision.plfright = i; + thisline_decision.plflinelen = out_offs; + thisline_decision.bplres = toscr_res_first; + finish_playfield_line (); +} + +STATIC_INLINE int one_fetch_cycle_0 (int i, int ddfstop_to_test, int dma, int fm) +{ + if (! passed_plfstop && i == ddfstop_to_test) + passed_plfstop = 1; + + if ((fetch_cycle & fetchunit_mask) == 0) { + if (passed_plfstop == 2) { + finish_final_fetch (i, fm); + return 1; + } + if (passed_plfstop) + passed_plfstop++; + } + + if (dma) { + /* fetchstart_mask can be larger than fm_maxplane if FMODE > 0. This means + that the remaining cycles are idle; we'll fall through the whole switch + without doing anything. */ + int cycle_start = fetch_cycle & fetchstart_mask; + switch (fm_maxplane) { + case 8: + switch (cycle_start) { + case 0: fetch (7, fm); break; + case 1: fetch (3, fm); break; + case 2: fetch (5, fm); break; + case 3: fetch (1, fm); break; + case 4: fetch (6, fm); break; + case 5: fetch (2, fm); break; + case 6: fetch (4, fm); break; + case 7: fetch (0, fm); break; + } + break; + case 4: + switch (cycle_start) { + case 0: fetch (3, fm); break; + case 1: fetch (1, fm); break; + case 2: fetch (2, fm); break; + case 3: fetch (0, fm); break; + } + break; + case 2: + switch (cycle_start) { + case 0: fetch (1, fm); break; + case 1: fetch (0, fm); break; + } + break; + } + } + fetch_cycle++; + toscr_nbits += 2 << toscr_res; + + if (toscr_nbits == 16) + flush_display (fm); + if (toscr_nbits > 16) + uae_abort ("toscr_nbits > 16 (%d)", toscr_nbits); + + return 0; +} + +static int one_fetch_cycle_fm0 (int i, int ddfstop_to_test, int dma) { return one_fetch_cycle_0 (i, ddfstop_to_test, dma, 0); } +static int one_fetch_cycle_fm1 (int i, int ddfstop_to_test, int dma) { return one_fetch_cycle_0 (i, ddfstop_to_test, dma, 1); } +static int one_fetch_cycle_fm2 (int i, int ddfstop_to_test, int dma) { return one_fetch_cycle_0 (i, ddfstop_to_test, dma, 2); } + +STATIC_INLINE int one_fetch_cycle (int i, int ddfstop_to_test, int dma, int fm) +{ + switch (fm) { + case 0: return one_fetch_cycle_fm0 (i, ddfstop_to_test, dma); +#ifdef AGA + case 1: return one_fetch_cycle_fm1 (i, ddfstop_to_test, dma); + case 2: return one_fetch_cycle_fm2 (i, ddfstop_to_test, dma); +#endif + default: uae_abort ("fm corrupt"); return 0; + } +} + +STATIC_INLINE void update_fetch (int until, int fm) +{ + int pos; + int dma = dmaen (DMA_BITPLANE); + + int ddfstop_to_test; + + if (framecnt != 0 || passed_plfstop == 3) + return; + + /* We need an explicit test against HARD_DDF_STOP here to guard against + programs that move the DDFSTOP before our current position before we + reach it. */ + ddfstop_to_test = HARD_DDF_STOP; + if (ddfstop >= last_fetch_hpos && plfstop < ddfstop_to_test) + ddfstop_to_test = plfstop; + + compute_toscr_delay (last_fetch_hpos); + update_toscr_planes (); + + pos = last_fetch_hpos; + cycle_diagram_shift = last_fetch_hpos - fetch_cycle; + + /* First, a loop that prepares us for the speedup code. We want to enter + the SPEEDUP case with fetch_state == fetch_was_plane0, and then unroll + whole blocks, so that we end on the same fetch_state again. */ + for (; ; pos++) { + if (pos == until) { + if (until >= maxhpos) { + finish_final_fetch (pos, fm); + return; + } + flush_display (fm); + return; + } + + if (fetch_state == fetch_was_plane0) + break; + + fetch_state = fetch_started; + if (one_fetch_cycle (pos, ddfstop_to_test, dma, fm)) + return; + } + +#ifdef SPEEDUP + /* Unrolled version of the for loop below. */ + if (! passed_plfstop && ddf_change != vpos && ddf_change + 1 != vpos + && dma + && (fetch_cycle & fetchstart_mask) == (fm_maxplane & fetchstart_mask) + && toscr_delay1 == toscr_delay1x && toscr_delay2 == toscr_delay2x + # if 0 + /* @@@ We handle this case, but the code would be simpler if we + * disallowed it - it may even be possible to guarantee that + * this condition never is false. Later. */ + && (out_nbits & 15) == 0 +# endif + && toscr_nr_planes == thisline_decision.nr_planes) + { + int offs = (pos - fetch_cycle) & fetchunit_mask; + int ddf2 = ((ddfstop_to_test - offs + fetchunit - 1) & ~fetchunit_mask) + offs; + int ddf3 = ddf2 + fetchunit; + int stop = until < ddf2 ? until : until < ddf3 ? ddf2 : ddf3; + int count; + + count = stop - pos; + + if (count >= fetchstart) { + count &= ~fetchstart_mask; + + if (thisline_decision.plfleft == -1) { + compute_delay_offset (); + compute_toscr_delay_1 (); + } + do_long_fetch (pos, count >> (3 - toscr_res), dma, fm); + + /* This must come _after_ do_long_fetch so as not to confuse flush_display + into thinking the first fetch has produced any output worth emitting to + the screen. But the calculation of delay_offset must happen _before_. */ + maybe_first_bpl1dat (pos); + + if (pos <= ddfstop_to_test && pos + count > ddfstop_to_test) + passed_plfstop = 1; + if (pos <= ddfstop_to_test && pos + count > ddf2) + passed_plfstop = 2; + if (pos <= ddf2 && pos + count >= ddf2 + fm_maxplane) + add_modulos (); + pos += count; + fetch_cycle += count; + } + } +#endif + for (; pos < until; pos++) { + if (fetch_state == fetch_was_plane0) + beginning_of_plane_block (pos, fm); + fetch_state = fetch_started; + + if (one_fetch_cycle (pos, ddfstop_to_test, dma, fm)) + return; + } + if (until >= maxhpos) { + finish_final_fetch (pos, fm); + return; + } + flush_display (fm); +} + +static void update_fetch_0 (int hpos) { update_fetch (hpos, 0); } +static void update_fetch_1 (int hpos) { update_fetch (hpos, 1); } +static void update_fetch_2 (int hpos) { update_fetch (hpos, 2); } + +STATIC_INLINE void decide_fetch (int hpos) +{ + if (fetch_state != fetch_not_started && hpos > last_fetch_hpos) { + switch (fetchmode) { + case 0: update_fetch_0 (hpos); break; +#ifdef AGA + case 1: update_fetch_1 (hpos); break; + case 2: update_fetch_2 (hpos); break; +#endif + default: uae_abort ("fetchmode corrupt"); + } + } + last_fetch_hpos = hpos; +} + +static void start_bpl_dma (int hpos, int hstart) +{ + fetch_state = fetch_started; + fetch_cycle = 0; + last_fetch_hpos = hstart; + out_nbits = 0; + out_offs = 0; + toscr_nbits = 0; + toscr_res_first = GET_RES (bplcon0); + + ddfstate = DIW_waiting_stop; + compute_toscr_delay (last_fetch_hpos); + + /* If someone already wrote BPL1DAT, clear the area between that point and + the real fetch start. */ + if (framecnt == 0) { + if (thisline_decision.plfleft != -1) { + out_nbits = (plfstrt - thisline_decision.plfleft) << (1 + toscr_res); + out_offs = out_nbits >> 5; + out_nbits &= 31; + } + update_toscr_planes (); + } +} + +/* this may turn on datafetch if program turns dma on during the ddf */ +static void maybe_start_bpl_dma (int hpos) +{ + /* OCS: BPL DMA never restarts if DMA is turned on during DDF + * ECS/AGA: BPL DMA restarts but only if DMA was turned off + outside of DDF or during current line, otherwise display + processing jumps immediately to "DDFSTOP passed"-condition */ + if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS)) + return; + if (fetch_state != fetch_not_started) + return; + if (diwstate != DIW_waiting_stop) + return; + if (hpos <= plfstrt) + return; + if (hpos > plfstop) + return; + if (ddfstate != DIW_waiting_start) + passed_plfstop = 1; + start_bpl_dma (hpos, hpos); +} + +/* This function is responsible for turning on datafetch if necessary. */ +STATIC_INLINE void decide_line (int hpos) +{ + /* Take care of the vertical DIW. */ + if (vpos == plffirstline) + diwstate = DIW_waiting_stop; + if (vpos == plflastline) + diwstate = DIW_waiting_start; + + if (hpos <= last_decide_line_hpos) + return; + if (fetch_state != fetch_not_started) + return; + + if (dmaen (DMA_BITPLANE) && diwstate == DIW_waiting_stop) { + int ok = 0; + /* Test if we passed the start of the DDF window. */ + if (last_decide_line_hpos < plfstrt && hpos >= plfstrt) { + ok = 1; + /* hack warning.. Writing to DDFSTRT when DMA should start must be ignored + * (correct fix would be emulate this delay for every custom register, but why bother..) */ + if (ddfstrt_old != ddfstrt && hpos - 2 == ddfstrt_old_hpos && ddfstrt_old_vpos == vpos) + ok = 0; + if (ok) { + start_bpl_dma (hpos, plfstrt); + estimate_last_fetch_cycle (plfstrt); + last_decide_line_hpos = hpos; +#ifndef CUSTOM_SIMPLE + do_sprites (plfstrt); +#endif + return; + } + } + } + +#ifndef CUSTOM_SIMPLE + if (last_decide_line_hpos < SPR0_HPOS + 4 * MAX_SPRITES) + do_sprites (hpos); +#endif + last_decide_line_hpos = hpos; +} + +/* Called when a color is about to be changed (write to a color register), + * but the new color has not been entered into the table yet. */ +static void record_color_change (int hpos, int regno, unsigned long value) +{ + if (regno == -1 && value) { + thisline_decision.ham_seen = 1; + if (hpos < HARD_DDF_START) + thisline_decision.ham_at_start = 1; + } + + /* Early positions don't appear on-screen. */ + if (framecnt != 0 || vpos < minfirstline || hpos < HARD_DDF_START + /*|| currprefs.emul_accuracy == 0*/) + return; + + decide_diw (hpos); + decide_line (hpos); + + if (thisline_decision.ctable == -1) + remember_ctable (); + +#ifdef OS_WITHOUT_MEMORY_MANAGEMENT + if (next_color_change >= max_color_change) { + ++delta_color_change; + return; + } +#endif + curr_color_changes[next_color_change].linepos = hpos; + curr_color_changes[next_color_change].regno = regno; + curr_color_changes[next_color_change++].value = value; +} + +typedef int sprbuf_res_t, cclockres_t, hwres_t, bplres_t; + +static void do_playfield_collisions (void) +{ + uae_u8 *ld = line_data[next_lineno]; + int i; + + if (clxcon_bpl_enable == 0) { + clxdat |= 1; + return; + } + + for (i = thisline_decision.plfleft; i < thisline_decision.plfright; i += 2) { + int j; + uae_u32 total = 0xFFFFFFFF; + for (j = 0; j < 8; j++) { + uae_u32 t = 0; + if ((clxcon_bpl_enable & (1 << j)) == 0) + t = 0xFFFFFFFF; + else if (j < thisline_decision.nr_planes) { + t = *(uae_u32 *)(line_data[next_lineno] + 2 * i + 2 * j * MAX_WORDS_PER_LINE); + t ^= ~(((clxcon_bpl_match >> j) & 1) - 1); + } + total &= t; + } + if (total) + clxdat |= 1; + } +} + +/* Sprite-to-sprite collisions are taken care of in record_sprite. This one does + playfield/sprite collisions. + That's the theory. In practice this doesn't work yet. I also suspect this code + is way too slow. */ +static void do_sprite_collisions (void) +{ + int nr_sprites = curr_drawinfo[next_lineno].nr_sprites; + int first = curr_drawinfo[next_lineno].first_sprite_entry; + int i; + unsigned int collision_mask = clxmask[clxcon >> 12]; + int bplres = GET_RES (bplcon0); + hwres_t ddf_left = thisline_decision.plfleft * 2 << bplres; + hwres_t hw_diwlast = coord_window_to_diw_x (thisline_decision.diwlastword); + hwres_t hw_diwfirst = coord_window_to_diw_x (thisline_decision.diwfirstword); + + if (clxcon_bpl_enable == 0) { + clxdat |= 0x1FE; + return; + } + + for (i = 0; i < nr_sprites; i++) { + struct sprite_entry *e = curr_sprite_entries + first + i; + sprbuf_res_t j; + sprbuf_res_t minpos = e->pos; + sprbuf_res_t maxpos = e->max; + hwres_t minp1 = minpos >> sprite_buffer_res; + hwres_t maxp1 = maxpos >> sprite_buffer_res; + + if (maxp1 > hw_diwlast) + maxpos = hw_diwlast << sprite_buffer_res; + if (maxp1 > thisline_decision.plfright * 2) + maxpos = thisline_decision.plfright * 2 << sprite_buffer_res; + if (minp1 < hw_diwfirst) + minpos = hw_diwfirst << sprite_buffer_res; + if (minp1 < thisline_decision.plfleft * 2) + minpos = thisline_decision.plfleft * 2 << sprite_buffer_res; + + for (j = minpos; j < maxpos; j++) { + int sprpix = spixels[e->first_pixel + j - e->pos] & collision_mask; + int k, offs, match = 1; + + if (sprpix == 0) + continue; + + offs = ((j << bplres) >> sprite_buffer_res) - ddf_left; + sprpix = sprite_ab_merge[sprpix & 255] | (sprite_ab_merge[sprpix >> 8] << 2); + sprpix <<= 1; + + /* Loop over number of playfields. */ + for (k = 1; k >= 0; k--) { + int l; +#ifdef AGA + int planes = (currprefs.chipset_mask & CSMASK_AGA) ? 8 : 6; +#else + int planes = 6; +#endif + if (bplcon0 & 0x400) + match = 1; + for (l = k; match && l < planes; l += 2) { + int t = 0; + if (l < thisline_decision.nr_planes) { + uae_u32 *ldata = (uae_u32 *)(line_data[next_lineno] + 2 * l * MAX_WORDS_PER_LINE); + uae_u32 word = ldata[offs >> 5]; + t = (word >> (31 - (offs & 31))) & 1; +#if 0 /* debug: draw collision mask */ + if (1) { + int m; + for (m = 0; m < 5; m++) { + ldata = (uae_u32 *)(line_data[next_lineno] + 2 * m * MAX_WORDS_PER_LINE); + ldata[(offs >> 5) + 1] |= 15 << (31 - (offs & 31)); + } + } +#endif + } + if (clxcon_bpl_enable & (1 << l)) { + if (t != ((clxcon_bpl_match >> l) & 1)) + match = 0; + } + } + if (match) { +#if 0 /* debug: mark lines where collisions are detected */ + if (0) { + int l; + for (l = 0; l < 5; l++) { + uae_u32 *ldata = (uae_u32 *)(line_data[next_lineno] + 2 * l * MAX_WORDS_PER_LINE); + ldata[(offs >> 5) + 1] |= 15 << (31 - (offs & 31)); + } + } +#endif + clxdat |= sprpix << (k * 4); + } + } + } + } +#if 0 + { + static int olx; + if (clxdat != olx) + write_log ("%d: %04.4X\n", vpos, clxdat); + olx = clxdat; + } +#endif +} + +static void expand_sprres (void) +{ + switch ((bplcon3 >> 6) & 3) { + case 0: /* ECS defaults (LORES,HIRES=140ns,SHRES=70ns) */ + if ((currprefs.chipset_mask & CSMASK_ECS_DENISE) && GET_RES (bplcon0) == RES_SUPERHIRES) + sprres = RES_HIRES; + else + sprres = RES_LORES; + break; + case 1: + sprres = RES_LORES; + break; + case 2: + sprres = RES_HIRES; + break; + case 3: + sprres = RES_SUPERHIRES; + break; + } +} + +STATIC_INLINE void record_sprite_1 (uae_u16 *buf, uae_u32 datab, int num, int dbl, + unsigned int mask, int do_collisions, uae_u32 collision_mask) +{ + int j = 0; + while (datab) { + unsigned int tmp = *buf; + unsigned int col = (datab & 3) << (2 * num); + tmp |= col; + if ((j & mask) == 0) + *buf++ = tmp; + if (dbl) + *buf++ = tmp; + j++; + datab >>= 2; + if (do_collisions) { + tmp &= collision_mask; + if (tmp) { + unsigned int shrunk_tmp = sprite_ab_merge[tmp & 255] | (sprite_ab_merge[tmp >> 8] << 2); + clxdat |= sprclx[shrunk_tmp]; + } + } + } +} + +/* DATAB contains the sprite data; 16 pixels in two-bit packets. Bits 0/1 + determine the color of the leftmost pixel, bits 2/3 the color of the next + etc. + This function assumes that for all sprites in a given line, SPRXP either + stays equal or increases between successive calls. + + The data is recorded either in lores pixels (if ECS), or in hires pixels + (if AGA). No support for SHRES sprites. */ + +static void record_sprite (int line, int num, int sprxp, uae_u16 *data, uae_u16 *datb, unsigned int ctl) +{ + struct sprite_entry *e = curr_sprite_entries + next_sprite_entry; + int i; + int word_offs; + uae_u16 *buf; + uae_u32 collision_mask; + int width = sprite_width; + int dbl = 0, half = 0; + unsigned int mask = 0; + + if (sprres != RES_LORES) + thisline_decision.any_hires_sprites = 1; + +#ifdef AGA + if (currprefs.chipset_mask & CSMASK_AGA) { + width = (width << 1) >> sprres; + dbl = sprite_buffer_res - sprres; + if (dbl < 0) { + half = -dbl; + dbl = 0; + } + mask = sprres == RES_SUPERHIRES ? 1 : 0; + } +#endif + + /* Try to coalesce entries if they aren't too far apart. */ + if (! next_sprite_forced && e[-1].max + 16 >= sprxp) { + e--; + } else { + next_sprite_entry++; + e->pos = sprxp; + e->has_attached = 0; + } + + if (sprxp < e->pos) + uae_abort ("sprxp < e->pos"); + + e->max = sprxp + width; + e[1].first_pixel = e->first_pixel + ((e->max - e->pos + 3) & ~3); + next_sprite_forced = 0; + + collision_mask = clxmask[clxcon >> 12]; + word_offs = e->first_pixel + sprxp - e->pos; + + for (i = 0; i < sprite_width; i += 16) { + unsigned int da = *data; + unsigned int db = *datb; + uae_u32 datab = ((sprtaba[da & 0xFF] << 16) | sprtaba[da >> 8] + | (sprtabb[db & 0xFF] << 16) | sprtabb[db >> 8]); + + buf = spixels + word_offs + ((i << dbl) >> half); + if (currprefs.collision_level > 0 && collision_mask) + record_sprite_1 (buf, datab, num, dbl, mask, 1, collision_mask); + else + record_sprite_1 (buf, datab, num, dbl, mask, 0, collision_mask); + data++; + datb++; + } + + /* We have 8 bits per pixel in spixstate, two for every sprite pair. The + low order bit records whether the attach bit was set for this pair. */ + + if (ctl & 0x80) { + uae_u32 state = 0x01010101 << (num & ~1); + uae_u32 *stbuf = spixstate.words + (word_offs >> 2); + uae_u8 *stb1 = spixstate.bytes + word_offs; + for (i = 0; i < width; i += 8) { + stb1[0] |= state; + stb1[1] |= state; + stb1[2] |= state; + stb1[3] |= state; + stb1[4] |= state; + stb1[5] |= state; + stb1[6] |= state; + stb1[7] |= state; + stb1 += 8; + } + e->has_attached = 1; + } +} + +static void decide_sprites (int hpos) +{ + int nrs[MAX_SPRITES], posns[MAX_SPRITES]; + int count, i; + int point = hpos * 2; + int width = sprite_width; + int window_width = (width << lores_shift) >> sprres; + + if (framecnt != 0 || hpos < 0x14 || nr_armed == 0 || point == last_sprite_point) + return; +#ifdef DISABLE_SPRITES + return; +#endif + + decide_diw (hpos); + decide_line (hpos); + +#if 0 + /* This tries to detect whether the line is border, but that doesn't work, it's too early. */ + if (thisline_decision.plfleft == -1) + return; +#endif + count = 0; + for (i = 0; i < MAX_SPRITES; i++) { + int sprxp = spr[i].xpos; + int hw_xp = (sprxp >> sprite_buffer_res); + int window_xp = coord_hw_to_window_x (hw_xp) + (DIW_DDF_OFFSET << lores_shift); + int j, bestp; + + if (! spr[i].armed || sprxp < 0 || hw_xp <= last_sprite_point || hw_xp > point) + continue; + if ( !(bplcon3 & 2) && /* sprites outside playfields enabled? */ + ((thisline_decision.diwfirstword >= 0 && window_xp + window_width < thisline_decision.diwfirstword) + || (thisline_decision.diwlastword >= 0 && window_xp > thisline_decision.diwlastword))) + continue; + + /* Sort the sprites in order of ascending X position before recording them. */ + for (bestp = 0; bestp < count; bestp++) { + if (posns[bestp] > sprxp) + break; + if (posns[bestp] == sprxp && nrs[bestp] < i) + break; + } + for (j = count; j > bestp; j--) { + posns[j] = posns[j-1]; + nrs[j] = nrs[j-1]; + } + posns[j] = sprxp; + nrs[j] = i; + count++; + } + for (i = 0; i < count; i++) { + int nr = nrs[i]; + record_sprite (next_lineno, nr, spr[nr].xpos, sprdata[nr], sprdatb[nr], sprctl[nr]); + } + last_sprite_point = point; +} + +STATIC_INLINE int sprites_differ (struct draw_info *dip, struct draw_info *dip_old) +{ + struct sprite_entry *this_first = curr_sprite_entries + dip->first_sprite_entry; + struct sprite_entry *this_last = curr_sprite_entries + dip->last_sprite_entry; + struct sprite_entry *prev_first = prev_sprite_entries + dip_old->first_sprite_entry; + int npixels; + int i; + + if (dip->nr_sprites != dip_old->nr_sprites) + return 1; + + if (dip->nr_sprites == 0) + return 0; + + for (i = 0; i < dip->nr_sprites; i++) + if (this_first[i].pos != prev_first[i].pos + || this_first[i].max != prev_first[i].max + || this_first[i].has_attached != prev_first[i].has_attached) + return 1; + + npixels = this_last->first_pixel + (this_last->max - this_last->pos) - this_first->first_pixel; + if (memcmp (spixels + this_first->first_pixel, spixels + prev_first->first_pixel, + npixels * sizeof (uae_u16)) != 0) + return 1; + if (memcmp (spixstate.bytes + this_first->first_pixel, spixstate.bytes + prev_first->first_pixel, npixels) != 0) + return 1; + return 0; +} + +STATIC_INLINE int color_changes_differ (struct draw_info *dip, struct draw_info *dip_old) +{ + if (dip->nr_color_changes != dip_old->nr_color_changes) + return 1; + + if (dip->nr_color_changes == 0) + return 0; + if (memcmp (curr_color_changes + dip->first_color_change, + prev_color_changes + dip_old->first_color_change, + dip->nr_color_changes * sizeof *curr_color_changes) != 0) + return 1; + return 0; +} + +/* End of a horizontal scan line. Finish off all decisions that were not + * made yet. */ +static void finish_decisions (void) +{ + struct draw_info *dip; + struct draw_info *dip_old; + struct decision *dp; + int changed; + int hpos = current_hpos (); + + if (framecnt != 0) + return; + + decide_diw (hpos); + decide_line (hpos); + decide_fetch (hpos); + + if (thisline_decision.plfleft != -1 && thisline_decision.plflinelen == -1) { + if (fetch_state != fetch_not_started) { + write_log("fetch_state=%d plfleft=%d\n",fetch_state,thisline_decision.plfleft); + uae_abort ("fetch_state != fetch_not_started"); + } + thisline_decision.plfright = thisline_decision.plfleft; + thisline_decision.plflinelen = 0; + thisline_decision.bplres = RES_LORES; + } + + /* Large DIWSTOP values can cause the stop position never to be + * reached, so the state machine always stays in the same state and + * there's a more-or-less full-screen DIW. */ + if (hdiwstate == DIW_waiting_stop || thisline_decision.diwlastword > max_diwlastword) + thisline_decision.diwlastword = max_diwlastword; + + if (thisline_decision.diwfirstword != line_decisions[next_lineno].diwfirstword) + MARK_LINE_CHANGED; + if (thisline_decision.diwlastword != line_decisions[next_lineno].diwlastword) + MARK_LINE_CHANGED; + + dip = curr_drawinfo + next_lineno; + dip_old = prev_drawinfo + next_lineno; + dp = line_decisions + next_lineno; + changed = thisline_changed; + + if (thisline_decision.plfleft != -1) { + record_diw_line (thisline_decision.diwfirstword, thisline_decision.diwlastword); + + decide_sprites (hpos); + } + + dip->last_sprite_entry = next_sprite_entry; + dip->last_color_change = next_color_change; + + if (thisline_decision.ctable == -1) { + if (thisline_decision.plfleft == -1) + remember_ctable_for_border (); + else + remember_ctable (); + } + + dip->nr_color_changes = next_color_change - dip->first_color_change; + dip->nr_sprites = next_sprite_entry - dip->first_sprite_entry; + + if (thisline_decision.plfleft != line_decisions[next_lineno].plfleft) + changed = 1; + if (! changed && color_changes_differ (dip, dip_old)) + changed = 1; + if (!changed && thisline_decision.plfleft != -1 && sprites_differ (dip, dip_old)) + changed = 1; + + if (changed) { + thisline_changed = 1; + *dp = thisline_decision; + } else + /* The only one that may differ: */ + dp->ctable = thisline_decision.ctable; +} + +/* Set the state of all decisions to "undecided" for a new scanline. */ +static void reset_decisions (void) +{ + if (framecnt != 0) + return; + toscr_res_first = 0; + + thisline_decision.any_hires_sprites = 0; + thisline_decision.nr_planes = 0; + + thisline_decision.plfleft = -1; + thisline_decision.plflinelen = -1; + thisline_decision.ham_seen = !! (bplcon0 & 0x800); + thisline_decision.ham_at_start = !! (bplcon0 & 0x800); + + /* decided_res shouldn't be touched before it's initialized by decide_line(). */ + thisline_decision.diwfirstword = -1; + thisline_decision.diwlastword = -1; + if (hdiwstate == DIW_waiting_stop) { + thisline_decision.diwfirstword = 0; + if (thisline_decision.diwfirstword != line_decisions[next_lineno].diwfirstword) + MARK_LINE_CHANGED; + } + thisline_decision.ctable = -1; + + thisline_changed = 0; + curr_drawinfo[next_lineno].first_color_change = next_color_change; + curr_drawinfo[next_lineno].first_sprite_entry = next_sprite_entry; + next_sprite_forced = 1; + + /* memset(sprite_last_drawn_at, 0, sizeof sprite_last_drawn_at); */ + last_sprite_point = 0; + fetch_state = fetch_not_started; + passed_plfstop = 0; + + memset (todisplay, 0, sizeof todisplay); + memset (fetched, 0, sizeof fetched); +#ifdef AGA + memset (fetched_aga0, 0, sizeof fetched_aga0); + memset (fetched_aga1, 0, sizeof fetched_aga1); +#endif + memset (outword, 0, sizeof outword); + + last_decide_line_hpos = -1; + last_diw_pix_hpos = -1; + last_ddf_pix_hpos = -1; + last_sprite_hpos = -1; + last_fetch_hpos = -1; + +} + +int vsynctime_orig; +int turbo_emulation; + +void compute_vsynctime (void) +{ + fake_vblank_hz = 0; + if (currprefs.gfx_vsync && currprefs.gfx_afullscreen && currprefs.gfx_refreshrate) { + vblank_hz = currprefs.gfx_refreshrate; + vblank_skip = 1; +#if 0 + if (vblank_hz == 75) { + fake_vblank_hz = 50; + vblank_skip = 2; + } + if (vblank_hz == 90) { + fake_vblank_hz = 60; + vblank_skip = 2; + } +#endif + if (!fake_vblank_hz && vblank_hz > 85) { + vblank_hz /= 2; + vblank_skip = -1; + } + } + if (!fake_vblank_hz) + fake_vblank_hz = vblank_hz; + if (turbo_emulation) + vsynctime = vsynctime_orig = 1; + else + vsynctime = vsynctime_orig = syncbase / fake_vblank_hz; +#ifdef OPENGL + OGL_refresh (); +#endif +#ifdef D3D + D3D_refresh (); +#endif + if (currprefs.produce_sound > 1) + update_sound (fake_vblank_hz); +} + + +/* set PAL or NTSC timing variables */ +void init_hz (void) +{ + int isntsc; + + beamcon0 = new_beamcon0; + isntsc = beamcon0 & 0x20 ? 0 : 1; + if (hack_vpos > 0) { + if (maxvpos == hack_vpos) return; + maxvpos = hack_vpos; + vblank_hz = 15600 / hack_vpos; + hack_vpos = -1; + } else if (hack_vpos < 0) { + hack_vpos = 0; + } + if (hack_vpos == 0) { + if (!isntsc) { + maxvpos = MAXVPOS_PAL; + maxhpos = MAXHPOS_PAL; + minfirstline = VBLANK_ENDLINE_PAL; + vblank_hz = VBLANK_HZ_PAL; + sprite_vblank_endline = VBLANK_SPRITE_PAL; + } else { + maxvpos = MAXVPOS_NTSC; + maxhpos = MAXHPOS_NTSC; + minfirstline = VBLANK_ENDLINE_NTSC; + vblank_hz = VBLANK_HZ_NTSC; + sprite_vblank_endline = VBLANK_SPRITE_NTSC; + } + } + if (beamcon0 & 0x80) { + if (vtotal >= MAXVPOS) + vtotal = MAXVPOS - 1; + maxvpos = vtotal + 1; + if (htotal >= MAXHPOS) + htotal = MAXHPOS - 1; + maxhpos = htotal + 1; + vblank_hz = 227 * 312 * 50 / (maxvpos * maxhpos); + } + /* limit to sane values */ + if (vblank_hz < 10) + vblank_hz = 10; + if (vblank_hz > 300) + vblank_hz = 300; + eventtab[ev_hsync].oldcycles = get_cycles (); + eventtab[ev_hsync].evtime = get_cycles() + HSYNCTIME; + events_schedule (); + compute_vsynctime (); +#ifdef OPENGL + OGL_refresh (); +#endif +#ifdef PICASSO96 + init_hz_p96 (); +#endif + write_log ("%s mode, %dHz\n", isntsc ? "NTSC" : "PAL", vblank_hz); +} + +static void calcdiw (void) +{ + int hstrt = diwstrt & 0xFF; + int hstop = diwstop & 0xFF; + int vstrt = diwstrt >> 8; + int vstop = diwstop >> 8; + + if (diwhigh_written) { + hstrt |= ((diwhigh >> 5) & 1) << 8; + hstop |= ((diwhigh >> 13) & 1) << 8; + vstrt |= (diwhigh & 7) << 8; + vstop |= ((diwhigh >> 8) & 7) << 8; + } else { + hstop += 0x100; + if ((vstop & 0x80) == 0) + vstop |= 0x100; + } + + diwfirstword = coord_diw_to_window_x (hstrt); + diwlastword = coord_diw_to_window_x (hstop); + if (diwfirstword < 0) + diwfirstword = 0; + + plffirstline = vstrt; + plflastline = vstop; + +#if 0 + /* This happens far too often. */ + if (plffirstline < minfirstline_bpl) { + write_log ("Warning: Playfield begins before line %d (%d)!\n", minfirstline_bpl, plffirstline); + } +#endif + +#if 0 /* this comparison is not needed but previous is.. */ + if (plflastline > 313) { + /* Turrican does this */ + write_log ("Warning: Playfield out of range!\n"); + plflastline = 313; + } +#endif + + plfstrt = ddfstrt; + plfstop = ddfstop; + /* probably not the correct place.. */ + if ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) && ddfstop > maxhpos) + plfstrt = 0; + if (plfstrt < HARD_DDF_START) + plfstrt = HARD_DDF_START; +} + +static int timehack_alive = 0; + +static uae_u32 timehack_helper (void) +{ +#ifdef HAVE_GETTIMEOFDAY + struct timeval tv; + if (m68k_dreg (regs, 0) == 0) + return timehack_alive; + + timehack_alive = 10; + + gettimeofday (&tv, NULL); + put_long (m68k_areg (regs, 0), tv.tv_sec - (((365 * 8 + 2) * 24) * 60 * 60)); + put_long (m68k_areg (regs, 0) + 4, tv.tv_usec); + return 0; +#else + return 2; +#endif +} + + /* + * register functions + */ +STATIC_INLINE uae_u16 DENISEID (void) +{ +#ifdef AGA + if (currprefs.chipset_mask & CSMASK_AGA) + return 0xF8; +#endif + if (currprefs.chipset_mask & CSMASK_ECS_DENISE) + return 0xFC; + return 0xffff; +} +STATIC_INLINE uae_u16 DMACONR (void) +{ + uae_u16 v; + decide_blitter (current_hpos ()); + v = dmacon | (bltstate == BLT_done ? 0 : 0x4000) + | (blt_info.blitzero ? 0x2000 : 0); + return v; +} +STATIC_INLINE uae_u16 INTENAR (void) +{ + return intena; +} +uae_u16 INTREQR (void) +{ + return intreq; +} +STATIC_INLINE uae_u16 ADKCONR (void) +{ + return adkcon; +} +STATIC_INLINE uae_u16 VPOSR (void) +{ + unsigned int csbit = currprefs.ntscmode ? 0x1000 : 0; + int vp = (vpos >> 8) & 7; +#ifdef AGA + csbit |= (currprefs.chipset_mask & CSMASK_AGA) ? 0x2300 : 0; +#else + csbit |= (currprefs.chipset_mask & CSMASK_ECS_AGNUS) ? 0x2000 : 0; +#endif + if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS)) + vp &= 1; + vp = vp | lof | csbit; + return vp; +} +static void VPOSW (uae_u16 v) +{ +#if 0 + write_log ("vposw %x at %x\n", v, m68k_getpc()); +#endif + if (lof != (v & 0x8000)) + lof_changed = 1; + lof = v & 0x8000; + if ( (v & 1) && vpos > 0) + hack_vpos = vpos; +} + +STATIC_INLINE uae_u16 VHPOSR (void) +{ + uae_u16 v = (vpos << 8) | current_hpos (); + return v; +} + +STATIC_INLINE void COP1LCH (uae_u16 v) { cop1lc = (cop1lc & 0xffff) | ((uae_u32)v << 16); } +STATIC_INLINE void COP1LCL (uae_u16 v) { cop1lc = (cop1lc & ~0xffff) | (v & 0xfffe); } +STATIC_INLINE void COP2LCH (uae_u16 v) { cop2lc = (cop2lc & 0xffff) | ((uae_u32)v << 16); } +STATIC_INLINE void COP2LCL (uae_u16 v) { cop2lc = (cop2lc & ~0xffff) | (v & 0xfffe); } + +static void COPJMP (int num) +{ + int was_active = eventtab[ev_copper].active; + eventtab[ev_copper].active = 0; + if (was_active) + events_schedule (); + + cop_state.ignore_next = 0; + cop_state.state = COP_read1; + cop_state.vpos = vpos; + cop_state.hpos = current_hpos () & ~1; + cop_state.strobe = num; + copper_enabled_thisline = 0; + + if (dmaen (DMA_COPPER)) { + copper_enabled_thisline = 1; + set_special (SPCFLAG_COPPER); + } +} + +STATIC_INLINE void COPCON (uae_u16 a) +{ + copcon = a; +} + +static void compute_spcflag_copper (void); +static void DMACON (int hpos, uae_u16 v) +{ + int oldcop, newcop; + uae_u16 changed; + + uae_u16 oldcon = dmacon; + + decide_line (hpos); + decide_fetch (hpos); + decide_blitter (hpos); + + setclr (&dmacon, v); + dmacon &= 0x1FFF; + + changed = dmacon ^ oldcon; + + oldcop = (oldcon & DMA_COPPER) && (oldcon & DMA_MASTER); + newcop = (dmacon & DMA_COPPER) && (dmacon & DMA_MASTER); + + if (oldcop != newcop) { + eventtab[ev_copper].active = 0; + if (newcop && !oldcop) { + compute_spcflag_copper (); + } else if (!newcop) { + copper_enabled_thisline = 0; + unset_special (SPCFLAG_COPPER); + } + } + if ((dmacon & DMA_BLITPRI) > (oldcon & DMA_BLITPRI) && bltstate != BLT_done) { + static int count = 0; + if (!count) { + count = 1; + write_log ("warning: program is doing blitpri hacks.\n"); + } + set_special (SPCFLAG_BLTNASTY); + decide_blitter (hpos); + } + if (dmaen (DMA_BLITTER) && bltstate == BLT_init) + bltstate = BLT_work; + if ((dmacon & (DMA_BLITPRI | DMA_BLITTER | DMA_MASTER)) != (DMA_BLITPRI | DMA_BLITTER | DMA_MASTER)) { + unset_special (SPCFLAG_BLTNASTY); + decide_blitter (hpos); + } + if (changed & (DMA_MASTER | 0x0f)) + audio_hsync (0); + if (changed & (DMA_MASTER | DMA_BITPLANE)) { + ddf_change = vpos; + if (dmaen (DMA_BITPLANE)) + maybe_start_bpl_dma (hpos); + } + + events_schedule(); +} + + +static int intlev_2 (void) +{ + uae_u16 imask = intreq & intena; + unsigned long cycles = get_cycles (); + int c = currprefs.cpu_level >= 2 ? 20 : 4; + int i; + + if (!(imask && (intena & 0x4000))) { + unset_special (SPCFLAG_INT); + return -1; + } + for (i = 14; i >= 0; i--) { + if (imask & (1 << i)) { + if (!(irqdelay[i] && (cycles - irqcycles[i]) < c * CYCLE_UNIT)) { + irqdelay[i] = 0; + if (i == 13 || i == 14) + return 6; + else if (i == 11 || i == 12) + return 5; + else if (i >= 7 && i <= 10) + return 4; + else if (i >= 4 && i <= 6) + return 3; + else if (i == 3) + return 2; + else + return 1; + } + } + } + return -1; +} + +int intlev (void) +{ + int il = intlev_2 (); + if (il >= 0 && il <= regs.intmask) + unset_special (SPCFLAG_INT); + return il; +} + +static void doint (void) +{ + int i; + uae_u16 imask = intreq & intena; + + set_special (SPCFLAG_INT); + if (imask && (intena & 0x4000)) { + for (i = 0; i < 14; i++) { + if ((imask & (1 << i)) && irqdelay[i] == 0) { + irqdelay[i] = 1; + irqcycles[i] = get_cycles (); + } + } + } +} + +STATIC_INLINE void INTENA (uae_u16 v) +{ + setclr (&intena,v); +#if 0 + if (v & 0x100) + write_log("INTENA %04.4X (%04.4X) %p\n", intena, v, m68k_getpc()); +#endif + if (v & 0x8000) + doint (); +} + +void INTREQ_0 (uae_u16 v) +{ + setclr (&intreq,v); + doint (); +} + +void INTREQ (uae_u16 v) +{ + INTREQ_0 (v); + serial_check_irq (); + rethink_cias (); +#if 0 + if (v & 0x100) + write_log("INTREQ %04.4X (%04.4X) %p\n", intreq, v, m68k_getpc()); +#endif +} + +static void ADKCON (int hpos, uae_u16 v) +{ + if (currprefs.produce_sound > 0) + update_audio (); + + setclr (&adkcon,v); + update_adkmasks (); + DISK_update (hpos); + if ((v >> 11) & 1) + serial_uartbreak ((adkcon >> 11) & 1); +} + +static void dumpsync (void) +{ +#if 0 + write_log ("BEAMCON0 = %04.4X VTOTAL=%04.4X HTOTAL=%04.4X\n", new_beamcon0, vtotal, htotal); + write_log ("HSSTOP=%04.4X HBSTRT=%04.4X HBSTOP=%04.4X\n", hsstop, hbstrt, hbstop); + write_log ("VSSTOP=%04.4X VBSTRT=%04.4X VBSTOP=%04.4X\n", vsstop, vbstrt, vbstop); + write_log ("HSSTRT=%04.4X VSSTRT=%04.4X HCENTER=%04.4X\n", hsstrt, vsstrt, hcenter); +#endif +} + +static void BEAMCON0 (uae_u16 v) +{ + if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) { + if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE)) + v &= 0x20; + if (v != new_beamcon0) { + new_beamcon0 = v; + if (v & ~0x20) + write_log ("warning: %04.4X written to BEAMCON0\n", v); + } + } +} + +static void varsync (void) +{ +#ifdef PICASSO96 + if (p96refresh_active) + { + extern int p96hack_vpos2; + static int p96hack_vpos_old; + if (p96hack_vpos_old == p96hack_vpos2) return; + vtotal = p96hack_vpos2; + p96hack_vpos_old = p96hack_vpos2; + hack_vpos = -1; + return; + } +#endif + if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE)) + return; + if (!(beamcon0 & 0x80)) + return; + hack_vpos = -1; + dumpsync (); +} + + +static void BPLxPTH (int hpos, uae_u16 v, int num) +{ + decide_line (hpos); + decide_fetch (hpos); + bplpt[num] = (bplpt[num] & 0xffff) | ((uae_u32)v << 16); + //write_log("%d:%d:BPL%dPTH %08.8X\n", hpos, vpos, num, v); +} +static void BPLxPTL (int hpos, uae_u16 v, int num) +{ + decide_line (hpos); + decide_fetch (hpos); + bplpt[num] = (bplpt[num] & ~0xffff) | (v & 0xfffe); + //write_log("%d:%d:BPL%dPTL %08.8X\n", hpos, vpos, num, v); +} + +static void BPLCON0 (int hpos, uae_u16 v) +{ + if (! (currprefs.chipset_mask & CSMASK_ECS_DENISE)) + v &= ~0x00F1; + else if (! (currprefs.chipset_mask & CSMASK_AGA)) + v &= ~0x00B1; + + if (bplcon0 == v) + return; + + ddf_change = vpos; + decide_line (hpos); + decide_fetch (hpos); + decide_blitter (hpos); + + /* HAM change? */ + if ((bplcon0 ^ v) & 0x800) { + record_color_change (hpos, -1, !! (v & 0x800)); + } + bplcon0 = v; + +#ifdef AGA + if (currprefs.chipset_mask & CSMASK_AGA) { + decide_sprites (hpos); + expand_sprres (); + } +#endif + + expand_fmodes (); + calcdiw (); + estimate_last_fetch_cycle (hpos); +} + +STATIC_INLINE void BPLCON1 (int hpos, uae_u16 v) +{ + if (!(currprefs.chipset_mask & CSMASK_AGA)) + v &= 0xff; + if (bplcon1 == v) + return; + decide_line (hpos); + decide_fetch (hpos); + bplcon1 = v; +} + +STATIC_INLINE void BPLCON2 (int hpos, uae_u16 v) +{ + if (!(currprefs.chipset_mask & CSMASK_AGA)) + v &= 0x7f; + if (bplcon2 == v) + return; + decide_line (hpos); + bplcon2 = v; +} + +#ifdef AGA +STATIC_INLINE void BPLCON3 (int hpos, uae_u16 v) +{ + if (! (currprefs.chipset_mask & CSMASK_AGA)) + return; + if (bplcon3 == v) + return; + decide_line (hpos); + decide_sprites (hpos); + bplcon3 = v; + expand_sprres (); +} + +STATIC_INLINE void BPLCON4 (int hpos, uae_u16 v) +{ + if (! (currprefs.chipset_mask & CSMASK_AGA)) + return; + if (bplcon4 == v) + return; + decide_line (hpos); + bplcon4 = v; +} +#endif + +static void BPL1MOD (int hpos, uae_u16 v) +{ + v &= ~1; + if ((uae_s16)bpl1mod == (uae_s16)v) + return; + decide_line (hpos); + decide_fetch (hpos); + bpl1mod = v; +} + +static void BPL2MOD (int hpos, uae_u16 v) +{ + v &= ~1; + if ((uae_s16)bpl2mod == (uae_s16)v) + return; + decide_line (hpos); + decide_fetch (hpos); + bpl2mod = v; +} + +STATIC_INLINE void BPL1DAT (int hpos, uae_u16 v) +{ + decide_line (hpos); + bpl1dat = v; + + maybe_first_bpl1dat (hpos); +} +/* We could do as well without those... */ +STATIC_INLINE void BPL2DAT (uae_u16 v) { bpl2dat = v; } +STATIC_INLINE void BPL3DAT (uae_u16 v) { bpl3dat = v; } +STATIC_INLINE void BPL4DAT (uae_u16 v) { bpl4dat = v; } +STATIC_INLINE void BPL5DAT (uae_u16 v) { bpl5dat = v; } +STATIC_INLINE void BPL6DAT (uae_u16 v) { bpl6dat = v; } +STATIC_INLINE void BPL7DAT (uae_u16 v) { bpl7dat = v; } +STATIC_INLINE void BPL8DAT (uae_u16 v) { bpl8dat = v; } + +static void DIWSTRT (int hpos, uae_u16 v) +{ + if (diwstrt == v && ! diwhigh_written) + return; + decide_line (hpos); + diwhigh_written = 0; + diwstrt = v; + calcdiw (); +} + +static void DIWSTOP (int hpos, uae_u16 v) +{ + if (diwstop == v && ! diwhigh_written) + return; + decide_line (hpos); + diwhigh_written = 0; + diwstop = v; + calcdiw (); +} + +static void DIWHIGH (int hpos, uae_u16 v) +{ + if (! (currprefs.chipset_mask & CSMASK_ECS_AGNUS)) + return; + if (diwhigh_written && diwhigh == v) + return; + decide_line (hpos); + diwhigh_written = 1; + diwhigh = v; + calcdiw (); +} + +static void DDFSTRT (int hpos, uae_u16 v) +{ + v &= 0xfe; + if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS)) + v &= 0xfc; + if (ddfstrt == v) + return; + ddf_change = vpos; + decide_line (hpos); + ddfstrt_old = ddfstrt; + ddfstrt_old_hpos = hpos; + ddfstrt_old_vpos = vpos; + ddfstrt = v; + calcdiw (); + if (ddfstop > 0xD4 && (ddfstrt & 4) == 4) { + static int last_warned; + last_warned = (last_warned + 1) & 4095; + if (last_warned == 0) + write_log ("WARNING! Very strange DDF values.\n"); + } +} + +int test_cnt = 0x80; + +static void DDFSTOP (int hpos, uae_u16 v) +{ + v &= 0xfe; + if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS)) + v &= 0xfc; + if (ddfstop == v) + return; + decide_line (hpos); + decide_fetch (hpos); + decide_blitter (hpos); + ddfstop = v; + calcdiw (); + if (fetch_state != fetch_not_started) + estimate_last_fetch_cycle (hpos); + if (ddfstop > 0xD4 && (ddfstrt & 4) == 4) { + static int last_warned; + if (last_warned == 0) + write_log ("WARNING! Very strange DDF values (%x).\n", ddfstop); + last_warned = (last_warned + 1) & 4095; + } +} + +static void FMODE (uae_u16 v) +{ + if (! (currprefs.chipset_mask & CSMASK_AGA)) + v = 0; + ddf_change = vpos; + fmode = v; + sprite_width = GET_SPRITEWIDTH (fmode); + switch (fmode & 3) { + case 0: + fetchmode = 0; + break; + case 1: + case 2: + fetchmode = 1; + break; + case 3: + fetchmode = 2; + break; + } + expand_fmodes (); + calcdiw (); +} + +static void BLTADAT (uae_u16 v) +{ + maybe_blit (current_hpos(), 0); + + blt_info.bltadat = v; +} +/* + * "Loading data shifts it immediately" says the HRM. Well, that may + * be true for BLTBDAT, but not for BLTADAT - it appears the A data must be + * loaded for every word so that AFWM and ALWM can be applied. + */ +static void BLTBDAT (uae_u16 v) +{ + maybe_blit (current_hpos(), 0); + + if (bltcon1 & 2) + blt_info.bltbhold = v << (bltcon1 >> 12); + else + blt_info.bltbhold = v >> (bltcon1 >> 12); + blt_info.bltbdat = v; +} +static void BLTCDAT (uae_u16 v) { maybe_blit (current_hpos(), 0); blt_info.bltcdat = v; reset_blit (0); } + +static void BLTAMOD (uae_u16 v) { maybe_blit (current_hpos(), 1); blt_info.bltamod = (uae_s16)(v & 0xFFFE); reset_blit (0); } +static void BLTBMOD (uae_u16 v) { maybe_blit (current_hpos(), 1); blt_info.bltbmod = (uae_s16)(v & 0xFFFE); reset_blit (0); } +static void BLTCMOD (uae_u16 v) { maybe_blit (current_hpos(), 1); blt_info.bltcmod = (uae_s16)(v & 0xFFFE); reset_blit (0); } +static void BLTDMOD (uae_u16 v) { maybe_blit (current_hpos(), 1); blt_info.bltdmod = (uae_s16)(v & 0xFFFE); reset_blit (0); } + +static void BLTCON0 (uae_u16 v) { maybe_blit (current_hpos(), 2); bltcon0 = v; blinea_shift = v >> 12; reset_blit (1); } +/* The next category is "Most useless hardware register". + * And the winner is... */ +static void BLTCON0L (uae_u16 v) +{ + if (! (currprefs.chipset_mask & CSMASK_ECS_AGNUS)) + return; + maybe_blit (current_hpos(), 2); bltcon0 = (bltcon0 & 0xFF00) | (v & 0xFF); + reset_blit (1); +} +static void BLTCON1 (uae_u16 v) { maybe_blit (current_hpos(), 2); bltcon1 = v; reset_blit (2); } + +static void BLTAFWM (uae_u16 v) { maybe_blit (current_hpos(), 2); blt_info.bltafwm = v; reset_blit (0); } +static void BLTALWM (uae_u16 v) { maybe_blit (current_hpos(), 2); blt_info.bltalwm = v; reset_blit (0); } + +static void BLTAPTH (uae_u16 v) { maybe_blit (current_hpos(), 0); bltapt = (bltapt & 0xffff) | ((uae_u32)v << 16); } +static void BLTAPTL (uae_u16 v) { maybe_blit (current_hpos(), 0); bltapt = (bltapt & ~0xffff) | (v & 0xFFFE); } +static void BLTBPTH (uae_u16 v) { maybe_blit (current_hpos(), 0); bltbpt = (bltbpt & 0xffff) | ((uae_u32)v << 16); } +static void BLTBPTL (uae_u16 v) { maybe_blit (current_hpos(), 0); bltbpt = (bltbpt & ~0xffff) | (v & 0xFFFE); } +static void BLTCPTH (uae_u16 v) { maybe_blit (current_hpos(), 0); bltcpt = (bltcpt & 0xffff) | ((uae_u32)v << 16); } +static void BLTCPTL (uae_u16 v) { maybe_blit (current_hpos(), 0); bltcpt = (bltcpt & ~0xffff) | (v & 0xFFFE); } +static void BLTDPTH (uae_u16 v) { maybe_blit (current_hpos(), 0); bltdpt = (bltdpt & 0xffff) | ((uae_u32)v << 16); } +static void BLTDPTL (uae_u16 v) { maybe_blit (current_hpos(), 0); bltdpt = (bltdpt & ~0xffff) | (v & 0xFFFE); } + +static void BLTSIZE (uae_u16 v) +{ + maybe_blit (current_hpos(), 0); + + blt_info.vblitsize = v >> 6; + blt_info.hblitsize = v & 0x3F; + if (!blt_info.vblitsize) blt_info.vblitsize = 1024; + if (!blt_info.hblitsize) blt_info.hblitsize = 64; + do_blitter (current_hpos()); +} + +static void BLTSIZV (uae_u16 v) +{ + if (! (currprefs.chipset_mask & CSMASK_ECS_AGNUS)) + return; + maybe_blit (current_hpos(), 0); + blt_info.vblitsize = v & 0x7FFF; +} + +static void BLTSIZH (uae_u16 v) +{ + if (! (currprefs.chipset_mask & CSMASK_ECS_AGNUS)) + return; + maybe_blit (current_hpos(), 0); + blt_info.hblitsize = v & 0x7FF; + if (!blt_info.vblitsize) blt_info.vblitsize = 32768; + if (!blt_info.hblitsize) blt_info.hblitsize = 0x800; + do_blitter (current_hpos()); +} + +STATIC_INLINE void SPRxCTLPOS (int num) +{ + int sprxp; + struct sprite *s = &spr[num]; + + sprxp = (sprpos[num] & 0xFF) * 2 + (sprctl[num] & 1); + /* Quite a bit salad in this register... */ +#ifdef AGA + if (currprefs.chipset_mask & CSMASK_AGA) { + /* We ignore the SHRES 35ns increment for now; SHRES support doesn't + work anyway, so we may as well restrict AGA sprites to a 70ns + resolution. */ + sprxp <<= 1; + sprxp |= (sprctl[num] >> 4) & 1; + } +#endif + s->xpos = sprxp; + s->vstart = (sprpos[num] >> 8) | ((sprctl[num] << 6) & 0x100); + s->vstop = (sprctl[num] >> 8) | ((sprctl[num] << 7) & 0x100); + if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) { + s->vstart |= (sprctl[num] << 3) & 0x200; + s->vstop |= (sprctl[num] << 4) & 0x200; + } + if (vpos == s->vstart) + s->dmastate = 1; + if (vpos == s->vstop) + s->dmastate = 0; +} + +STATIC_INLINE void SPRxCTL_1 (uae_u16 v, int num, int hpos) +{ + struct sprite *s = &spr[num]; + sprctl[num] = v; + nr_armed -= s->armed; + s->armed = 0; + SPRxCTLPOS (num); +#if SPRITE_DEBUG > 0 + if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) { + write_log ("%d:%d:SPR%dCTL %04.4X VSTRT=%d VSTOP=%d HSTRT=%d DMA=%d ARM=%d COP=%x PC=%x\n", + vpos, hpos, num, v, s->vstart, s->vstop, s->xpos, spr[num].dmastate, spr[num].armed, cop_state.ip, m68k_getpc()); + } +#endif + +} +STATIC_INLINE void SPRxPOS_1 (uae_u16 v, int num, int hpos) +{ + struct sprite *s = &spr[num]; + sprpos[num] = v; + SPRxCTLPOS (num); +#if SPRITE_DEBUG > 0 + if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) { + write_log ("%d:%d:SPR%dPOS %04.4X VSTRT=%d VSTOP=%d HSTRT=%d DMA=%d ARM=%d COP=%x PC=%x\n", + vpos, hpos, num, v, s->vstart, s->vstop, s->xpos, spr[num].dmastate, spr[num].armed, cop_state.ip, m68k_getpc()); + } +#endif +} +STATIC_INLINE void SPRxDATA_1 (uae_u16 v, int num, int hpos) +{ + sprdata[num][0] = v; +#ifdef AGA + sprdata[num][1] = v; + sprdata[num][2] = v; + sprdata[num][3] = v; +#endif + nr_armed += 1 - spr[num].armed; + spr[num].armed = 1; +#if SPRITE_DEBUG > 1 + if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) { + write_log ("%d:%d:SPR%dDATA %04.4X DMA=%d ARM=%d PC=%x\n", + vpos, hpos, num, v, spr[num].dmastate, spr[num].armed, m68k_getpc()); + } +#endif +} +STATIC_INLINE void SPRxDATB_1 (uae_u16 v, int num, int hpos) +{ + sprdatb[num][0] = v; +#ifdef AGA + sprdatb[num][1] = v; + sprdatb[num][2] = v; + sprdatb[num][3] = v; +#endif +#if SPRITE_DEBUG > 1 + if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) { + write_log ("%d:%d:SPR%dDATB %04.4X DMA=%d ARM=%d PC=%x\n", + vpos, hpos, num, v, spr[num].dmastate, spr[num].armed, m68k_getpc()); + } +#endif +} +static void SPRxDATA (int hpos, uae_u16 v, int num) { decide_sprites (hpos); SPRxDATA_1 (v, num, hpos); } +static void SPRxDATB (int hpos, uae_u16 v, int num) { decide_sprites (hpos); SPRxDATB_1 (v, num, hpos); } +static void SPRxCTL (int hpos, uae_u16 v, int num) { decide_sprites (hpos); SPRxCTL_1 (v, num, hpos); } +static void SPRxPOS (int hpos, uae_u16 v, int num) { decide_sprites (hpos); SPRxPOS_1 (v, num, hpos); } +static void SPRxPTH (int hpos, uae_u16 v, int num) +{ + decide_sprites (hpos); + spr[num].pt &= 0xffff; + spr[num].pt |= (uae_u32)v << 16; +#if SPRITE_DEBUG > 0 + if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) { + write_log ("%d:%d:SPR%dPTH %08.8X\n", vpos, hpos, num, spr[num].pt); + } +#endif +} +static void SPRxPTL (int hpos, uae_u16 v, int num) +{ + decide_sprites (hpos); + spr[num].pt &= ~0xffff; + spr[num].pt |= v; +#if SPRITE_DEBUG > 0 + if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) { + write_log ("%d:%d:SPR%dPTL %08.8X\n", vpos, hpos, num, spr[num].pt); + } +#endif +} + +static void CLXCON (uae_u16 v) +{ + clxcon = v; + clxcon_bpl_enable = (v >> 6) & 63; + clxcon_bpl_match = v & 63; + //write_log("CLXCON: %04.4X PC=%x\n", v, m68k_getpc()); +} + +static void CLXCON2 (uae_u16 v) +{ + if (!(currprefs.chipset_mask & CSMASK_AGA)) + return; + clxcon2 = v; + clxcon_bpl_enable |= v & (0x40|0x80); + clxcon_bpl_match |= (v & (0x01|0x02)) << 6; + //write_log("CLXCON2: %04.4X\n", v); +} + +static uae_u16 CLXDAT (void) +{ + uae_u16 v = clxdat | 0x8000; + //write_log("%d:CLXDAT %04.4X PC=%x\n", vpos, v, m68k_getpc()); + clxdat = 0; + return v; +} + +#ifdef AGA +static uae_u16 COLOR_READ (int num) +{ + int cr, cg, cb, colreg; + uae_u16 cval; + + if (!(currprefs.chipset_mask & CSMASK_AGA) || !(bplcon2 & 0x0100)) + return 0xffff; + + colreg = ((bplcon3 >> 13) & 7) * 32 + num; + cr = current_colors.color_regs_aga[colreg] >> 16; + cg = (current_colors.color_regs_aga[colreg] >> 8) & 0xFF; + cb = current_colors.color_regs_aga[colreg] & 0xFF; + if (bplcon3 & 0x200) + cval = ((cr & 15) << 8) | ((cg & 15) << 4) | ((cb & 15) << 0); + else + cval = ((cr >> 4) << 8) | ((cg >> 4) << 4) | ((cb >> 4) << 0); + return cval; +} +#endif + +static void COLOR_WRITE (int hpos, uae_u16 v, int num) +{ + v &= 0xFFF; +#ifdef AGA + if (currprefs.chipset_mask & CSMASK_AGA) { + int r,g,b; + int cr,cg,cb; + int colreg; + uae_u32 cval; + + /* writing is disabled when RDRAM=1 */ + if (bplcon2 & 0x0100) + return; + + colreg = ((bplcon3 >> 13) & 7) * 32 + num; + r = (v & 0xF00) >> 8; + g = (v & 0xF0) >> 4; + b = (v & 0xF) >> 0; + cr = current_colors.color_regs_aga[colreg] >> 16; + cg = (current_colors.color_regs_aga[colreg] >> 8) & 0xFF; + cb = current_colors.color_regs_aga[colreg] & 0xFF; + + if (bplcon3 & 0x200) { + cr &= 0xF0; cr |= r; + cg &= 0xF0; cg |= g; + cb &= 0xF0; cb |= b; + } else { + cr = r + (r << 4); + cg = g + (g << 4); + cb = b + (b << 4); + } + cval = (cr << 16) | (cg << 8) | cb; + if (cval == current_colors.color_regs_aga[colreg]) + return; + + /* Call this with the old table still intact. */ + record_color_change (hpos, colreg, cval); + remembered_color_entry = -1; + current_colors.color_regs_aga[colreg] = cval; + current_colors.acolors[colreg] = CONVERT_RGB (cval); + } else { +#endif + if (current_colors.color_regs_ecs[num] == v) + return; + /* Call this with the old table still intact. */ + record_color_change (hpos, num, v); + remembered_color_entry = -1; + current_colors.color_regs_ecs[num] = v; + current_colors.acolors[num] = xcolors[v]; +#ifdef AGA + } +#endif +} + +/* The copper code. The biggest nightmare in the whole emulator. + + Alright. The current theory: + 1. Copper moves happen 2 cycles after state READ2 is reached. + It can't happen immediately when we reach READ2, because the + data needs time to get back from the bus. An additional 2 + cycles are needed for non-Agnus registers, to take into account + the delay for moving data from chip to chip. + 2. As stated in the HRM, a WAIT really does need an extra cycle + to wake up. This is implemented by _not_ falling through from + a successful wait to READ1, but by starting the next cycle. + (Note: the extra cycle for the WAIT apparently really needs a + free cycle; i.e. contention with the bitplane fetch can slow + it down). + 3. Apparently, to compensate for the extra wake up cycle, a WAIT + will use the _incremented_ horizontal position, so the WAIT + cycle normally finishes two clocks earlier than the position + it was waiting for. The extra cycle then takes us to the + position that was waited for. + If the earlier cycle is busy with a bitplane, things change a bit. + E.g., waiting for position 0x50 in a 6 plane display: In cycle + 0x4e, we fetch BPL5, so the wait wakes up in 0x50, the extra cycle + takes us to 0x54 (since 0x52 is busy), then we have READ1/READ2, + and the next register write is at 0x5c. + 4. The last cycle in a line is not usable for the copper. + 5. A 4 cycle delay also applies to the WAIT instruction. This means + that the second of two back-to-back WAITs (or a WAIT whose + condition is immediately true) takes 8 cycles. + 6. This also applies to a SKIP instruction. The copper does not + fetch the next instruction while waiting for the second word of + a WAIT or a SKIP to arrive. + 7. A SKIP also seems to need an unexplained additional two cycles + after its second word arrives; this is _not_ a memory cycle (I + think, the documentation is pretty clear on this). + 8. Two additional cycles are inserted when writing to COPJMP1/2. */ + +/* Determine which cycles are available for the copper in a display + * with a agiven number of planes. */ + +int is_bitplane_dma (int hpos) +{ + if (fetch_state == fetch_not_started || hpos < thisline_decision.plfleft) + return 0; + if ((passed_plfstop == 3 && hpos >= thisline_decision.plfright) + || hpos >= estimated_last_fetch_cycle) + return 0; + return curr_diagram[(hpos - cycle_diagram_shift) & fetchstart_mask]; +} + +STATIC_INLINE int is_bitplane_dma_inline (int hpos) +{ + if (fetch_state == fetch_not_started || hpos < thisline_decision.plfleft) + return 0; + if ((passed_plfstop == 3 && hpos >= thisline_decision.plfright) + || hpos >= estimated_last_fetch_cycle) + return 0; + return curr_diagram[(hpos - cycle_diagram_shift) & fetchstart_mask]; +} + +STATIC_INLINE int copper_cant_read (int hpos) +{ + if (hpos + 1 >= maxhpos) + return 1; + return is_bitplane_dma_inline (hpos); +} + +STATIC_INLINE int dangerous_reg (int reg) +{ + /* Safe: + * Bitplane pointers, control registers, modulos and data. + * Sprite pointers, control registers, and data. + * Color registers. */ + if (reg >= 0xE0 && reg < 0x1C0) + return 0; + return 1; +} + +#define FAST_COPPER 1 + +/* The future, Conan? + We try to look ahead in the copper list to avoid doing continuous calls + to updat_copper (which is what happens when SPCFLAG_COPPER is set). If + we find that the same effect can be achieved by setting a delayed event + and then doing multiple copper insns in one batch, we can get a massive + speedup. + + We don't try to be precise here. All copper reads take exactly 2 cycles, + the effect of bitplane contention is ignored. Trying to get it exactly + right would be much more complex and as such carry a huge risk of getting + it subtly wrong; and it would also be more expensive - we want this code + to be fast. */ +static void predict_copper (void) +{ + uaecptr ip = cop_state.ip; + unsigned int c_hpos = cop_state.hpos; + enum copper_states state = cop_state.state; + unsigned int w1, w2, cycle_count; + + switch (state) { + case COP_read1_wr_in2: + case COP_read2_wr_in2: + case COP_read1_wr_in4: + if (dangerous_reg (cop_state.saved_i1)) + return; + state = state == COP_read2_wr_in2 ? COP_read2 : COP_read1; + break; + + case COP_read1_in2: + c_hpos += 2; + state = COP_read1; + break; + + case COP_stop: + case COP_bltwait: + case COP_wait1: + case COP_skip_in4: + case COP_skip_in2: + case COP_skip1: + case COP_strobe_delay: + return; + + case COP_wait_in4: + c_hpos += 2; + /* fallthrough */ + case COP_wait_in2: + c_hpos += 2; + /* fallthrough */ + case COP_wait: + state = COP_wait; + break; + + default: + break; + } + + /* Only needed for COP_wait, but let's shut up the compiler. */ + w1 = cop_state.saved_i1; + w2 = cop_state.saved_i2; + cop_state.first_sync = c_hpos; + cop_state.regtypes_modified = REGTYPE_FORCE; + + /* Get this case out of the way, so that the loop below only has to deal + with read1 and wait. */ + if (state == COP_read2) { + w1 = cop_state.i1; + if (w1 & 1) { + w2 = chipmem_wget (ip); + if (w2 & 1) + goto done; + state = COP_wait; + c_hpos += 4; + } else if (dangerous_reg (w1)) { + c_hpos += 4; + goto done; + } else { + cop_state.regtypes_modified |= regtypes[w1 & 0x1FE]; + state = COP_read1; + c_hpos += 2; + } + ip += 2; + } + + while (c_hpos + 1 < maxhpos) { + if (state == COP_read1) { + w1 = chipmem_wget (ip); + if (w1 & 1) { + w2 = chipmem_wget (ip + 2); + if (w2 & 1) + break; + state = COP_wait; + c_hpos += 6; + } else if (dangerous_reg (w1)) { + c_hpos += 6; + break; + } else { + cop_state.regtypes_modified |= regtypes[w1 & 0x1FE]; + c_hpos += 4; + } + ip += 4; + } else if (state == COP_wait) { + if ((w2 & 0xFE) != 0xFE) + break; + else { + unsigned int vcmp = (w1 & (w2 | 0x8000)) >> 8; + unsigned int hcmp = (w1 & 0xFE); + + unsigned int vp = vpos & (((w2 >> 8) & 0x7F) | 0x80); + if (vp < vcmp) { + /* Whee. We can wait until the end of the line! */ + c_hpos = maxhpos; + } else if (vp > vcmp || hcmp <= c_hpos) { + state = COP_read1; + /* minimum wakeup time */ + c_hpos += 2; + } else { + state = COP_read1; + c_hpos = hcmp; + } + /* If this is the current instruction, remember that we don't + need to sync CPU and copper anytime soon. */ + if (cop_state.ip == ip) { + cop_state.first_sync = c_hpos; + } + } + } else + uae_abort ("predict copper %d", state); + } + + done: + cycle_count = c_hpos - cop_state.hpos; + if (cycle_count >= 8) { + unset_special (SPCFLAG_COPPER); + eventtab[ev_copper].active = 1; + eventtab[ev_copper].oldcycles = get_cycles (); + eventtab[ev_copper].evtime = get_cycles () + cycle_count * CYCLE_UNIT; + events_schedule (); + } +} + +static int test_copper_dangerous (unsigned int address) +{ + if ((address & 0x1fe) < (copcon & 2 ? ((currprefs.chipset_mask & CSMASK_AGA) ? 0 : 0x40u) : 0x80u)) { + cop_state.state = COP_stop; + copper_enabled_thisline = 0; + unset_special (SPCFLAG_COPPER); + return 1; + } + return 0; +} + +static void perform_copper_write (int old_hpos) +{ + unsigned int address = cop_state.saved_i1 & 0x1FE; + + record_copper (cop_state.saved_ip - 4, old_hpos, vpos); + + if (test_copper_dangerous (address)) + return; + if (address == 0x88) { + cop_state.ip = cop1lc; + cop_state.state = COP_strobe_delay; + } else if (address == 0x8A) { + cop_state.ip = cop2lc; + cop_state.state = COP_strobe_delay; + } else + custom_wput_1 (old_hpos, cop_state.saved_i1, cop_state.saved_i2, 0); +} + +static int isagnus[]= { + 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* 32 0x00 - 0x3e */ + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 27 0x40 - 0x74 */ + 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0, /* 21 */ + 1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0, /* 32 0xa0 - 0xde + /* BPLxPTH/BPLxPTL */ + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 16 */ + 0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0, /* 16 */ + /* SPRxPTH/SPRxPTL */ + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 16 */ + /* SPRxPOS/SPRxCTL/SPRxDATA/SPRxDATB */ + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + /* COLORxx */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + /* RESERVED */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +}; + +static void dump_copper (char *error, int until_hpos) +{ + write_log("%s: vpos=%d until_hpos=%d\n", + error, vpos, until_hpos); + write_log("cvcmp=%d chcmp=%d chpos=%d cvpos=%d ci1=%04.4X ci2=%04.4X\n", + cop_state.vcmp,cop_state.hcmp,cop_state.hpos,cop_state.vpos,cop_state.saved_i1,cop_state.saved_i2); + write_log("cstate=%d ip=%08.8X ev_copper=%d\n", + cop_state.state,cop_state.ip,eventtab[ev_copper].active); +} + +static void update_copper (int until_hpos) +{ + int vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80); + int c_hpos = cop_state.hpos; + + if (eventtab[ev_copper].active) { + static int warned; + if (!warned) { + dump_copper ("error1",until_hpos); + warned = 1; + } + eventtab[ev_copper].active = 0; + return; + uae_abort ("update_copper1"); + } + + if (cop_state.state == COP_wait && vp < cop_state.vcmp) { + static int warned; + if (!warned) { + dump_copper ("error2",until_hpos); + warned = 1; + } + copper_enabled_thisline = 0; + return; + uae_abort ("update_copper2"); + } + + until_hpos &= ~1; + + if (until_hpos > (maxhpos & ~1)) + until_hpos = maxhpos & ~1; + + until_hpos += 2; + for (;;) { + int old_hpos = c_hpos; + int hp; + + if (c_hpos >= until_hpos) + break; + + /* So we know about the fetch state. */ + decide_line (c_hpos); + + switch (cop_state.state) { + case COP_read1_in2: + cop_state.state = COP_read1; + break; + case COP_read1_wr_in2: + cop_state.state = COP_read1; + perform_copper_write (old_hpos); + /* That could have turned off the copper. */ + if (! copper_enabled_thisline) + goto out; + + break; + case COP_read1_wr_in4: + cop_state.state = COP_read1_wr_in2; + break; + case COP_read2_wr_in2: + cop_state.state = COP_read2; + perform_copper_write (old_hpos); + /* That could have turned off the copper. */ + if (! copper_enabled_thisline) + goto out; + + break; + case COP_wait_in2: + cop_state.state = COP_wait1; + break; + case COP_wait_in4: + cop_state.state = COP_wait_in2; + break; + case COP_skip_in2: + cop_state.state = COP_skip1; + break; + case COP_skip_in4: + cop_state.state = COP_skip_in2; + break; + case COP_strobe_delay: + cop_state.state = COP_read1; + break; + + default: + break; + } + + c_hpos += 2; +#if 0 + if (copper_cant_read (old_hpos)) + continue; +#endif + if (cop_state.strobe) { + cop_state.ip = cop_state.strobe == 1 ? cop1lc : cop2lc; + cop_state.strobe = 0; + } + + switch (cop_state.state) { + + case COP_read1_wr_in4: + uae_abort ("COP_read1_wr_in4"); + + case COP_read1_wr_in2: + case COP_read1: + if (copper_cant_read (old_hpos)) + continue; + cop_state.i1 = chipmem_wget (cop_state.ip); +#ifdef CPUEMU_6 + cycle_line[old_hpos] |= CYCLE_COPPER; +#endif + cop_state.ip += 2; + cop_state.state = cop_state.state == COP_read1 ? COP_read2 : COP_read2_wr_in2; + break; + + case COP_read2_wr_in2: + uae_abort ("read2_wr_in2"); + + case COP_read2: + if (copper_cant_read (old_hpos)) + continue; + cop_state.i2 = chipmem_wget (cop_state.ip); +#ifdef CPUEMU_6 + cycle_line[old_hpos] |= CYCLE_COPPER; +#endif + cop_state.ip += 2; + if (cop_state.ignore_next) { + cop_state.ignore_next = 0; + cop_state.state = COP_read1; + break; + } + + cop_state.saved_i1 = cop_state.i1; + cop_state.saved_i2 = cop_state.i2; + cop_state.saved_ip = cop_state.ip; + + if (cop_state.i1 & 1) { + if (cop_state.i2 & 1) + cop_state.state = COP_skip_in4; + else + cop_state.state = COP_wait_in4; + } else { + unsigned int reg = cop_state.i1 & 0x1FE; + cop_state.state = isagnus[reg >> 1] ? COP_read1_wr_in2 : COP_read1_wr_in4; + } + break; + + case COP_wait1: + /* There's a nasty case here. As stated in the "Theory" comment above, we + test against the incremented copper position. I believe this means that + we have to increment the _vertical_ position at the last cycle in the line, + and set the horizontal position to 0. + Normally, this isn't going to make a difference, since we consider these + last cycles unavailable for the copper, so waking up in the last cycle has + the same effect as waking up at the start of the line. However, there is + one possible problem: If we're at 0xFFE0, any wait for an earlier position + must _not_ complete (since, in effect, the current position will be back + at 0/0). This can be seen in the Superfrog copper list. + Things get monstrously complicated if we try to handle this "properly" by + incrementing vpos and setting c_hpos to 0. Especially the various speedup + hacks really assume that vpos remains constant during one line. Hence, + this hack: defer the entire decision until the next line if necessary. */ + if (c_hpos >= (maxhpos & ~1)) + break; + + cop_state.state = COP_wait; + + cop_state.vcmp = (cop_state.saved_i1 & (cop_state.saved_i2 | 0x8000)) >> 8; + cop_state.hcmp = (cop_state.saved_i1 & cop_state.saved_i2 & 0xFE); + + vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80); + + if (cop_state.saved_i1 == 0xFFFF && cop_state.saved_i2 == 0xFFFE) { + cop_state.state = COP_stop; + copper_enabled_thisline = 0; + unset_special (SPCFLAG_COPPER); + goto out; + } + if (vp < cop_state.vcmp) { + copper_enabled_thisline = 0; + unset_special (SPCFLAG_COPPER); + goto out; + } + + /* fall through */ + case COP_wait: + if (vp < cop_state.vcmp) + uae_abort ("vp < cop_state.vcmp"); + if (copper_cant_read (old_hpos)) + continue; + + hp = c_hpos & (cop_state.saved_i2 & 0xFE); + if (vp == cop_state.vcmp && hp < cop_state.hcmp) { + /* Position not reached yet. */ + if (currprefs.fast_copper && FAST_COPPER && (cop_state.saved_i2 & 0xFE) == 0xFE) { + int wait_finish = cop_state.hcmp - 2; + /* This will leave c_hpos untouched if it's equal to wait_finish. */ + if (wait_finish < c_hpos) + uae_abort ("wait_finish < c_hpos"); + else if (wait_finish <= until_hpos) { + c_hpos = wait_finish; + } else + c_hpos = until_hpos; + } + break; + } + + /* Now we know that the comparisons were successful. We might still + have to wait for the blitter though. */ + if ((cop_state.saved_i2 & 0x8000) == 0 && (DMACONR() & 0x4000)) { + /* We need to wait for the blitter. */ + cop_state.state = COP_bltwait; + copper_enabled_thisline = 0; + unset_special (SPCFLAG_COPPER); + goto out; + } + + record_copper (cop_state.ip - 4, old_hpos, vpos); + + cop_state.state = COP_read1; + break; + + case COP_skip1: + { + static int skipped_before; + unsigned int vcmp, hcmp, vp1, hp1; + + if (! skipped_before) { + skipped_before = 1; + write_log ("Program uses Copper SKIP instruction.\n"); + } + + if (c_hpos >= (maxhpos & ~1)) + break; + + vcmp = (cop_state.saved_i1 & (cop_state.saved_i2 | 0x8000)) >> 8; + hcmp = (cop_state.saved_i1 & cop_state.saved_i2 & 0xFE); + vp1 = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80); + hp1 = c_hpos & (cop_state.saved_i2 & 0xFE); + + if ((vp1 > vcmp || (vp1 == vcmp && hp1 >= hcmp)) + && ((cop_state.saved_i2 & 0x8000) != 0 || ! (DMACONR() & 0x4000))) + cop_state.ignore_next = 1; + if (chipmem_wget (cop_state.ip) & 1) { /* FIXME: HACK!!! */ + /* copper never skips if following instruction is WAIT or another SKIP... */ + cop_state.ignore_next = 0; + } + + cop_state.state = COP_read1; + + if (cop_state.ignore_next && (chipmem_wget (cop_state.ip) & 1) == 0) { + /* another undocumented copper feature: + copper stops if skipped instruction is MOVE to dangerous register... + */ + test_copper_dangerous (chipmem_wget(cop_state.ip)); + } + + record_copper (cop_state.ip - 4, old_hpos, vpos); + + break; + } + default: + break; + } + } + + out: + cop_state.hpos = c_hpos; + + /* The test against maxhpos also prevents us from calling predict_copper + when we are being called from hsync_handler, which would not only be + stupid, but actively harmful. */ + if (currprefs.fast_copper && FAST_COPPER && (regs.spcflags & SPCFLAG_COPPER) && c_hpos + 8 < maxhpos) + predict_copper (); +} + +static void compute_spcflag_copper (void) +{ + copper_enabled_thisline = 0; + unset_special (SPCFLAG_COPPER); + if (! dmaen (DMA_COPPER) || cop_state.state == COP_stop || cop_state.state == COP_bltwait) + return; + + if (cop_state.state == COP_wait) { + int vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80); + + if (vp < cop_state.vcmp) + return; + } + copper_enabled_thisline = 1; + + if (currprefs.fast_copper && FAST_COPPER) + predict_copper (); + + if (! eventtab[ev_copper].active) + set_special (SPCFLAG_COPPER); +} + +static void copper_handler (void) +{ + /* This will take effect immediately, within the same cycle. */ + set_special (SPCFLAG_COPPER); + + if (! copper_enabled_thisline) + uae_abort ("copper_handler"); + + eventtab[ev_copper].active = 0; +} + +void blitter_done_notify (void) +{ + if (cop_state.state != COP_bltwait) + return; + + cop_state.hpos = current_hpos () & ~1; + cop_state.vpos = vpos; + cop_state.state = COP_wait; + compute_spcflag_copper (); +} + +void do_copper (void) +{ + int hpos = current_hpos (); + update_copper (hpos); +} + +/* ADDR is the address that is going to be read/written; this access is + the reason why we want to update the copper. This function is also + used from hsync_handler to finish up the line; for this case, we check + hpos against maxhpos. */ +STATIC_INLINE void sync_copper_with_cpu (int hpos, int do_schedule, unsigned int addr) +{ + /* Need to let the copper advance to the current position. */ + if (eventtab[ev_copper].active) { + if (hpos != maxhpos) { + /* There might be reasons why we don't actually need to bother + updating the copper. */ + if (hpos < cop_state.first_sync) + return; + + if ((cop_state.regtypes_modified & regtypes[addr & 0x1FE]) == 0) + return; + } + + eventtab[ev_copper].active = 0; + if (do_schedule) + events_schedule (); + set_special (SPCFLAG_COPPER); + } + if (copper_enabled_thisline) + update_copper (hpos); +} + +STATIC_INLINE uae_u16 sprite_fetch (struct sprite *s, int dma, int hpos) +{ + uae_u16 data = last_custom_value; + if (dma) { + data = last_custom_value = chipmem_wget (s->pt); +#ifdef CPUEMU_6 + cycle_line[hpos] |= CYCLE_SPRITE; +#endif + } + s->pt += 2; + return data; +} + +STATIC_INLINE void do_sprites_1 (int num, int cycle, int hpos) +{ + struct sprite *s = &spr[num]; + int dma, posctl = 0; + uae_u16 data; + + if (vpos == s->vstart) { + s->dmastate = 1; +#if SPRITE_DEBUG > 0 + write_log ("%d:SPR%d START\n", vpos, num); +#endif + } + if (vpos == s->vstop || vpos == sprite_vblank_endline) { + s->dmastate = 0; +#if SPRITE_DEBUG > 0 + write_log ("%d:SPR%d STOP\n", vpos, num); +#endif + } + if (!dmaen (DMA_SPRITE)) + return; + dma = hpos < plfstrt || diwstate != DIW_waiting_stop || !dmaen (DMA_BITPLANE); + if (vpos == s->vstop || vpos == sprite_vblank_endline) { + s->dmastate = 0; + posctl = 1; + if (dma) { + data = sprite_fetch (s, dma, hpos); + s->pt += (sprite_width >> 3) - 2; + } else { + data = cycle == 0 ? sprpos[num] : sprctl[num]; + } +#if SPRITE_DEBUG > 1 + if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) { + write_log ("dma:"); + } +#endif + if (cycle == 0) + SPRxPOS_1 (data, num, hpos); + else + SPRxCTL_1 (data, num, hpos); + } + if (s->dmastate && !posctl) { + uae_u16 data = sprite_fetch (s, dma, hpos); + /* Hack for X mouse auto-calibration */ + if (num == 0 && cycle == 0) + mousehack_handle (sprctl[0], sprpos[0]); +#if SPRITE_DEBUG > 1 + if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) { + write_log ("dma:"); + } +#endif + if (cycle == 0) + SPRxDATA_1 (dma ? data : sprdata[num][0], num, hpos); + else + SPRxDATB_1 (dma ? data : sprdatb[num][0], num, hpos); +#ifdef AGA + switch (sprite_width) + { + case 64: + { + uae_u16 data32 = sprite_fetch (s, dma, hpos); + uae_u16 data641 = sprite_fetch (s, dma, hpos); + uae_u16 data642 = sprite_fetch (s, dma, hpos); + if (dma) { + if (cycle == 0) { + sprdata[num][3] = data642; + sprdata[num][2] = data641; + sprdata[num][1] = data32; + } else { + sprdatb[num][3] = data642; + sprdatb[num][2] = data641; + sprdatb[num][1] = data32; + } + } + } + break; + case 32: + { + uae_u16 data32 = sprite_fetch (s, dma, hpos); + if (dma) { + if (cycle == 0) + sprdata[num][1] = data32; + else + sprdatb[num][1] = data32; + } + } + break; + } +#endif + } +} + +static void do_sprites (int hpos) +{ + int maxspr, minspr; + int i; + + /* I don't know whether this is right. Some programs write the sprite pointers + * directly at the start of the copper list. With the test against currvp, the + * first two words of data are read on the second line in the frame. The problem + * occurs when the program jumps to another copperlist a few lines further down + * which _also_ writes the sprite pointer registers. This means that a) writing + * to the sprite pointers sets the state to SPR_restart; or b) that sprite DMA + * is disabled until the end of the vertical blanking interval. The HRM + * isn't clear - it says that the vertical sprite position can be set to any + * value, but this wouldn't be the first mistake... */ + /* Update: I modified one of the programs to write the sprite pointers the + * second time only _after_ the VBlank interval, and it showed the same behaviour + * as it did unmodified under UAE with the above check. This indicates that the + * solution below is correct. */ + /* Another update: seems like we have to use the NTSC value here (see Sanity Turmoil + * demo). */ + /* Maximum for Sanity Turmoil: 27. + Minimum for Sanity Arte: 22. */ + if (vpos < sprite_vblank_endline) + return; + +#ifndef CUSTOM_SIMPLE + maxspr = hpos; + minspr = last_sprite_hpos; + + if (minspr >= SPR0_HPOS + MAX_SPRITES * 4 || maxspr < SPR0_HPOS) + return; + + if (maxspr > SPR0_HPOS + MAX_SPRITES * 4) + maxspr = SPR0_HPOS + MAX_SPRITES * 4; + if (minspr < SPR0_HPOS) + minspr = SPR0_HPOS; + + for (i = minspr; i < maxspr; i++) { + int cycle = -1; + switch ((i - SPR0_HPOS) & 3) + { + case 0: + cycle = 0; + break; + case 2: + cycle = 1; + break; + } + if (cycle >= 0) + do_sprites_1 ((i - SPR0_HPOS) / 4, cycle, i); + } + last_sprite_hpos = hpos; +#else + for (i = 0; i < MAX_SPRITES * 2; i++) + do_sprites_1 (i / 2, i & 1, 0); +#endif +} + +static void init_sprites (void) +{ + memset (sprpos, 0, sizeof sprpos); + memset (sprctl, 0, sizeof sprctl); +} + +static void adjust_array_sizes (void) +{ +#ifdef OS_WITHOUT_MEMORY_MANAGEMENT + if (delta_sprite_entry) { + void *p1,*p2; + int mcc = max_sprite_entry + 50 + delta_sprite_entry; + delta_sprite_entry = 0; + p1 = realloc (sprite_entries[0], mcc * sizeof (struct sprite_entry)); + p2 = realloc (sprite_entries[1], mcc * sizeof (struct sprite_entry)); + if (p1) sprite_entries[0] = p1; + if (p2) sprite_entries[1] = p2; + if (p1 && p2) { + write_log ("new max_sprite_entry=%d\n",mcc); + max_sprite_entry = mcc; + } + } + if (delta_color_change) { + void *p1,*p2; + int mcc = max_color_change + 200 + delta_color_change; + delta_color_change = 0; + p1 = realloc (color_changes[0], mcc * sizeof (struct color_change)); + p2 = realloc (color_changes[1], mcc * sizeof (struct color_change)); + if (p1) color_changes[0] = p1; + if (p2) color_changes[1] = p2; + if (p1 && p2) { + write_log ("new max_color_change=%d\n",mcc); + max_color_change = mcc; + } + } +#endif +} + +static void init_hardware_frame (void) +{ + next_lineno = 0; + nextline_how = nln_normal; + diwstate = DIW_waiting_start; + hdiwstate = DIW_waiting_start; + ddfstate = DIW_waiting_start; +} + +void init_hardware_for_drawing_frame (void) +{ + adjust_array_sizes (); + + /* Avoid this code in the first frame after a customreset. */ + if (prev_sprite_entries) { + int first_pixel = prev_sprite_entries[0].first_pixel; + int npixels = prev_sprite_entries[prev_next_sprite_entry].first_pixel - first_pixel; + memset (spixels + first_pixel, 0, npixels * sizeof *spixels); + memset (spixstate.bytes + first_pixel, 0, npixels * sizeof *spixstate.bytes); + } + prev_next_sprite_entry = next_sprite_entry; + + next_color_change = 0; + next_sprite_entry = 0; + next_color_entry = 0; + remembered_color_entry = -1; + + prev_sprite_entries = sprite_entries[current_change_set]; + curr_sprite_entries = sprite_entries[current_change_set ^ 1]; + prev_color_changes = color_changes[current_change_set]; + curr_color_changes = color_changes[current_change_set ^ 1]; + prev_color_tables = color_tables[current_change_set]; + curr_color_tables = color_tables[current_change_set ^ 1]; + + prev_drawinfo = line_drawinfo[current_change_set]; + curr_drawinfo = line_drawinfo[current_change_set ^ 1]; + current_change_set ^= 1; + + color_src_match = color_dest_match = -1; + + /* Use both halves of the array in alternating fashion. */ + curr_sprite_entries[0].first_pixel = current_change_set * MAX_SPR_PIXELS; + next_sprite_forced = 1; +} + +static void do_savestate(void); + +static int rpt_vsync (void) +{ + int v = read_processor_time () - vsyncmintime; + if (v > (int)syncbase || v < -((int)syncbase)) { + vsyncmintime = read_processor_time(); + v = 0; + } + return v; +} + +static void framewait (void) +{ + frame_time_t curr_time; + int start; + + for (;;) { + double v = rpt_vsync () / (syncbase / 1000.0); + if (v >= -4) + break; + sleep_millis_busy (1); + } + start = read_processor_time(); + do { + curr_time = read_processor_time (); + } while (rpt_vsync () < 0); + vsyncmintime = curr_time + vsynctime; + idletime += read_processor_time() - start; +} + +static int frametime2; + +void fpscounter_reset (void) +{ + timeframes = 0; + frametime2 = 0; + bogusframe = 2; + lastframetime = read_processor_time (); + idletime = 0; +} + +static void fpscounter (void) +{ + int now, last; + + now = read_processor_time (); + last = now - lastframetime; + lastframetime = now; + + if (bogusframe) + return; + + frametime += last; + frametime2 += last; + timeframes++; + if ((timeframes & 31) == 0) { + double idle = 1000 - (idletime == 0 ? 0.0 : (double)idletime * 1000.0 / (vsynctime * 32.0)); + int fps = frametime2 == 0 ? 0 : syncbase * 32 / (frametime2 / 10); + if (fps > 9999) + fps = 9999; + if (idle < 0) + idle = 0; + if (idle > 100 * 10) + idle = 100 * 10; + if (fake_vblank_hz * 10 > fps) { + double mult = (double)fake_vblank_hz * 10.0 / fps; + idle *= mult; + } + if (turbo_emulation && idle < 100 * 10) + idle = 100 * 10; + gui_fps (fps, (int)idle); + frametime2 = 0; + idletime = 0; + } +} + +static void vsync_handler (void) +{ + fpscounter (); + + if ((!currprefs.gfx_vsync || !currprefs.gfx_afullscreen) +#ifdef AVIOUTPUT + && ((avioutput_framelimiter && avioutput_enabled) || !avioutput_enabled) +#endif + ) { +#ifdef JIT + if (!compiled_code) { +#endif + if (currprefs.m68k_speed == -1) { + frame_time_t curr_time = read_processor_time (); + vsyncmintime += vsynctime; + /* @@@ Mathias? How do you think we should do this? */ + /* If we are too far behind, or we just did a reset, adjust the + * needed time. */ + if ((long int)(curr_time - vsyncmintime) > 0 || rpt_did_reset) + vsyncmintime = curr_time + vsynctime; + rpt_did_reset = 0; + } else if (rpt_available) { + framewait (); + } +#ifdef JIT + } else { + if (rpt_available && currprefs.m68k_speed == 0) { + framewait (); + } + } +#endif + } + + if (bogusframe > 0) + bogusframe--; + + handle_events (); + + INTREQ (0x8020); + if (bplcon0 & 4) + lof ^= 0x8000; + +#ifdef PICASSO96 + /* And now let's update the Picasso palette, if required */ + DX_SetPalette_vsync(); + if (picasso_on) + picasso_handle_vsync (); +#endif + + vsync_handle_redraw (lof, lof_changed); + + if (quit_program > 0) { + /* prevent possible infinite loop at wait_cycles().. */ + framecnt = 0; + reset_decisions (); + return; + } + + { + static int cnt = 0; + if (cnt == 0) { + /* resolution_check_change (); */ + DISK_check_change (); + cnt = 5; + } + cnt--; + } + + /* Start a new set of copper records. */ + curr_cop_set ^= 1; + nr_cop_records[curr_cop_set] = 0; + + /* For now, let's only allow this to change at vsync time. It gets too + * hairy otherwise. */ + if ((beamcon0 & (0x20|0x80)) != (new_beamcon0 & (0x20|0x80)) || hack_vpos) + init_hz (); + + lof_changed = 0; + + eventtab[ev_copper].active = 0; + COPJMP (1); + + init_hardware_frame (); + + if (ievent_alive > 0) + ievent_alive--; + if (timehack_alive > 0) + timehack_alive--; + inputdevice_vsync (); + +} + +#ifdef JIT + +#define N_LINES 8 + +static __inline__ int trigger_frh(int v) +{ + return (v & (N_LINES - 1)) == 0; +} + +extern int gonebad; + +static long int diff32(frame_time_t x, frame_time_t y) +{ + return (long int)(x-y); +} +static void frh_handler(void) +{ + if (currprefs.m68k_speed == -1) { + frame_time_t curr_time = read_processor_time (); + vsyncmintime += vsynctime * N_LINES / maxvpos; + /* @@@ Mathias? How do you think we should do this? */ + /* If we are too far behind, or we just did a reset, adjust the + * needed time. */ + if (rpt_did_reset) { + vsyncmintime = curr_time + vsynctime; + rpt_did_reset = 0; + } + /* Allow this to be one frame's worth of cycles out */ + while (diff32 (curr_time, vsyncmintime + vsynctime) > 0) { + vsyncmintime += vsynctime * N_LINES / maxvpos; + gonebad++; + if (turbo_emulation) + break; + } + } +} +#endif + +static void copper_check (int n) +{ + if (cop_state.state == COP_wait) { + int vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80); + if (vp < cop_state.vcmp) { + if (eventtab[ev_copper].active || copper_enabled_thisline) + write_log ("COPPER BUG %d: vp=%d vpos=%d vcmp=%d act=%d thisline=%d\n", n, vp, vpos, cop_state.vcmp, eventtab[ev_copper].active, copper_enabled_thisline); + } + } +} + +static void hsync_handler (void) +{ + static int ciahsync; + int hpos = current_hpos (); + + /* Using 0x8A makes sure that we don't accidentally trip over the + modified_regtypes check. */ + sync_copper_with_cpu (maxhpos, 0, 0x8A); + + //copper_check (1); + + finish_decisions (); + if (thisline_decision.plfleft != -1) { + if (currprefs.collision_level > 1) + do_sprite_collisions (); + if (currprefs.collision_level > 2) + do_playfield_collisions (); + } + hsync_record_line_state (next_lineno, nextline_how, thisline_changed); + + eventtab[ev_hsync].evtime += get_cycles () - eventtab[ev_hsync].oldcycles; + eventtab[ev_hsync].oldcycles = get_cycles (); + CIA_hsync_handler (); +#ifdef CD32 + AKIKO_hsync_handler (); +#endif + +#ifdef PICASSO96 + picasso_handle_hsync (); +#endif + ciahsync++; + if (ciahsync >= (currprefs.ntscmode ? MAXVPOS_NTSC : MAXVPOS_PAL) * MAXHPOS_PAL / maxhpos) { /* not so perfect.. */ + CIA_vsync_handler (); + ciahsync = 0; + } + +#ifdef CPUEMU_6 + if (currprefs.cpu_cycle_exact || currprefs.blitter_cycle_exact) { + decide_blitter (hpos); + memset (cycle_line, 0, MAXHPOS); + cycle_line[maxhpos - 1] = CYCLE_REFRESH; + cycle_line[0] = CYCLE_REFRESH; + cycle_line[2] = CYCLE_REFRESH; + cycle_line[4] = CYCLE_REFRESH; + } +#endif + if ((currprefs.chipset_mask & CSMASK_AGA) || (!currprefs.chipset_mask & CSMASK_ECS_AGNUS)) + last_custom_value = rand (); + else + last_custom_value = 0xffff; + + if (!currprefs.blitter_cycle_exact && bltstate != BLT_done && dmaen (DMA_BITPLANE) && diwstate == DIW_waiting_stop) + blitter_slowdown (ddfstrt, ddfstop, cycle_diagram_total_cycles[fmode][GET_RES (bplcon0)][GET_PLANES (bplcon0)], + cycle_diagram_free_cycles[fmode][GET_RES (bplcon0)][GET_PLANES (bplcon0)]); + + if (currprefs.produce_sound) + audio_hsync (1); + + hardware_line_completed (next_lineno); + + /* In theory only an equality test is needed here - but if a program + goes haywire with the VPOSW register, it can cause us to miss this, + with vpos going into the thousands (and all the nasty consequences + this has). */ + + if (++vpos >= (maxvpos + (lof == 0 ? 0 : 1))) { + vpos = 0; + vsync_handler (); + } + + DISK_update (maxhpos); + +#ifdef JIT + if (compiled_code) { + if (currprefs.m68k_speed == -1) { + static int count=0; + + count++; + if (trigger_frh(count)) { + frh_handler(); + } + is_lastline = trigger_frh(count+1) && ! rpt_did_reset; + } + else + is_lastline=0; + } else { +#endif + is_lastline = vpos + 1 == maxvpos + (lof == 0 ? 0 : 1) && currprefs.m68k_speed == -1 && ! rpt_did_reset; +#ifdef JIT + } +#endif + + if ((bplcon0 & 4) && currprefs.gfx_linedbl) + notice_interlace_seen (); + + if (framecnt == 0) { + int lineno = vpos; + nextline_how = nln_normal; + if (currprefs.gfx_linedbl) { + lineno *= 2; + nextline_how = currprefs.gfx_linedbl == 1 ? nln_doubled : nln_nblack; + if (bplcon0 & 4) { + if (!lof) { + lineno++; + nextline_how = nln_lower; + } else { + nextline_how = nln_upper; + } + } + } + next_lineno = lineno; + reset_decisions (); + } +#ifdef FILESYS + if (uae_int_requested) { + set_uae_int_flag (); + INTREQ (0x8000 | 0x0008); + } +#endif + /* See if there's a chance of a copper wait ending this line. */ + cop_state.hpos = 0; + compute_spcflag_copper (); + inputdevice_hsync (); + serial_hsynchandler (); +#ifdef CUSTOM_SIMPLE + do_sprites (0); +#endif + //copper_check (2); +} + +static void init_regtypes (void) +{ + int i; + for (i = 0; i < 512; i += 2) { + regtypes[i] = REGTYPE_ALL; + if ((i >= 0x20 && i < 0x28) || i == 0x08 || i == 0x7E) + regtypes[i] = REGTYPE_DISK; + else if (i >= 0x68 && i < 0x70) + regtypes[i] = REGTYPE_NONE; + else if (i >= 0x40 && i < 0x78) + regtypes[i] = REGTYPE_BLITTER; + else if (i >= 0xA0 && i < 0xE0 && (i & 0xF) < 0xE) + regtypes[i] = REGTYPE_AUDIO; + else if (i >= 0xA0 && i < 0xE0) + regtypes[i] = REGTYPE_NONE; + else if (i >= 0xE0 && i < 0x100) + regtypes[i] = REGTYPE_PLANE; + else if (i >= 0x120 && i < 0x180) + regtypes[i] = REGTYPE_SPRITE; + else if (i >= 0x180 && i < 0x1C0) + regtypes[i] = REGTYPE_COLOR; + else switch (i) { + case 0x02: + /* DMACONR - setting this to REGTYPE_BLITTER will cause it to + conflict with DMACON (since that is REGTYPE_ALL), and the + blitter registers (for the BBUSY bit), but nothing else, + which is (I think) what we want. */ + regtypes[i] = REGTYPE_BLITTER; + break; + case 0x04: case 0x06: case 0x2A: case 0x2C: + regtypes[i] = REGTYPE_POS; + break; + case 0x0A: case 0x0C: + case 0x12: case 0x14: case 0x16: + case 0x36: + regtypes[i] = REGTYPE_JOYPORT; + break; + case 0x104: + case 0x102: + regtypes[i] = REGTYPE_PLANE; + break; + case 0x88: case 0x8A: + case 0x8E: case 0x90: case 0x92: case 0x94: + case 0x96: + case 0x100: + regtypes[i] |= REGTYPE_FORCE; + break; + } + } +} + +void init_eventtab (void) +{ + int i; + + nextevent = 0; + set_cycles (0); + for (i = 0; i < ev_max; i++) { + eventtab[i].active = 0; + eventtab[i].oldcycles = 0; + } + + eventtab[ev_cia].handler = CIA_handler; + eventtab[ev_hsync].handler = hsync_handler; + eventtab[ev_hsync].evtime = get_cycles () + HSYNCTIME; + eventtab[ev_hsync].active = 1; + + eventtab[ev_copper].handler = copper_handler; + eventtab[ev_copper].active = 0; + eventtab[ev_blitter].handler = blitter_handler; + eventtab[ev_blitter].active = 0; + eventtab[ev_disk].handler = DISK_handler; + eventtab[ev_disk].active = 0; + eventtab[ev_audio].handler = audio_evhandler; + eventtab[ev_audio].active = 0; + events_schedule (); +} + +void customreset (void) +{ + int i; + int zero = 0; + + write_log ("reset at %x\n", m68k_getpc()); + if (! savestate_state) { + currprefs.chipset_mask = changed_prefs.chipset_mask; + if ((currprefs.chipset_mask & CSMASK_AGA) == 0) { + for (i = 0; i < 32; i++) { + current_colors.color_regs_ecs[i] = 0; + current_colors.acolors[i] = xcolors[0]; + } +#ifdef AGA + } else { + for (i = 0; i < 256; i++) { + current_colors.color_regs_aga[i] = 0; + current_colors.acolors[i] = CONVERT_RGB (zero); + } +#endif + } + + clxdat = 0; + + /* Clear the armed flags of all sprites. */ + memset (spr, 0, sizeof spr); + nr_armed = 0; + + dmacon = intena = 0; + + copcon = 0; + DSKLEN (0, 0); + + bplcon0 = 0; + bplcon4 = 0x11; /* Get AGA chipset into ECS compatibility mode */ + bplcon3 = 0xC00; + + FMODE (0); + CLXCON (0); + } + +#ifdef AUTOCONFIG + expamem_reset (); +#endif + a1000_reset (); + DISK_reset (); + CIA_reset (); +#ifdef JIT + compemu_reset (); +#endif + unset_special (~(SPCFLAG_BRK | SPCFLAG_MODE_CHANGE)); + + vpos = 0; + + if (needmousehack ()) { +#if 0 + mousehack_set (mousehack_follow); +#else + mousehack_set (mousehack_dontcare); +#endif + } else { + mousehack_set (mousehack_normal); + } + ievent_alive = 0; + timehack_alive = 0; + + curr_sprite_entries = 0; + prev_sprite_entries = 0; + sprite_entries[0][0].first_pixel = 0; + sprite_entries[1][0].first_pixel = MAX_SPR_PIXELS; + sprite_entries[0][1].first_pixel = 0; + sprite_entries[1][1].first_pixel = MAX_SPR_PIXELS; + memset (spixels, 0, sizeof spixels); + memset (&spixstate, 0, sizeof spixstate); + + bltstate = BLT_done; + cop_state.state = COP_stop; + diwstate = DIW_waiting_start; + hdiwstate = DIW_waiting_start; + set_cycles (0); + + new_beamcon0 = currprefs.ntscmode ? 0x00 : 0x20; + hack_vpos = 0; + init_hz (); + + audio_reset (); + if (savestate_state != STATE_RESTORE) { + /* must be called after audio_reset */ + adkcon = 0; + serial_uartbreak (0); + update_adkmasks (); + } + + init_sprites (); + + init_hardware_frame (); + drawing_init (); + + reset_decisions (); + + bogusframe = 1; + + init_regtypes (); + + sprite_buffer_res = currprefs.chipset_mask & CSMASK_AGA ? RES_HIRES : RES_LORES; + if (savestate_state == STATE_RESTORE) { + uae_u16 v; + uae_u32 vv; + + update_adkmasks (); + INTENA (0); + INTREQ (0); +#if 0 + DMACON (0, 0); +#endif + COPJMP (1); + v = bplcon0; + BPLCON0 (0, 0); + BPLCON0 (0, v); + FMODE (fmode); + if (!(currprefs.chipset_mask & CSMASK_AGA)) { + for(i = 0 ; i < 32 ; i++) { + vv = current_colors.color_regs_ecs[i]; + current_colors.color_regs_ecs[i] = -1; + record_color_change (0, i, vv); + remembered_color_entry = -1; + current_colors.color_regs_ecs[i] = vv; + current_colors.acolors[i] = xcolors[vv]; + } +#ifdef AGA + } else { + for(i = 0 ; i < 256 ; i++) { + vv = current_colors.color_regs_aga[i]; + current_colors.color_regs_aga[i] = -1; + record_color_change (0, i, vv); + remembered_color_entry = -1; + current_colors.color_regs_aga[i] = vv; + current_colors.acolors[i] = CONVERT_RGB(vv); + } +#endif + } + CLXCON (clxcon); + CLXCON2 (clxcon2); + calcdiw (); + write_log ("State restored\n"); + dumpcustom (); + for (i = 0; i < 8; i++) + nr_armed += spr[i].armed != 0; + } + expand_sprres (); + + #ifdef ACTION_REPLAY + /* Doing this here ensures we can use the 'reset' command from within AR */ + action_replay_reset (); + #endif + #ifdef WIN32 + #ifndef UAE_MINI + enforcer_disable(); + #endif + #endif +} + +void dumpcustom (void) +{ + write_log ("DMACON: %x INTENA: %x INTREQ: %x VPOS: %x HPOS: %x\n", DMACONR(), + (unsigned int)intena, (unsigned int)intreq, (unsigned int)vpos, (unsigned int)current_hpos()); + write_log ("COP1LC: %08lx, COP2LC: %08lx COPPTR: %08lx\n", (unsigned long)cop1lc, (unsigned long)cop2lc, cop_state.ip); + write_log ("DIWSTRT: %04x DIWSTOP: %04x DDFSTRT: %04x DDFSTOP: %04x\n", + (unsigned int)diwstrt, (unsigned int)diwstop, (unsigned int)ddfstrt, (unsigned int)ddfstop); + write_log ("BPLCON 0: %04x 1: %04x 2: %04x 3: %04x 4: %04x\n", bplcon0, bplcon1, bplcon2, bplcon3, bplcon4); + if (timeframes) { + write_log ("Average frame time: %f ms [frames: %d time: %d]\n", + (double)frametime / timeframes, timeframes, frametime); + if (total_skipped) + write_log ("Skipped frames: %d\n", total_skipped); + } + /*for (i=0; i<256; i++) if (blitcount[i]) write_log ("minterm %x = %d\n",i,blitcount[i]); blitter debug */ +} + +static void gen_custom_tables (void) +{ + int i; + for (i = 0; i < 256; i++) { + sprtaba[i] = ((((i >> 7) & 1) << 0) + | (((i >> 6) & 1) << 2) + | (((i >> 5) & 1) << 4) + | (((i >> 4) & 1) << 6) + | (((i >> 3) & 1) << 8) + | (((i >> 2) & 1) << 10) + | (((i >> 1) & 1) << 12) + | (((i >> 0) & 1) << 14)); + sprtabb[i] = sprtaba[i] * 2; + sprite_ab_merge[i] = (((i & 15) ? 1 : 0) + | ((i & 240) ? 2 : 0)); + } + for (i = 0; i < 16; i++) { + clxmask[i] = (((i & 1) ? 0xF : 0x3) + | ((i & 2) ? 0xF0 : 0x30) + | ((i & 4) ? 0xF00 : 0x300) + | ((i & 8) ? 0xF000 : 0x3000)); + sprclx[i] = (((i & 0x3) == 0x3 ? 1 : 0) + | ((i & 0x5) == 0x5 ? 2 : 0) + | ((i & 0x9) == 0x9 ? 4 : 0) + | ((i & 0x6) == 0x6 ? 8 : 0) + | ((i & 0xA) == 0xA ? 16 : 0) + | ((i & 0xC) == 0xC ? 32 : 0)) << 9; + } +} + +void custom_init (void) +{ + +#ifdef OS_WITHOUT_MEMORY_MANAGEMENT + int num; + + for (num = 0; num < 2; num++) { + sprite_entries[num] = xmalloc (max_sprite_entry * sizeof (struct sprite_entry)); + color_changes[num] = xmalloc (max_color_change * sizeof (struct color_change)); + } +#endif + +#ifdef AUTOCONFIG + { + uaecptr pos; + pos = here (); + + org (RTAREA_BASE+0xFF70); + calltrap (deftrap (mousehack_helper)); + dw (RTS); + + org (RTAREA_BASE+0xFFA0); + calltrap (deftrap (timehack_helper)); + dw (RTS); + + org (pos); + } +#endif + + gen_custom_tables (); + build_blitfilltable (); + + drawing_init (); + + mousehack_set (mousehack_unknown); + if (needmousehack ()) + mousehack_set (mousehack_follow); + + create_cycle_diagram_table (); +} + +/* Custom chip memory bank */ + +static uae_u32 custom_lget (uaecptr) REGPARAM; +static uae_u32 custom_wget (uaecptr) REGPARAM; +static uae_u32 custom_bget (uaecptr) REGPARAM; +static void custom_lput (uaecptr, uae_u32) REGPARAM; +static void custom_wput (uaecptr, uae_u32) REGPARAM; +static void custom_bput (uaecptr, uae_u32) REGPARAM; + +addrbank custom_bank = { + custom_lget, custom_wget, custom_bget, + custom_lput, custom_wput, custom_bput, + default_xlate, default_check, NULL +}; + +STATIC_INLINE uae_u32 REGPARAM2 custom_wget_1 (uaecptr addr, int noput) +{ + uae_u16 v; +#ifdef JIT + special_mem |= S_READ; +#endif + addr &= 0xfff; +#ifdef CUSTOM_DEBUG + write_log ("%d:%d:wget: %04.4X=%04.4X pc=%p\n", current_hpos(), vpos, addr, addr & 0x1fe, m68k_getpc()); +#endif + switch (addr & 0x1fe) { + case 0x002: v = DMACONR (); break; + case 0x004: v = VPOSR (); break; + case 0x006: v = VHPOSR (); break; + + case 0x00A: v = JOY0DAT (); break; + case 0x00C: v = JOY1DAT (); break; + case 0x00E: v = CLXDAT (); break; + case 0x010: v = ADKCONR (); break; + + case 0x012: v = POT0DAT (); break; + case 0x014: v = POT1DAT (); break; + case 0x016: v = POTGOR (); break; + case 0x018: v = SERDATR (); break; + case 0x01A: v = DSKBYTR (current_hpos ()); break; + case 0x01C: v = INTENAR (); break; + case 0x01E: v = INTREQR (); break; + case 0x07C: v = DENISEID (); break; + + case 0x02E: v = 0xffff; break; /* temporary hack */ + +#ifdef AGA + case 0x180: case 0x182: case 0x184: case 0x186: case 0x188: case 0x18A: + case 0x18C: case 0x18E: case 0x190: case 0x192: case 0x194: case 0x196: + case 0x198: case 0x19A: case 0x19C: case 0x19E: case 0x1A0: case 0x1A2: + case 0x1A4: case 0x1A6: case 0x1A8: case 0x1AA: case 0x1AC: case 0x1AE: + case 0x1B0: case 0x1B2: case 0x1B4: case 0x1B6: case 0x1B8: case 0x1BA: + case 0x1BC: case 0x1BE: + v = COLOR_READ ((addr & 0x3E) / 2); + break; +#endif + + default: + /* reading write-only register causes write with last value in bus */ + v = last_custom_value; + if (!noput) { + int r; + int hpos = current_hpos (); + decide_line (hpos); + decide_fetch (hpos); + decide_blitter (hpos); + v = last_custom_value; + r = custom_wput_1 (hpos, addr, v, 1); + } + return v; + } + return v; +} + + STATIC_INLINE custom_wget2 (uaecptr addr) + { + uae_u32 v; + sync_copper_with_cpu (current_hpos (), 1, addr); + if (currprefs.cpu_level >= 2) { + if(addr > 0xde0000 && addr <= 0xdeffff) + return 0x7f7f; + if(addr > 0xdd0000 && addr <= 0xddffff) + return 0xffff; + } + v = custom_wget_1 (addr, 0); +#ifdef ACTION_REPLAY +#ifdef ACTION_REPLAY_COMMON + addr &= 0x1ff; + ar_custom[addr + 0] = (uae_u8)(v >> 8); + ar_custom[addr + 1] = (uae_u8)(v); +#endif +#endif + return v; +} + +uae_u32 REGPARAM2 custom_wget (uaecptr addr) +{ + uae_u32 v; + + if (addr & 1) { + /* think about move.w $dff005,d0.. (68020+ only) */ + addr &= ~1; + v = custom_wget2 (addr) << 8; + v |= custom_wget2 (addr + 2) >> 8; + return v; + } + return custom_wget2 (addr); + } + +uae_u32 REGPARAM2 custom_bget (uaecptr addr) +{ +#ifdef JIT + special_mem |= S_READ; +#endif + return custom_wget2 (addr & ~1) >> (addr & 1 ? 0 : 8); +} + +uae_u32 REGPARAM2 custom_lget (uaecptr addr) +{ +#ifdef JIT + special_mem |= S_READ; +#endif + return ((uae_u32)custom_wget (addr) << 16) | custom_wget (addr + 2); +} + +int REGPARAM2 custom_wput_1 (int hpos, uaecptr addr, uae_u32 value, int noget) +{ + addr &= 0x1FE; + value &= 0xffff; +#ifdef ACTION_REPLAY +#ifdef ACTION_REPLAY_COMMON + ar_custom[addr+0]=(uae_u8)(value>>8); + ar_custom[addr+1]=(uae_u8)(value); +#endif +#endif + last_custom_value = value; + switch (addr) { + case 0x00E: CLXDAT (); break; + + case 0x020: DSKPTH (value); break; + case 0x022: DSKPTL (value); break; + case 0x024: DSKLEN (value, hpos); break; + case 0x026: DSKDAT (value); break; + + case 0x02A: VPOSW (value); break; + case 0x02E: COPCON (value); break; + case 0x030: SERDAT (value); break; + case 0x032: SERPER (value); break; + case 0x034: POTGO (value); break; + case 0x040: BLTCON0 (value); break; + case 0x042: BLTCON1 (value); break; + + case 0x044: BLTAFWM (value); break; + case 0x046: BLTALWM (value); break; + + case 0x050: BLTAPTH (value); break; + case 0x052: BLTAPTL (value); break; + case 0x04C: BLTBPTH (value); break; + case 0x04E: BLTBPTL (value); break; + case 0x048: BLTCPTH (value); break; + case 0x04A: BLTCPTL (value); break; + case 0x054: BLTDPTH (value); break; + case 0x056: BLTDPTL (value); break; + + case 0x058: BLTSIZE (value); break; + + case 0x064: BLTAMOD (value); break; + case 0x062: BLTBMOD (value); break; + case 0x060: BLTCMOD (value); break; + case 0x066: BLTDMOD (value); break; + + case 0x070: BLTCDAT (value); break; + case 0x072: BLTBDAT (value); break; + case 0x074: BLTADAT (value); break; + + case 0x07E: DSKSYNC (hpos, value); break; + + case 0x080: COP1LCH (value); break; + case 0x082: COP1LCL (value); break; + case 0x084: COP2LCH (value); break; + case 0x086: COP2LCL (value); break; + + case 0x088: COPJMP (1); break; + case 0x08A: COPJMP (2); break; + + case 0x08E: DIWSTRT (hpos, value); break; + case 0x090: DIWSTOP (hpos, value); break; + case 0x092: DDFSTRT (hpos, value); break; + case 0x094: DDFSTOP (hpos, value); break; + + case 0x096: DMACON (hpos, value); break; + case 0x098: CLXCON (value); break; + case 0x09A: INTENA (value); break; + case 0x09C: INTREQ (value); break; + case 0x09E: ADKCON (hpos, value); break; + + case 0x0A0: AUDxLCH (0, value); break; + case 0x0A2: AUDxLCL (0, value); break; + case 0x0A4: AUDxLEN (0, value); break; + case 0x0A6: AUDxPER (0, value); break; + case 0x0A8: AUDxVOL (0, value); break; + case 0x0AA: AUDxDAT (0, value); break; + + case 0x0B0: AUDxLCH (1, value); break; + case 0x0B2: AUDxLCL (1, value); break; + case 0x0B4: AUDxLEN (1, value); break; + case 0x0B6: AUDxPER (1, value); break; + case 0x0B8: AUDxVOL (1, value); break; + case 0x0BA: AUDxDAT (1, value); break; + + case 0x0C0: AUDxLCH (2, value); break; + case 0x0C2: AUDxLCL (2, value); break; + case 0x0C4: AUDxLEN (2, value); break; + case 0x0C6: AUDxPER (2, value); break; + case 0x0C8: AUDxVOL (2, value); break; + case 0x0CA: AUDxDAT (2, value); break; + + case 0x0D0: AUDxLCH (3, value); break; + case 0x0D2: AUDxLCL (3, value); break; + case 0x0D4: AUDxLEN (3, value); break; + case 0x0D6: AUDxPER (3, value); break; + case 0x0D8: AUDxVOL (3, value); break; + case 0x0DA: AUDxDAT (3, value); break; + + case 0x0E0: BPLxPTH (hpos, value, 0); break; + case 0x0E2: BPLxPTL (hpos, value, 0); break; + case 0x0E4: BPLxPTH (hpos, value, 1); break; + case 0x0E6: BPLxPTL (hpos, value, 1); break; + case 0x0E8: BPLxPTH (hpos, value, 2); break; + case 0x0EA: BPLxPTL (hpos, value, 2); break; + case 0x0EC: BPLxPTH (hpos, value, 3); break; + case 0x0EE: BPLxPTL (hpos, value, 3); break; + case 0x0F0: BPLxPTH (hpos, value, 4); break; + case 0x0F2: BPLxPTL (hpos, value, 4); break; + case 0x0F4: BPLxPTH (hpos, value, 5); break; + case 0x0F6: BPLxPTL (hpos, value, 5); break; + case 0x0F8: BPLxPTH (hpos, value, 6); break; + case 0x0FA: BPLxPTL (hpos, value, 6); break; + case 0x0FC: BPLxPTH (hpos, value, 7); break; + case 0x0FE: BPLxPTL (hpos, value, 7); break; + + case 0x100: BPLCON0 (hpos, value); break; + case 0x102: BPLCON1 (hpos, value); break; + case 0x104: BPLCON2 (hpos, value); break; +#ifdef AGA + case 0x106: BPLCON3 (hpos, value); break; +#endif + + case 0x108: BPL1MOD (hpos, value); break; + case 0x10A: BPL2MOD (hpos, value); break; +#ifdef AGA + case 0x10E: CLXCON2 (value); break; +#endif + + case 0x110: BPL1DAT (hpos, value); break; + case 0x112: BPL2DAT (value); break; + case 0x114: BPL3DAT (value); break; + case 0x116: BPL4DAT (value); break; + case 0x118: BPL5DAT (value); break; + case 0x11A: BPL6DAT (value); break; + case 0x11C: BPL7DAT (value); break; + case 0x11E: BPL8DAT (value); break; + + case 0x180: case 0x182: case 0x184: case 0x186: case 0x188: case 0x18A: + case 0x18C: case 0x18E: case 0x190: case 0x192: case 0x194: case 0x196: + case 0x198: case 0x19A: case 0x19C: case 0x19E: case 0x1A0: case 0x1A2: + case 0x1A4: case 0x1A6: case 0x1A8: case 0x1AA: case 0x1AC: case 0x1AE: + case 0x1B0: case 0x1B2: case 0x1B4: case 0x1B6: case 0x1B8: case 0x1BA: + case 0x1BC: case 0x1BE: + COLOR_WRITE (hpos, value & 0xFFF, (addr & 0x3E) / 2); + break; + case 0x120: case 0x124: case 0x128: case 0x12C: + case 0x130: case 0x134: case 0x138: case 0x13C: + SPRxPTH (hpos, value, (addr - 0x120) / 4); + break; + case 0x122: case 0x126: case 0x12A: case 0x12E: + case 0x132: case 0x136: case 0x13A: case 0x13E: + SPRxPTL (hpos, value, (addr - 0x122) / 4); + break; + case 0x140: case 0x148: case 0x150: case 0x158: + case 0x160: case 0x168: case 0x170: case 0x178: + SPRxPOS (hpos, value, (addr - 0x140) / 8); + break; + case 0x142: case 0x14A: case 0x152: case 0x15A: + case 0x162: case 0x16A: case 0x172: case 0x17A: + SPRxCTL (hpos, value, (addr - 0x142) / 8); + break; + case 0x144: case 0x14C: case 0x154: case 0x15C: + case 0x164: case 0x16C: case 0x174: case 0x17C: + SPRxDATA (hpos, value, (addr - 0x144) / 8); + break; + case 0x146: case 0x14E: case 0x156: case 0x15E: + case 0x166: case 0x16E: case 0x176: case 0x17E: + SPRxDATB (hpos, value, (addr - 0x146) / 8); + break; + + case 0x36: JOYTEST (value); break; + case 0x5A: BLTCON0L (value); break; + case 0x5C: BLTSIZV (value); break; + case 0x5E: BLTSIZH (value); break; + case 0x1E4: DIWHIGH (hpos, value); break; +#ifdef AGA + case 0x10C: BPLCON4 (hpos, value); break; +#endif + + case 0x1DC: BEAMCON0 (value); break; + case 0x1C0: if (htotal != value) { htotal = value; varsync (); } break; + case 0x1C2: if (hsstop != value) { hsstop = value; varsync (); } break; + case 0x1C4: if (hbstrt != value) { hbstrt = value; varsync (); } break; + case 0x1C6: if (hbstop != value) { hbstop = value; varsync (); } break; + case 0x1C8: if (vtotal != value) { vtotal = value; varsync (); } break; + case 0x1CA: if (vsstop != value) { vsstop = value; varsync (); } break; + case 0x1CC: if (vbstrt != value) { vbstrt = value; varsync (); } break; + case 0x1CE: if (vbstop != value) { vbstop = value; varsync (); } break; + case 0x1DE: if (hsstrt != value) { hsstrt = value; varsync (); } break; + case 0x1E0: if (vsstrt != value) { vsstrt = value; varsync (); } break; + case 0x1E2: if (hcenter != value) { hcenter = value; varsync (); } break; + +#ifdef AGA + case 0x1FC: FMODE (value); break; +#endif + + /* writing to read-only register causes read access */ + default: + if (!noget) + custom_wget_1 (addr, 1); + if (!(currprefs.chipset_mask & CSMASK_AGA) && (currprefs.chipset_mask & CSMASK_ECS_AGNUS)) + last_custom_value = 0xffff; + return 1; + } + return 0; +} + +void REGPARAM2 custom_wput (uaecptr addr, uae_u32 value) +{ + int hpos = current_hpos (); +#ifdef JIT + special_mem |= S_WRITE; +#endif +#ifdef CUSTOM_DEBUG + write_log ("%d:%d:wput: %04.4X %04.4X pc=%p\n", hpos, vpos, addr & 0x01fe, value & 0xffff, m68k_getpc()); +#endif + sync_copper_with_cpu (hpos, 1, addr); + custom_wput_1 (hpos, addr, value, 0); +} + +void REGPARAM2 custom_bput (uaecptr addr, uae_u32 value) +{ + static int warned; + /* Is this correct now? (There are people who bput things to the upper byte of AUDxVOL). */ + uae_u16 rval = (value << 8) | (value & 0xFF); +#ifdef JIT + special_mem |= S_WRITE; +#endif + custom_wput (addr & ~1, rval); + if (warned < 10) { + write_log ("Byte put to custom register %04.4X PC=%08.8X\n", addr, m68k_getpc()); + warned++; + } +} + +void REGPARAM2 custom_lput(uaecptr addr, uae_u32 value) +{ +#ifdef JIT + special_mem |= S_WRITE; +#endif + custom_wput (addr & 0xfffe, value >> 16); + custom_wput ((addr + 2) & 0xfffe, (uae_u16)value); +} + +void custom_prepare_savestate (void) +{ +} + +#define RB restore_u8 () +#define RW restore_u16 () +#define RL restore_u32 () + +uae_u8 *restore_custom (uae_u8 *src) +{ + uae_u16 dsklen, dskbytr; + int dskpt; + int i; + + audio_reset (); + + changed_prefs.chipset_mask = currprefs.chipset_mask = RL; + RW; /* 000 ? */ + RW; /* 002 DMACONR */ + RW; /* 004 VPOSR */ + RW; /* 006 VHPOSR */ + RW; /* 008 DSKDATR (dummy register) */ + RW; /* 00A JOY0DAT */ + RW; /* 00C JOY1DAT */ + clxdat = RW; /* 00E CLXDAT */ + RW; /* 010 ADKCONR */ + RW; /* 012 POT0DAT* */ + RW; /* 014 POT1DAT* */ + RW; /* 016 POTINP* */ + RW; /* 018 SERDATR* */ + dskbytr = RW; /* 01A DSKBYTR */ + RW; /* 01C INTENAR */ + RW; /* 01E INTREQR */ + dskpt = RL; /* 020-022 DSKPT */ + dsklen = RW; /* 024 DSKLEN */ + RW; /* 026 DSKDAT */ + RW; /* 028 REFPTR */ + lof = RW; /* 02A VPOSW */ + RW; /* 02C VHPOSW */ + COPCON(RW); /* 02E COPCON */ + RW; /* 030 SERDAT* */ + RW; /* 032 SERPER* */ + POTGO(RW); /* 034 POTGO */ + RW; /* 036 JOYTEST* */ + RW; /* 038 STREQU */ + RW; /* 03A STRVHBL */ + RW; /* 03C STRHOR */ + RW; /* 03E STRLONG */ + BLTCON0(RW); /* 040 BLTCON0 */ + BLTCON1(RW); /* 042 BLTCON1 */ + BLTAFWM(RW); /* 044 BLTAFWM */ + BLTALWM(RW); /* 046 BLTALWM */ + BLTCPTH(RL); /* 048-04B BLTCPT */ + BLTBPTH(RL); /* 04C-04F BLTBPT */ + BLTAPTH(RL); /* 050-053 BLTAPT */ + BLTDPTH(RL); /* 054-057 BLTDPT */ + RW; /* 058 BLTSIZE */ + RW; /* 05A BLTCON0L */ + blt_info.vblitsize = RW; /* 05C BLTSIZV */ + blt_info.hblitsize = RW; /* 05E BLTSIZH */ + BLTCMOD(RW); /* 060 BLTCMOD */ + BLTBMOD(RW); /* 062 BLTBMOD */ + BLTAMOD(RW); /* 064 BLTAMOD */ + BLTDMOD(RW); /* 066 BLTDMOD */ + RW; /* 068 ? */ + RW; /* 06A ? */ + RW; /* 06C ? */ + RW; /* 06E ? */ + BLTCDAT(RW); /* 070 BLTCDAT */ + BLTBDAT(RW); /* 072 BLTBDAT */ + BLTADAT(RW); /* 074 BLTADAT */ + RW; /* 076 ? */ + RW; /* 078 ? */ + RW; /* 07A ? */ + RW; /* 07C LISAID */ + DSKSYNC(-1, RW); /* 07E DSKSYNC */ + cop1lc = RL; /* 080/082 COP1LC */ + cop2lc = RL; /* 084/086 COP2LC */ + RW; /* 088 ? */ + RW; /* 08A ? */ + RW; /* 08C ? */ + diwstrt = RW; /* 08E DIWSTRT */ + diwstop = RW; /* 090 DIWSTOP */ + ddfstrt = RW; /* 092 DDFSTRT */ + ddfstop = RW; /* 094 DDFSTOP */ + dmacon = RW & ~(0x2000|0x4000); /* 096 DMACON */ + CLXCON(RW); /* 098 CLXCON */ + intena = RW; /* 09A INTENA */ + intreq = RW; /* 09C INTREQ */ + adkcon = RW; /* 09E ADKCON */ + for (i = 0; i < 8; i++) + bplpt[i] = RL; + bplcon0 = RW; /* 100 BPLCON0 */ + bplcon1 = RW; /* 102 BPLCON1 */ + bplcon2 = RW; /* 104 BPLCON2 */ + bplcon3 = RW; /* 106 BPLCON3 */ + bpl1mod = RW; /* 108 BPL1MOD */ + bpl2mod = RW; /* 10A BPL2MOD */ + bplcon4 = RW; /* 10C BPLCON4 */ + clxcon2 = RW; /* 10E CLXCON2* */ + for(i = 0; i < 8; i++) + RW; /* BPLXDAT */ + for(i = 0; i < 32; i++) + current_colors.color_regs_ecs[i] = RW; /* 180 COLORxx */ + htotal = RW; /* 1C0 HTOTAL */ + RW; /* 1C2 ? */ + RW; /* 1C4 ? */ + RW; /* 1C6 ? */ + vtotal = RW; /* 1C8 VTOTAL */ + RW; /* 1CA ? */ + RW; /* 1CC ? */ + RW; /* 1CE ? */ + RW; /* 1D0 ? */ + RW; /* 1D2 ? */ + RW; /* 1D4 ? */ + RW; /* 1D6 ? */ + RW; /* 1D8 ? */ + RW; /* 1DA ? */ + new_beamcon0 = RW; /* 1DC BEAMCON0 */ + RW; /* 1DE ? */ + RW; /* 1E0 ? */ + RW; /* 1E2 ? */ + diwhigh = RW; /* 1E4 ? */ + if (diwhigh & 0x8000) + diwhigh_written = 1; + diwhigh &= 0x7fff; + RW; /* 1E6 ? */ + RW; /* 1E8 ? */ + RW; /* 1EA ? */ + RW; /* 1EC ? */ + RW; /* 1EE ? */ + RW; /* 1F0 ? */ + RW; /* 1F2 ? */ + RW; /* 1F4 ? */ + RW; /* 1F6 ? */ + RW; /* 1F8 ? */ + RW; /* 1FA ? */ + fmode = RW; /* 1FC FMODE */ + last_custom_value = RW; /* 1FE ? */ + + DISK_restore_custom (dskpt, dsklen, dskbytr); + + return src; +} + + +#define SB save_u8 +#define SW save_u16 +#define SL save_u32 + +extern uae_u16 serper; + +uae_u8 *save_custom (int *len, uae_u8 *dstptr, int full) +{ + uae_u8 *dstbak, *dst; + int i; + uae_u32 dskpt; + uae_u16 dsklen, dsksync, dskbytr; + + DISK_save_custom (&dskpt, &dsklen, &dsksync, &dskbytr); + + if (dstptr) + dstbak = dst = dstptr; + else + dstbak = dst = malloc (8+256*2); + + SL (currprefs.chipset_mask); + SW (0); /* 000 ? */ + SW (dmacon); /* 002 DMACONR */ + SW (VPOSR()); /* 004 VPOSR */ + SW (VHPOSR()); /* 006 VHPOSR */ + SW (0); /* 008 DSKDATR */ + SW (JOY0DAT()); /* 00A JOY0DAT */ + SW (JOY1DAT()); /* 00C JOY1DAT */ + SW (clxdat); /* 00E CLXDAT */ + SW (ADKCONR()); /* 010 ADKCONR */ + SW (POT0DAT()); /* 012 POT0DAT */ + SW (POT0DAT()); /* 014 POT1DAT */ + SW (0) ; /* 016 POTINP * */ + SW (0); /* 018 SERDATR * */ + SW (dskbytr); /* 01A DSKBYTR */ + SW (INTENAR()); /* 01C INTENAR */ + SW (INTREQR()); /* 01E INTREQR */ + SL (dskpt); /* 020-023 DSKPT */ + SW (dsklen); /* 024 DSKLEN */ + SW (0); /* 026 DSKDAT */ + SW (0); /* 028 REFPTR */ + SW (lof); /* 02A VPOSW */ + SW (0); /* 02C VHPOSW */ + SW (copcon); /* 02E COPCON */ + SW (serper); /* 030 SERDAT * */ + SW (serdat); /* 032 SERPER * */ + SW (potgo_value); /* 034 POTGO */ + SW (0); /* 036 JOYTEST * */ + SW (0); /* 038 STREQU */ + SW (0); /* 03A STRVBL */ + SW (0); /* 03C STRHOR */ + SW (0); /* 03E STRLONG */ + SW (bltcon0); /* 040 BLTCON0 */ + SW (bltcon1); /* 042 BLTCON1 */ + SW (blt_info.bltafwm); /* 044 BLTAFWM */ + SW (blt_info.bltalwm); /* 046 BLTALWM */ + SL (bltcpt); /* 048-04B BLTCPT */ + SL (bltbpt); /* 04C-04F BLTCPT */ + SL (bltapt); /* 050-053 BLTCPT */ + SL (bltdpt); /* 054-057 BLTCPT */ + SW (0); /* 058 BLTSIZE */ + SW (0); /* 05A BLTCON0L (use BLTCON0 instead) */ + SW (blt_info.vblitsize); /* 05C BLTSIZV */ + SW (blt_info.hblitsize); /* 05E BLTSIZH */ + SW (blt_info.bltcmod); /* 060 BLTCMOD */ + SW (blt_info.bltbmod); /* 062 BLTBMOD */ + SW (blt_info.bltamod); /* 064 BLTAMOD */ + SW (blt_info.bltdmod); /* 066 BLTDMOD */ + SW (0); /* 068 ? */ + SW (0); /* 06A ? */ + SW (0); /* 06C ? */ + SW (0); /* 06E ? */ + SW (blt_info.bltcdat); /* 070 BLTCDAT */ + SW (blt_info.bltbdat); /* 072 BLTBDAT */ + SW (blt_info.bltadat); /* 074 BLTADAT */ + SW (0); /* 076 ? */ + SW (0); /* 078 ? */ + SW (0); /* 07A ? */ + SW (DENISEID()); /* 07C DENISEID/LISAID */ + SW (dsksync); /* 07E DSKSYNC */ + SL (cop1lc); /* 080-083 COP1LC */ + SL (cop2lc); /* 084-087 COP2LC */ + SW (0); /* 088 ? */ + SW (0); /* 08A ? */ + SW (0); /* 08C ? */ + SW (diwstrt); /* 08E DIWSTRT */ + SW (diwstop); /* 090 DIWSTOP */ + SW (ddfstrt); /* 092 DDFSTRT */ + SW (ddfstop); /* 094 DDFSTOP */ + SW (dmacon); /* 096 DMACON */ + SW (clxcon); /* 098 CLXCON */ + SW (intena); /* 09A INTENA */ + SW (intreq); /* 09C INTREQ */ + SW (adkcon); /* 09E ADKCON */ + for (i = 0; full && i < 32; i++) + SW (0); + for (i = 0; i < 8; i++) + SL (bplpt[i]); /* 0E0-0FE BPLxPT */ + SW (bplcon0); /* 100 BPLCON0 */ + SW (bplcon1); /* 102 BPLCON1 */ + SW (bplcon2); /* 104 BPLCON2 */ + SW (bplcon3); /* 106 BPLCON3 */ + SW (bpl1mod); /* 108 BPL1MOD */ + SW (bpl2mod); /* 10A BPL2MOD */ + SW (bplcon4); /* 10C BPLCON4 */ + SW (clxcon2); /* 10E CLXCON2 */ + for (i = 0;i < 8; i++) + SW (0); /* 110 BPLxDAT */ + if (full) { + for (i = 0; i < 8; i++) { + SL (spr[i].pt); /* 120-13E SPRxPT */ + SW (sprpos[i]); /* 1x0 SPRxPOS */ + SW (sprctl[i]); /* 1x2 SPRxPOS */ + SW (sprdata[i][0]); /* 1x4 SPRxDATA */ + SW (sprdatb[i][0]); /* 1x6 SPRxDATB */ + } + } + for ( i = 0; i < 32; i++) + SW (current_colors.color_regs_ecs[i]); /* 180-1BE COLORxx */ + SW (htotal); /* 1C0 HTOTAL */ + SW (0); /* 1C2 */ + SW (0); /* 1C4 */ + SW (0); /* 1C6 */ + SW (vtotal); /* 1C8 VTOTAL */ + SW (0); /* 1CA */ + SW (0); /* 1CC */ + SW (0); /* 1CE */ + SW (0); /* 1D0 */ + SW (0); /* 1D2 */ + SW (0); /* 1D4 */ + SW (0); /* 1D6 */ + SW (0); /* 1D8 */ + SW (0); /* 1DA */ + SW (beamcon0); /* 1DC BEAMCON0 */ + SW (0); /* 1DE */ + SW (0); /* 1E0 */ + SW (0); /* 1E2 */ + SW (diwhigh | (diwhigh_written ? 0x8000 : 0)); /* 1E4 */ + SW (0); /* 1E6 */ + SW (0); /* 1E8 */ + SW (0); /* 1EA */ + SW (0); /* 1EC */ + SW (0); /* 1EE */ + SW (0); /* 1F0 */ + SW (0); /* 1F2 */ + SW (0); /* 1F4 */ + SW (0); /* 1F6 */ + SW (0); /* 1F8 */ + SW (0); /* 1FA */ + SW (fmode); /* 1FC FMODE */ + SW (last_custom_value); /* 1FE */ + + *len = dst - dstbak; + return dstbak; +} + +uae_u8 *restore_custom_agacolors (uae_u8 *src) +{ + int i; + + for (i = 0; i < 256; i++) +#ifdef AGA + current_colors.color_regs_aga[i] = RL; +#else + RL; +#endif + return src; +} + +uae_u8 *save_custom_agacolors (int *len, uae_u8 *dstptr) +{ + uae_u8 *dstbak, *dst; + int i; + + if (dstptr) + dstbak = dst = dstptr; + else + dstbak = dst = malloc (256*4); + for (i = 0; i < 256; i++) +#ifdef AGA + SL (current_colors.color_regs_aga[i]); +#else + SL (0); +#endif + *len = dst - dstbak; + return dstbak; +} + +uae_u8 *restore_custom_sprite (int num, uae_u8 *src) +{ + spr[num].pt = RL; /* 120-13E SPRxPT */ + sprpos[num] = RW; /* 1x0 SPRxPOS */ + sprctl[num] = RW; /* 1x2 SPRxPOS */ + sprdata[num][0] = RW; /* 1x4 SPRxDATA */ + sprdatb[num][0] = RW; /* 1x6 SPRxDATB */ + sprdata[num][1] = RW; + sprdatb[num][1] = RW; + sprdata[num][2] = RW; + sprdatb[num][2] = RW; + sprdata[num][3] = RW; + sprdatb[num][3] = RW; + spr[num].armed = RB; + return src; +} + +uae_u8 *save_custom_sprite(int num, int *len, uae_u8 *dstptr) +{ + uae_u8 *dstbak, *dst; + + if (dstptr) + dstbak = dst = dstptr; + else + dstbak = dst = malloc (25); + SL (spr[num].pt); /* 120-13E SPRxPT */ + SW (sprpos[num]); /* 1x0 SPRxPOS */ + SW (sprctl[num]); /* 1x2 SPRxPOS */ + SW (sprdata[num][0]); /* 1x4 SPRxDATA */ + SW (sprdatb[num][0]); /* 1x6 SPRxDATB */ + SW (sprdata[num][1]); + SW (sprdatb[num][1]); + SW (sprdata[num][2]); + SW (sprdatb[num][2]); + SW (sprdata[num][3]); + SW (sprdatb[num][3]); + SB (spr[num].armed ? 1 : 0); + *len = dst - dstbak; + return dstbak; +} + +void check_prefs_changed_custom (void) +{ + currprefs.gfx_framerate = changed_prefs.gfx_framerate; + if (inputdevice_config_change_test ()) { + inputdevice_copyconfig (&changed_prefs, &currprefs); + inputdevice_updateconfig (&currprefs); + } + currprefs.immediate_blits = changed_prefs.immediate_blits; + currprefs.collision_level = changed_prefs.collision_level; + currprefs.fast_copper = changed_prefs.fast_copper; + + if (currprefs.chipset_mask != changed_prefs.chipset_mask || + currprefs.gfx_vsync != changed_prefs.gfx_vsync || + currprefs.ntscmode != changed_prefs.ntscmode) { + currprefs.gfx_vsync = changed_prefs.gfx_vsync; + currprefs.chipset_mask = changed_prefs.chipset_mask; + if (currprefs.ntscmode != changed_prefs.ntscmode) { + currprefs.ntscmode = changed_prefs.ntscmode; + new_beamcon0 = currprefs.ntscmode ? 0x00 : 0x20; + } + init_hz (); + calcdiw (); + } + currprefs.gfx_filter_horiz_zoom = changed_prefs.gfx_filter_horiz_zoom; + currprefs.gfx_filter_vert_zoom = changed_prefs.gfx_filter_vert_zoom; + currprefs.gfx_filter_horiz_offset = changed_prefs.gfx_filter_horiz_offset; + currprefs.gfx_filter_vert_offset = changed_prefs.gfx_filter_vert_offset; + currprefs.gfx_filter_scanlines = changed_prefs.gfx_filter_scanlines; + currprefs.gfx_filter_filtermode = changed_prefs.gfx_filter_filtermode; +} + +#ifdef CPUEMU_6 + +STATIC_INLINE void sync_copper (int hpos) +{ + if (eventtab[ev_copper].active) { + eventtab[ev_copper].active = 0; + update_copper (hpos); + return; + } + if (copper_enabled_thisline) + update_copper (hpos); +} + +STATIC_INLINE int dma_cycle(void) +{ + int hpos, cycles = 0, bnasty = 0; + + for (;;) { + int bpldma; + int blitpri = dmaen (DMA_BLITPRI); + do_cycles (1 * CYCLE_UNIT); + cycles += CYCLE_UNIT; + hpos = current_hpos (); + sync_copper (hpos); + decide_line (hpos); + bpldma = is_bitplane_dma (hpos); + if (cycle_line[hpos] == 0 && !bpldma) { + if (bltstate == BLT_done || bnasty >= 3) + break; + decide_blitter (hpos); + if (cycle_line[hpos] == 0) + break; + if (!blitpri || blit_singlechannel) + bnasty++; + } else if (bpldma && (blit_singlechannel || !blitpri)) { + bnasty++; + } + /* bus was allocated to dma channel, wait for next cycle.. */ + } + cycle_line[hpos] |= CYCLE_CPU; + return cycles; +} + +uae_u32 wait_cpu_cycle_read (uaecptr addr, int mode) +{ + uae_u32 v = 0; + dma_cycle (); + if (mode > 0) + v = get_word (addr); + else if (mode == 0) + v = get_byte (addr); + do_cycles (1 * CYCLE_UNIT); + return v; +} + +uae_u32 wait_cpu_cycle_read_cycles (uaecptr addr, int mode, int *cycles) +{ + uae_u32 v = 0; + *cycles = dma_cycle () + CYCLE_UNIT; + if (mode > 0) + v = get_word (addr); + else if (mode == 0) + v = get_byte (addr); + do_cycles (1 * CYCLE_UNIT); + return v; +} + +void wait_cpu_cycle_write (uaecptr addr, int mode, uae_u32 v) +{ + dma_cycle (); + if (mode > 0) + put_word (addr, v); + else if (mode == 0) + put_byte (addr, v); + do_cycles (1 * CYCLE_UNIT); +} + +void do_cycles_ce (long cycles) +{ + int hpos, bpldma; + while (cycles > 0) { + do_cycles (1 * CYCLE_UNIT); + cycles -= CYCLE_UNIT; + hpos = current_hpos (); + sync_copper (hpos); + decide_line (hpos); + bpldma = is_bitplane_dma (hpos); + if (cycle_line[hpos] == 0 && !bpldma) + decide_blitter (hpos); + } +} + +#endif diff --git a/debug.c b/debug.c index c2b442e4..9cf8de65 100755 --- a/debug.c +++ b/debug.c @@ -761,6 +761,8 @@ static void memwatch (char **c) mwn->rw = 1; else if (nc == 'R' && toupper(**c) != 'W') mwn->rw = 0; + else if (nc == 'R' && toupper(**c) == 'W') + next_char (c); ignore_ws (c); if (more_params (c)) { if (toupper(**c) == 'M') { @@ -1160,6 +1162,7 @@ static void debug_1 (void) } debugger_active = 0; debugging = 0; + exception_debugging = 0; return; case 'H': diff --git a/disk.c b/disk.c index c2a29fa7..511cba1e 100755 --- a/disk.c +++ b/disk.c @@ -31,19 +31,31 @@ #include "osemu.h" #include "execlib.h" #include "savestate.h" +#ifdef FDI2RAW #include "fdi2raw.h" +#endif #include "catweasel.h" #include "driveclick.h" #ifdef CAPS #include "caps/caps_win32.h" #endif +/* support HD floppies */ +#define FLOPPY_DRIVE_HD /* writable track length with normal 2us bitcell/300RPM motor (PAL) */ #define FLOPPY_WRITE_LEN (currprefs.ntscmode ? (12798 / 2) : (12668 / 2)) /* 12667 PAL, 12797 NTSC */ /* This works out to 350 */ #define FLOPPY_GAP_LEN (FLOPPY_WRITE_LEN - 11 * 544) /* (cycles/bitcell) << 8, normal = ((2us/280ns)<<8) = ~1830 */ #define NORMAL_FLOPPY_SPEED (currprefs.ntscmode ? 1810 : 1829) +/* max supported floppy drives, for small memory systems */ +#define MAX_FLOPPY_DRIVES 4 + +#ifdef FLOPPY_DRIVE_HD +#define DDHDMULT 2 +#else +#define DDHDMULT 1 +#endif #define DISK_DEBUG #define DISK_DEBUG2 @@ -64,10 +76,11 @@ static int side, direction, writing; static uae_u8 selected = 15, disabled; -static uae_u8 *writebuffer[544 * 22]; +static uae_u8 *writebuffer[544 * 11 * DDHDMULT]; #define DISK_INDEXSYNC 1 #define DISK_WORDSYNC 2 +#define DISK_REVOLUTION 4 /* 4,8,16,32 */ /* A value of 5 works out to a guaranteed delay of 1/2 of a second Higher values are dangerous, e.g. a value of 8 breaks the RSI @@ -86,6 +99,7 @@ static int dma_enable, bitoffset, syncoffset; static uae_u16 word, dsksync; /* Always carried through to the next line. */ static int disk_hpos; +static int disk_jitter; typedef enum { TRACK_AMIGADOS, TRACK_RAW, TRACK_RAW1 } image_tracktype; typedef struct { @@ -96,7 +110,7 @@ typedef struct { image_tracktype type; } trackid; -#define MAX_TRACKS 328 +#define MAX_TRACKS (2 * 83) /* We have three kinds of Amiga floppy drives * - internal A500/A2000 drive: @@ -113,8 +127,6 @@ typedef struct { #define DRIVE_ID_35HD 0xAAAAAAAA #define DRIVE_ID_525SD 0x55555555 /* 40 track 5.25 drive , kickstart does not recognize this */ -#define MAX_REVOLUTIONS 5 - typedef enum { ADF_NORMAL, ADF_EXT1, ADF_EXT2, ADF_FDI, ADF_IPF, ADF_CATWEASEL } drive_filetype; typedef struct { struct zfile *diskfile; @@ -127,12 +139,10 @@ typedef struct { int motoroff; int state; int wrprot; - uae_u16 bigmfmbuf[MAX_REVOLUTIONS * 0x8000]; - int revolutions; - int current_revolution; - uae_u16 *trackpointers[MAX_REVOLUTIONS]; - uae_u16 *tracktiming; - int tracklengths[MAX_REVOLUTIONS]; + uae_u16 bigmfmbuf[0x4000 * DDHDMULT]; + uae_u16 tracktiming[0x4000 * DDHDMULT]; + int multi_revolution; + int skipoffset; int mfmpos; int indexoffset; int tracklen; @@ -152,7 +162,9 @@ typedef struct { int idbit; unsigned long drive_id; /* drive id to be reported */ char newname[256]; /* storage space for new filename during eject delay */ +#ifdef FDI2RAW FDI *fdi; +#endif int useturbo; int floppybitcounter; /* number of bits left */ #ifdef CATWEASEL @@ -162,10 +174,10 @@ typedef struct { #endif } drive; -static uae_u16 bigmfmbufw[0x8000]; -static drive floppy[4]; +static uae_u16 bigmfmbufw[0x4000 * DDHDMULT]; +static drive floppy[MAX_FLOPPY_DRIVES]; #define MAX_PREVIOUS_FLOPPIES 99 -static char dfxhistory[MAX_PREVIOUS_FLOPPIES][256]; +static char dfxhistory[MAX_PREVIOUS_FLOPPIES][MAX_DPATH]; static uae_u8 exeheader[]={0x00,0x00,0x03,0xf3,0x00,0x00,0x00,0x00}; static uae_u8 bootblock[]={ @@ -477,10 +489,14 @@ static void drive_settype_id(drive *drv) switch (t) { case DRV_35_HD: +#ifdef FLOPPY_DRIVE_HD if (!drv->diskfile || drv->ddhd <= 1) drv->drive_id = DRIVE_ID_35DD; else drv->drive_id = DRIVE_ID_35HD; +#else + drv->drive_id = DRIVE_ID_35DD; +#endif break; case DRV_35_DD: default: @@ -505,8 +521,10 @@ static void drive_image_free (drive *drv) #endif break; case ADF_FDI: - fdi2raw_header_free (drv->fdi); +#ifdef FDI2RAW + fdi2raw_header_free (drv->fdi); drv->fdi = 0; +#endif break; } drv->filetype = -1; @@ -593,13 +611,9 @@ static void track_reset (drive *drv) { drv->tracklen = FLOPPY_WRITE_LEN * drv->ddhd * 2 * 8; drv->trackspeed = get_floppy_speed (); - drv->revolutions = 0; - drv->tracklengths[0] = drv->tracklen; - drv->current_revolution = 0; - drv->trackpointers[0] = drv->bigmfmbuf; drv->buffered_side = -1; - free (drv->tracktiming); - drv->tracktiming = 0; + drv->skipoffset = -1; + drv->tracktiming[0] = 0; memset (drv->bigmfmbuf, 0xaa, FLOPPY_WRITE_LEN * 2 * drv->ddhd); updatemfmpos (drv); } @@ -762,8 +776,7 @@ static int drive_insert (drive * drv, int dnum, const char *fname) drv->ddhd = 1; drv->num_secs = 0; drv->hard_num_cyls = currprefs.dfxtype[dnum] == DRV_525_SD ? 40 : 80; - free (drv->tracktiming); - drv->tracktiming = 0; + drv->tracktiming[0] = 0; drv->useturbo = 0; drv->indexoffset = 0; @@ -805,13 +818,14 @@ static int drive_insert (drive * drv, int dnum, const char *fname) drv->num_tracks = num_tracks; drv->filetype = ADF_IPF; #endif +#ifdef FDI2RAW } else if (drv->fdi = fdi2raw_header (drv->diskfile)) { drv->wrprot = 1; drv->num_tracks = fdi2raw_get_last_track (drv->fdi); drv->num_secs = fdi2raw_get_num_sector (drv->fdi); drv->filetype = ADF_FDI; - +#endif } else if (strncmp ((char *) buffer, "UAE-1ADF", 8) == 0) { read_header_ext2 (drv->diskfile, drv->trackdata, &drv->num_tracks, &drv->ddhd); @@ -1085,10 +1099,10 @@ static void drive_fill_bigbuf (drive * drv, int force) if (!force && drv->buffered_cyl == drv->cyl && drv->buffered_side == side) return; - drv->revolutions = 0; drv->indexoffset = 0; - free (drv->tracktiming); - drv->tracktiming = 0; + drv->multi_revolution = 0; + drv->tracktiming[0] = 0; + drv->skipoffset = -1; if (drv->writediskfile && drv->writetrackdata[tr].bitlen > 0) { int i; @@ -1118,14 +1132,14 @@ static void drive_fill_bigbuf (drive * drv, int force) } else if (drv->filetype == ADF_IPF) { #ifdef CAPS - caps_loadtrack (drv->bigmfmbuf, drv->trackpointers, &drv->tracktiming, drv - floppy, tr, drv->tracklengths, &drv->revolutions); - drv->tracklen = drv->tracklengths[0]; + caps_loadtrack (drv->bigmfmbuf, drv->tracktiming, drv - floppy, tr, &drv->tracklen, &drv->multi_revolution); #endif } else if (drv->filetype == ADF_FDI) { - fdi2raw_loadtrack (drv->fdi, drv->bigmfmbuf, drv->trackpointers, &drv->tracktiming, tr, drv->tracklengths, &drv->revolutions, &drv->indexoffset); - drv->tracklen = drv->tracklengths[0]; +#ifdef FDI2RAW + fdi2raw_loadtrack (drv->fdi, drv->bigmfmbuf, drv->tracktiming, tr, &drv->tracklen, &drv->indexoffset, &drv->multi_revolution, 1); +#endif } else if (ti->type == TRACK_AMIGADOS) { @@ -1137,6 +1151,7 @@ static void drive_fill_bigbuf (drive * drv, int force) memset (dstmfmbuf, 0xaa, len * 2); dstmfmoffset += FLOPPY_GAP_LEN; + drv->skipoffset = FLOPPY_GAP_LEN / 3 * 2; drv->tracklen = len * 2 * 8; for (sec = 0; sec < drv->num_secs; sec++) { @@ -1232,13 +1247,10 @@ static void drive_fill_bigbuf (drive * drv, int force) write_log ("rawtrack %d\n", tr); #endif } - drv->current_revolution = 0; - drv->tracklengths[0] = drv->tracklen; - drv->trackpointers[0] = drv->bigmfmbuf; drv->buffered_side = side; drv->buffered_cyl = drv->cyl; if (drv->tracklen == 0) { - drv->tracklengths[0] = drv->tracklen = FLOPPY_WRITE_LEN * drv->ddhd * 2 * 8; + drv->tracklen = FLOPPY_WRITE_LEN * drv->ddhd * 2 * 8; memset (drv->bigmfmbuf, 0, FLOPPY_WRITE_LEN * 2 * drv->ddhd); } drv->trackspeed = get_floppy_speed () * drv->tracklen / (2 * 8 * FLOPPY_WRITE_LEN * drv->ddhd); @@ -1433,8 +1445,7 @@ static void drive_write_data (drive * drv) case ADF_IPF: break; } - free (drv->tracktiming); - drv->tracktiming = 0; + drv->tracktiming[0] = 0; } static void drive_eject (drive * drv) @@ -1566,7 +1577,7 @@ static void setdskchangetime(drive *drv, int dsktime) /* prevent multiple disk insertions at the same time */ if (drv->dskchange_time > 0) return; - for (i = 0; i < 4; i++) { + for (i = 0; i < MAX_FLOPPY_DRIVES; i++) { if (&floppy[i] != drv && floppy[i].dskchange_time > 0 && floppy[i].dskchange_time + 5 >= dsktime) { dsktime = floppy[i].dskchange_time + 5; } @@ -1593,7 +1604,7 @@ int disk_setwriteprotect (int num, const char *name, int protect) disk_creatediskfile (name2, 1, drvtype); zfile_fclose (zf2); if (protect && iswritefileempty (name)) { - for (i = 0; i < 4; i++) { + for (i = 0; i < MAX_FLOPPY_DRIVES; i++) { if (!strcmp (name, floppy[i].newname)) drive_eject (&floppy[i]); } @@ -1655,6 +1666,8 @@ char *DISK_history_get (int idx) void disk_insert (int num, const char *name) { drive *drv = floppy + num; + if (!strcmp (currprefs.df[num], name)) + return; strcpy (drv->newname, name); strcpy (currprefs.df[num], name); DISK_history_add (name, -1); @@ -1678,17 +1691,15 @@ void DISK_check_change (void) if (currprefs.floppy_speed != changed_prefs.floppy_speed) currprefs.floppy_speed = changed_prefs.floppy_speed; - for (i = 0; i < 4; i++) { + for (i = 0; i < MAX_FLOPPY_DRIVES; i++) { drive *drv = floppy + i; gui_lock (); if (currprefs.dfxtype[i] != changed_prefs.dfxtype[i]) { currprefs.dfxtype[i] = changed_prefs.dfxtype[i]; reset_drive (i); } - if (strcmp (currprefs.df[i], changed_prefs.df[i])) { - strcpy (currprefs.df[i], changed_prefs.df[i]); - disk_insert (i, currprefs.df[i]); - } + if (strcmp (currprefs.df[i], changed_prefs.df[i])) + disk_insert (i, changed_prefs.df[i]); gui_unlock (); if (drv->dskready_down_time > 0) drv->dskready_down_time--; @@ -1763,7 +1774,7 @@ void DISK_select (uae_u8 data) #endif step = step_pulse; if (step && !savestate_state) { - for (dr = 0; dr < 4; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { if (!(selected & (1 << dr))) { drive_step (floppy + dr); } @@ -1771,7 +1782,7 @@ void DISK_select (uae_u8 data) } } if (!savestate_state) { - for (dr = 0; dr < 4; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = floppy + dr; /* motor on/off workings tested with small assembler code on real Amiga 1200. */ /* motor/id flipflop is set only when drive select goes from high to low */ @@ -1800,7 +1811,7 @@ void DISK_select (uae_u8 data) } } } - for (dr = 0; dr < 4; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { floppy[dr].state = (!(selected & (1 << dr))) | !floppy[dr].motoroff; update_drive_gui (dr); } @@ -1815,7 +1826,7 @@ uae_u8 DISK_status (void) uae_u8 st = 0x3c; int dr; - for (dr = 0; dr < 4; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = floppy + dr; if (!(selected & (1 << dr))) { if (drive_running (drv)) { @@ -1879,7 +1890,7 @@ void dumpdisk (void) int i, j, k; uae_u16 w; - for (i = 0; i < 4; i++) { + for (i = 0; i < MAX_FLOPPY_DRIVES; i++) { drive *drv = &floppy[i]; if (!(disabled & (1 << i))) { write_log ("Drive %d: motor %s cylinder %2d sel %s %s mfmpos %d/%d\n", @@ -1908,6 +1919,26 @@ static void disk_dmafinished (void) #endif } +static void fetchnextrevolution (drive *drv) +{ + drv->trackspeed = get_floppy_speed () * drv->tracklen / (2 * 8 * FLOPPY_WRITE_LEN * drv->ddhd); + if (!drv->multi_revolution) + return; + switch (drv->filetype) + { + case ADF_IPF: +#ifdef CAPS + caps_loadrevolution (drv->bigmfmbuf, drv - floppy, drv->cyl * 2 + side, &drv->tracklen); +#endif + break; + case ADF_FDI: +#ifdef FDI2RAW + fdi2raw_loadrevolution (drv->fdi, drv->bigmfmbuf, drv->tracktiming, drv->cyl * 2 + side, &drv->tracklen, 1); +#endif + break; + } +} + extern void cia_diskindex (void); static int diskevent_flag; @@ -1918,13 +1949,21 @@ void DISK_handler (void) int i, flag = diskevent_flag; eventtab[ev_disk].active = 0; DISK_update (disk_sync_cycle); + if (flag & (DISK_REVOLUTION << 0)) + fetchnextrevolution (&floppy[0]); + if (flag & (DISK_REVOLUTION << 1)) + fetchnextrevolution (&floppy[1]); + if (flag & (DISK_REVOLUTION << 2)) + fetchnextrevolution (&floppy[2]); + if (flag & (DISK_REVOLUTION << 3)) + fetchnextrevolution (&floppy[3]); if (flag & DISK_WORDSYNC) { INTREQ (0x8000 | 0x1000); } if (flag & DISK_INDEXSYNC) { cia_diskindex (); #if 0 - for (i = 0; i < 4; i++) { + for (i = 0; i < MAX_FLOPPY_DRIVES; i++) { drive *drv = &floppy[i]; if (drv->dskready_time) { drv->dskready_time--; @@ -1945,7 +1984,7 @@ static void disk_doupdate_write (drive * drv, int floppybits) int dr; int drives[4]; - for (dr = 0; dr < 4 ; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv2 = &floppy[dr]; drives[dr] = 0; if (drv2->motoroff) @@ -1956,7 +1995,7 @@ static void disk_doupdate_write (drive * drv, int floppybits) } while (floppybits >= drv->trackspeed) { - for (dr = 0; dr < 4; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { if (drives[dr]) { floppy[dr].mfmpos++; floppy[dr].mfmpos %= drv->tracklen; @@ -1966,7 +2005,7 @@ static void disk_doupdate_write (drive * drv, int floppybits) bitoffset++; bitoffset &= 15; if (!bitoffset) { - for (dr = 0; dr < 4 ; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES ; dr++) { drive *drv2 = &floppy[dr]; if (drives[dr]) drv2->bigmfmbuf[drv2->mfmpos >> 4] = get_word (dskpt); @@ -1986,12 +2025,15 @@ static void disk_doupdate_write (drive * drv, int floppybits) static void updatetrackspeed (drive *drv, int mfmpos) { if (dskdmaen < 3) { - uae_u16 *p = drv->trackpointers[drv->current_revolution] - drv->trackpointers[0] + drv->tracktiming; + uae_u16 *p = drv->tracktiming; p += mfmpos / 8; drv->trackspeed = get_floppy_speed () * drv->tracklen / (2 * 8 * FLOPPY_WRITE_LEN * drv->ddhd); drv->trackspeed = drv->trackspeed * p[0] / 1000; if (drv->trackspeed < 700 || drv->trackspeed > 3000) { - write_log ("corrupted trackspeed value %d\n", drv->trackspeed); + static int warned; + warned++; + if (warned < 50) + write_log ("corrupted trackspeed value %d\n", drv->trackspeed); assert (0); } } @@ -2007,24 +2049,37 @@ static void disk_doupdate_predict (drive * drv, int startcycle) diskevent_flag = 0; while (startcycle < (maxhpos << 8) && !diskevent_flag) { int cycle = startcycle >> 8; - if (drv->tracktiming) + if (drv->tracktiming[0]) updatetrackspeed (drv, mfmpos); if (dskdmaen != 3) { tword <<= 1; if (unformatted (drv)) tword |= (rand() & 0x1000) ? 1 : 0; else - tword |= getonebit (drv->trackpointers[drv->current_revolution], mfmpos); + tword |= getonebit (drv->bigmfmbuf, mfmpos); if ((tword & 0xffff) == dsksync) diskevent_flag |= DISK_WORDSYNC; } mfmpos++; mfmpos %= drv->tracklen; + if (mfmpos == 0) + diskevent_flag |= DISK_REVOLUTION << (drv - floppy); if (mfmpos == drv->indexoffset) diskevent_flag |= DISK_INDEXSYNC; + if (mfmpos == drv->skipoffset) { + int skipcnt = disk_jitter; + while (skipcnt-- > 0) { + if (mfmpos == drv->indexoffset) + diskevent_flag |= DISK_INDEXSYNC; + if (mfmpos == 0) + diskevent_flag |= DISK_REVOLUTION << (drv - floppy); + mfmpos++; + mfmpos %= drv->tracklen; + } + } startcycle += drv->trackspeed; } - if (drv->tracktiming) + if (drv->tracktiming[0]) updatetrackspeed (drv, drv->mfmpos); if (diskevent_flag) { disk_sync_cycle = startcycle >> 8; @@ -2062,24 +2117,20 @@ static void disk_doupdate_read (drive * drv, int floppybits) mfmbuf[7] = 0x4444; */ while (floppybits >= drv->trackspeed) { - if (drv->tracktiming) + if (drv->tracktiming[0]) updatetrackspeed (drv, drv->mfmpos); word <<= 1; if (unformatted (drv)) word |= (rand() & 0x1000) ? 1 : 0; else - word |= getonebit (drv->trackpointers[drv->current_revolution], drv->mfmpos); + word |= getonebit (drv->bigmfmbuf, drv->mfmpos); //write_log ("%08.8X bo=%d so=%d mfmpos=%d dma=%d\n", (word & 0xffffff), bitoffset, syncoffset, drv->mfmpos,dma_enable); drv->mfmpos++; drv->mfmpos %= drv->tracklen; - if (drv->mfmpos == drv->indexoffset) { - drv->current_revolution++; - if (drv->current_revolution >= drv->revolutions) - drv->current_revolution = 0; - drv->tracklen = drv->tracklengths[drv->current_revolution]; - drv->trackspeed = get_floppy_speed () * drv->tracklen / (2 * 8 * FLOPPY_WRITE_LEN * drv->ddhd); + if (drv->mfmpos == drv->skipoffset) { + drv->mfmpos += disk_jitter; + drv->mfmpos %= drv->tracklen; } - if (bitoffset == 15 && dma_enable && dskdmaen == 2 && dsklength >= 0) { if (dsklength > 0) { put_word (dskpt, word); @@ -2107,11 +2158,13 @@ static void disk_doupdate_read (drive * drv, int floppybits) if (word == dsksync) { if (adkcon & 0x400) bitoffset = 15; + if (dskdmaen) { #ifdef DISK_DEBUG - if (dma_enable == 0) - write_dlog ("Sync match, DMA started at %d\n", drv->mfmpos); + if (dma_enable == 0) + write_dlog ("Sync match, DMA started at %d\n", drv->mfmpos); #endif - dma_enable = 1; + dma_enable = 1; + } } bitoffset++; @@ -2166,7 +2219,7 @@ static void DISK_start (void) { int dr; - for (dr = 0; dr < 4; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = &floppy[dr]; if (!(selected & (1 << dr))) { int tr = drv->cyl * 2 + side; @@ -2197,13 +2250,16 @@ void DISK_update (int tohpos) int cycles = (tohpos << 8) - disk_hpos; int startcycle = disk_hpos; + disk_jitter = (rand () >> 4) & 3; + if (disk_jitter > 2) + disk_jitter = 0; if (cycles <= 0) return; disk_hpos += cycles; if (disk_hpos >= (maxhpos << 8)) disk_hpos -= maxhpos << 8; - for (dr = 0; dr < 4; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = &floppy[dr]; if (drv->steplimit) drv->steplimit--; @@ -2219,7 +2275,7 @@ void DISK_update (int tohpos) dodmafetch (); #endif - for (dr = 0; dr < 4; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = &floppy[dr]; if (drv->motoroff) @@ -2234,7 +2290,7 @@ void DISK_update (int tohpos) drive_fill_bigbuf (drv, 0); drv->mfmpos %= drv->tracklen; } - for (dr = 0; dr < 4; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = &floppy[dr]; if (drv->motoroff) continue; @@ -2287,7 +2343,7 @@ void DSKLEN (uae_u16 v, int hpos) } #ifdef DISK_DEBUG - for (dr = 0; dr < 4; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = &floppy[dr]; if (drv->motoroff) continue; @@ -2308,18 +2364,18 @@ void DSKLEN (uae_u16 v, int hpos) /* Try to make floppy access from Kickstart faster. */ if (dskdmaen != 2 && dskdmaen != 3) return; - for (dr = 0; dr < 4; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = &floppy[dr]; if (selected & (1 << dr)) continue; if (drv->filetype != ADF_NORMAL) break; } - if (dr < 4) /* no turbo mode if any selected drive has non-standard ADF */ + if (dr < MAX_FLOPPY_DRIVES) /* no turbo mode if any selected drive has non-standard ADF */ return; { int done = 0; - for (dr = 0; dr < 4; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = &floppy[dr]; int pos, i; @@ -2410,7 +2466,7 @@ void DSKPTL (uae_u16 v) void DISK_free (void) { int dr; - for (dr = 0; dr < 4; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = &floppy[dr]; drive_image_free (drv); } @@ -2423,7 +2479,7 @@ void DISK_init (void) #if 0 dma_tab[0] = 0xffffffff; #endif - for (dr = 0; dr < 4; dr++) { + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = &floppy[dr]; /* reset all drive types to 3.5 DD */ drive_settype_id (drv); @@ -2445,7 +2501,7 @@ void DISK_reset (void) disk_hpos = 0; dskdmaen = 0; disabled = 0; - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_FLOPPY_DRIVES; i++) reset_drive (i); } diff --git a/driveclick.c b/driveclick.c index 9aecd6f0..f9c364f3 100755 --- a/driveclick.c +++ b/driveclick.c @@ -206,6 +206,7 @@ static int clickcnt; static void mix (void) { int total = ((uae_u8*)sndbufpt - (uae_u8*)sndbuffer) / (currprefs.stereo ? 4 : 2); + if (currprefs.dfxclickvolume > 0) { while (clickcnt < total) { clickbuffer[clickcnt++] = getsample() * (100 - currprefs.dfxclickvolume) / 100; @@ -215,8 +216,6 @@ static void mix (void) clickbuffer[clickcnt++] = getsample(); } } - if (clickcnt > 0) - clickbuffer[clickcnt] = clickbuffer[clickcnt - 1]; } STATIC_INLINE uae_s16 limit (uae_s32 v) diff --git a/fdi2raw.c b/fdi2raw.c index adc770bd..19b27deb 100755 --- a/fdi2raw.c +++ b/fdi2raw.c @@ -1,30 +1,30 @@ /* - FDI to raw bit stream converter - Copyright (c) 2001 by Toni Wilen + FDI to raw bit stream converter + Copyright (c) 2001 by Toni Wilen FDI 2.0 support - Copyright (c) 2003-2004 by Toni Wilen - and Vincent Joguin + Copyright (c) 2003-2004 by Toni Wilen + and Vincent Joguin - FDI format created by Vincent "ApH" Joguin + FDI format created by Vincent "ApH" Joguin - Tiny changes - function type fixes, multiple drives, addition of - get_last_head and C++ callability - by Thomas Harte, 2001, + Tiny changes - function type fixes, multiple drives, addition of + get_last_head and C++ callability - by Thomas Harte, 2001, T.Harte@excite.co.uk - 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) + 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. + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR 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., + with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ @@ -37,13 +37,14 @@ #include "sysconfig.h" #include "sysdeps.h" #include "zfile.h" -/* ELSE */ +/* ELSE */ //#include "types.h" #include "fdi2raw.h" #undef DEBUG -#define VERBOSE +#define VERBOSE +#undef VERBOSE #include @@ -52,34 +53,34 @@ static char *datalog(uae_u8 *src, int len) { static char buf[1000]; static int offset; - int i = 0, offset2; + int i = 0, offset2; - offset2 = offset; + offset2 = offset; buf[offset++]='\''; while(len--) { - sprintf (buf + offset, "%02.2X", src[i]); + sprintf (buf + offset, "%02.2X", src[i]); offset += 2; i++; - if (i > 10) break; + if (i > 10) break; } buf[offset++]='\''; - buf[offset++] = 0; + buf[offset++] = 0; if (offset >= 900) offset = 0; return buf + offset2; } #else -static char *datalog(uae_u8 *src, int len) { return ""; } +static char *datalog(uae_u8 *src, int len) { return ""; } #endif #ifdef DEBUG -#define debuglog write_log +#define debuglog write_log #else -#define debuglog +#define debuglog #endif #ifdef VERBOSE -#define outlog write_log +#define outlog write_log #else -#define outlog +#define outlog #endif static int fdi_allocated; @@ -87,38 +88,39 @@ static int fdi_allocated; static void fdi_free (void *p) { int size; - if (!p) - return; + if (!p) + return; size = ((int*)p)[-1]; fdi_allocated -= size; write_log ("%d freed (%d)\n", size, fdi_allocated); - free ((int*)p - 1); + free ((int*)p - 1); } -static void *fdi_malloc (int size) +static void *fdi_malloc (int size) { - void *p = xmalloc (size + sizeof (int)); + void *p = xmalloc (size + sizeof (int)); ((int*)p)[0] = size; fdi_allocated += size; - write_log ("%d allocated (%d)\n", size, fdi_allocated); + write_log ("%d allocated (%d)\n", size, fdi_allocated); return (int*)p + 1; } #else -#define fdi_free free -#define fdi_malloc xmalloc +#define fdi_free free +#define fdi_malloc xmalloc #endif -#define MAX_SRC_BUFFER 4194304 -#define MAX_DST_BUFFER 40000 -#define MAX_MFM_SYNC_BUFFER 60000 -#define MAX_TIMING_BUFFER 400000 -#define MAX_TRACKS 166 -#define MAX_REVOLUTIONS 4 +#define MAX_SRC_BUFFER 4194304 +#define MAX_DST_BUFFER 40000 +#define MAX_MFM_SYNC_BUFFER 60000 +#define MAX_TIMING_BUFFER 400000 +#define MAX_TRACKS 166 struct fdi_cache { - uae_u8 *cache_buffer[MAX_REVOLUTIONS]; - uae_u8 *cache_buffer_timing; - int length[MAX_REVOLUTIONS]; - int indexoffset; + uae_u32 *avgp, *minp, *maxp; + uae_u8 *idxp; + int avg_free, idx_free, min_free, max_free; + uae_u32 totalavg, pulses, maxidx, indexoffset; + int weakbits; + int lowlevel; }; struct fdi { @@ -127,11 +129,11 @@ struct fdi { int track_src_len; uae_u8 *track_dst_buffer; uae_u8 *track_dst; - uae_u16 *track_dst_buffer_timing; + uae_u16 *track_dst_buffer_timing; uae_u8 track_len; uae_u8 track_type; int current_track; - int last_track; + int last_track; int last_head; int rotation_speed; int bit_rate; @@ -147,41 +149,41 @@ struct fdi { /* sector described only */ int index_offset; int encoding_type; - /* bit handling */ + /* bit handling */ int nextdrop; struct fdi_cache cache[MAX_TRACKS]; }; -#define get_u32(x) ((((x)[0])<<24)|(((x)[1])<<16)|(((x)[2])<<8)|((x)[3])) -#define get_u24(x) ((((x)[0])<<16)|(((x)[1])<<8)|((x)[2])) +#define get_u32(x) ((((x)[0])<<24)|(((x)[1])<<16)|(((x)[2])<<8)|((x)[3])) +#define get_u24(x) ((((x)[0])<<16)|(((x)[1])<<8)|((x)[2])) STATIC_INLINE put_u32 (uae_u8 *d, uae_u32 v) { - d[0] = v >> 24; - d[1] = v >> 16; + d[0] = v >> 24; + d[1] = v >> 16; d[2] = v >> 8; d[3] = v; } struct node { - uae_u16 v; + uae_u16 v; struct node *left; struct node *right; }; -typedef struct node NODE; +typedef struct node NODE; static uae_u8 temp, temp2; -static uae_u8 *expand_tree (uae_u8 *stream, NODE *node) +static uae_u8 *expand_tree (uae_u8 *stream, NODE *node) { if (temp & temp2) { fdi_free (node->left); - node->left = 0; - fdi_free (node->right); + node->left = 0; + fdi_free (node->right); node->right = 0; temp2 >>= 1; if (!temp2) { temp = *stream++; - temp2 = 0x80; + temp2 = 0x80; } return stream; } else { @@ -189,13 +191,13 @@ static uae_u8 *expand_tree (uae_u8 *stream, NODE *node) temp2 >>= 1; if (!temp2) { temp = *stream++; - temp2 = 0x80; + temp2 = 0x80; } - node->left = fdi_malloc (sizeof (NODE)); + node->left = fdi_malloc (sizeof (NODE)); memset (node->left, 0, sizeof (NODE)); - stream_temp = expand_tree (stream, node->left); + stream_temp = expand_tree (stream, node->left); node->right = fdi_malloc (sizeof (NODE)); - memset (node->right, 0, sizeof (NODE)); + memset (node->right, 0, sizeof (NODE)); return expand_tree (stream_temp, node->right); } } @@ -203,19 +205,19 @@ static uae_u8 *expand_tree (uae_u8 *stream, NODE *node) static uae_u8 *values_tree8 (uae_u8 *stream, NODE *node) { if (node->left == 0) { - node->v = *stream++; + node->v = *stream++; return stream; } else { uae_u8 *stream_temp = values_tree8 (stream, node->left); - return values_tree8 (stream_temp, node->right); + return values_tree8 (stream_temp, node->right); } } static uae_u8 *values_tree16 (uae_u8 *stream, NODE *node) { if (node->left == 0) { - uae_u16 high_8_bits = (*stream++) << 8; - node->v = high_8_bits | (*stream++); + uae_u16 high_8_bits = (*stream++) << 8; + node->v = high_8_bits | (*stream++); return stream; } else { uae_u8 *stream_temp = values_tree16 (stream, node->left); @@ -234,53 +236,53 @@ static void free_nodes (NODE *node) static uae_u32 sign_extend16 (uae_u32 v) { - if (v & 0x8000) + if (v & 0x8000) v |= 0xffff0000; return v; } -static uae_u32 sign_extend8 (uae_u32 v) +static uae_u32 sign_extend8 (uae_u32 v) { - if (v & 0x80) + if (v & 0x80) v |= 0xffffff00; return v; } -static void fdi_decode (uae_u8 *stream, int size, uae_u8 *out) +static void fdi_decode (uae_u8 *stream, int size, uae_u8 *out) { int i; uae_u8 sign_extend, sixteen_bit, sub_stream_shift; NODE root; NODE *current_node; - memset (out, 0, size * 4); + memset (out, 0, size * 4); sub_stream_shift = 1; while (sub_stream_shift) { //sub-stream header decode - sign_extend = *stream++; + sign_extend = *stream++; sub_stream_shift = sign_extend & 0x7f; sign_extend &= 0x80; sixteen_bit = (*stream++) & 0x80; //huffman tree architecture decode temp = *stream++; - temp2 = 0x80; + temp2 = 0x80; stream = expand_tree (stream, &root); if (temp2 == 0x80) stream--; - //huffman output values decode + //huffman output values decode if (sixteen_bit) - stream = values_tree16 (stream, &root); + stream = values_tree16 (stream, &root); else stream = values_tree8 (stream, &root); //sub-stream data decode - temp2 = 0; - for (i = 0; i < size; i++) { - uae_u32 v; - uae_u8 decode = 1; + temp2 = 0; + for (i = 0; i < size; i++) { + uae_u32 v; + uae_u8 decode = 1; current_node = &root; while (decode) { if (current_node->left == 0) { @@ -288,7 +290,7 @@ static void fdi_decode (uae_u8 *stream, int size, uae_u8 *out) } else { temp2 >>= 1; if (!temp2) { - temp2 = 0x80; + temp2 = 0x80; temp = *stream++; } if (temp & temp2) @@ -297,18 +299,18 @@ static void fdi_decode (uae_u8 *stream, int size, uae_u8 *out) current_node = current_node->left; } } - v = ((uae_u32*)out)[i]; + v = ((uae_u32*)out)[i]; if (sign_extend) { if (sixteen_bit) - v |= sign_extend16 (current_node->v) << sub_stream_shift; + v |= sign_extend16 (current_node->v) << sub_stream_shift; else - v |= sign_extend8 (current_node->v) << sub_stream_shift; + v |= sign_extend8 (current_node->v) << sub_stream_shift; } else { - v |= current_node->v << sub_stream_shift; + v |= current_node->v << sub_stream_shift; } - ((uae_u32*)out)[i] = v; + ((uae_u32*)out)[i] = v; } - free_nodes (root.left); + free_nodes (root.left); free_nodes (root.right); } } @@ -317,99 +319,99 @@ static void fdi_decode (uae_u8 *stream, int size, uae_u8 *out) static int decode_raw_track (FDI *fdi) { int size = get_u32(fdi->track_src); - memcpy (fdi->track_dst, fdi->track_src, (size + 7) >> 3); - fdi->track_src += (size + 7) >> 3; + memcpy (fdi->track_dst, fdi->track_src, (size + 7) >> 3); + fdi->track_src += (size + 7) >> 3; return size; } /* unknown track */ -static void zxx (FDI *fdi) +static void zxx (FDI *fdi) { outlog ("track %d: unknown track type 0x%02.2X\n", fdi->current_track, fdi->track_type); // return -1; } -/* unsupported track */ -static void zyy (FDI *fdi) +/* unsupported track */ +static void zyy (FDI *fdi) { outlog ("track %d: unsupported track type 0x%02.2X\n", fdi->current_track, fdi->track_type); // return -1; } /* empty track */ -static void track_empty (FDI *fdi) +static void track_empty (FDI *fdi) { // return 0; } /* unknown sector described type */ -static void dxx (FDI *fdi) +static void dxx (FDI *fdi) { - outlog ("\ntrack %d: unknown sector described type 0x%02.2X\n", fdi->current_track, fdi->track_type); + outlog ("\ntrack %d: unknown sector described type 0x%02.2X\n", fdi->current_track, fdi->track_type); fdi->err = 1; } -/* unsupported sector described type */ -static void dyy (FDI *fdi) +/* unsupported sector described type */ +static void dyy (FDI *fdi) { - outlog ("\ntrack %d: unsupported sector described 0x%02.2X\n", fdi->current_track, fdi->track_type); + outlog ("\ntrack %d: unsupported sector described 0x%02.2X\n", fdi->current_track, fdi->track_type); fdi->err = 1; } -/* add position of mfm sync bit */ -static void add_mfm_sync_bit (FDI *fdi) +/* add position of mfm sync bit */ +static void add_mfm_sync_bit (FDI *fdi) { if (fdi->nextdrop) { - fdi->nextdrop = 0; - return; + fdi->nextdrop = 0; + return; } fdi->mfmsync_buffer[fdi->mfmsync_offset++] = fdi->out; - if (fdi->out == 0) { + if (fdi->out == 0) { outlog ("illegal position for mfm sync bit, offset=%d\n",fdi->out); fdi->err = 1; } - if (fdi->mfmsync_offset >= MAX_MFM_SYNC_BUFFER) { + if (fdi->mfmsync_offset >= MAX_MFM_SYNC_BUFFER) { fdi->mfmsync_offset = 0; - outlog ("mfmsync buffer overflow\n"); + outlog ("mfmsync buffer overflow\n"); fdi->err = 1; } fdi->out++; } -#define BIT_BYTEOFFSET ((fdi->out) >> 3) -#define BIT_BITOFFSET (7-((fdi->out)&7)) +#define BIT_BYTEOFFSET ((fdi->out) >> 3) +#define BIT_BITOFFSET (7-((fdi->out)&7)) /* add one bit */ -static void bit_add (FDI *fdi, int bit) +static void bit_add (FDI *fdi, int bit) { if (fdi->nextdrop) { - fdi->nextdrop = 0; - return; + fdi->nextdrop = 0; + return; } fdi->track_dst[BIT_BYTEOFFSET] &= ~(1 << BIT_BITOFFSET); if (bit) - fdi->track_dst[BIT_BYTEOFFSET] |= (1 << BIT_BITOFFSET); + fdi->track_dst[BIT_BYTEOFFSET] |= (1 << BIT_BITOFFSET); fdi->out++; - if (fdi->out >= MAX_DST_BUFFER * 8) { + if (fdi->out >= MAX_DST_BUFFER * 8) { outlog ("destination buffer overflow\n"); fdi->err = 1; fdi->out = 1; } } -/* add bit and mfm sync bit */ -static void bit_mfm_add (FDI *fdi, int bit) +/* add bit and mfm sync bit */ +static void bit_mfm_add (FDI *fdi, int bit) { - add_mfm_sync_bit (fdi); - bit_add (fdi, bit); + add_mfm_sync_bit (fdi); + bit_add (fdi, bit); } -/* remove following bit */ +/* remove following bit */ static void bit_drop_next (FDI *fdi) { if (fdi->nextdrop > 0) { outlog("multiple bit_drop_next() called"); - } else if (fdi->nextdrop < 0) { - fdi->nextdrop = 0; + } else if (fdi->nextdrop < 0) { + fdi->nextdrop = 0; debuglog(":DNN:"); - return; + return; } debuglog(":DN:"); - fdi->nextdrop = 1; + fdi->nextdrop = 1; } /* ignore next bit_drop_next() */ @@ -418,37 +420,37 @@ static void bit_dedrop (FDI *fdi) if (fdi->nextdrop) { outlog("bit_drop_next called before bit_dedrop"); } - fdi->nextdrop = -1; + fdi->nextdrop = -1; debuglog(":BDD:"); } -/* add one byte */ -static void byte_add (FDI *fdi, uae_u8 v) +/* add one byte */ +static void byte_add (FDI *fdi, uae_u8 v) { int i; for (i = 7; i >= 0; i--) - bit_add (fdi, v & (1 << i)); + bit_add (fdi, v & (1 << i)); } -/* add one word */ -static void word_add (FDI *fdi, uae_u16 v) +/* add one word */ +static void word_add (FDI *fdi, uae_u16 v) { byte_add (fdi, (uae_u8)(v >> 8)); byte_add (fdi, (uae_u8)v); } -/* add one byte and mfm encode it */ +/* add one byte and mfm encode it */ static void byte_mfm_add (FDI *fdi, uae_u8 v) { int i; for (i = 7; i >= 0; i--) bit_mfm_add (fdi, v & (1 << i)); } -/* add multiple bytes and mfm encode them */ -static void bytes_mfm_add (FDI *fdi, uae_u8 v, int len) +/* add multiple bytes and mfm encode them */ +static void bytes_mfm_add (FDI *fdi, uae_u8 v, int len) { int i; - for (i = 0; i < len; i++) byte_mfm_add (fdi, v); + for (i = 0; i < len; i++) byte_mfm_add (fdi, v); } -/* add one mfm encoded word and re-mfm encode it */ +/* add one mfm encoded word and re-mfm encode it */ static void word_post_mfm_add (FDI *fdi, uae_u16 v) { int i; @@ -457,32 +459,32 @@ static void word_post_mfm_add (FDI *fdi, uae_u16 v) } /* bit 0 */ -static void s00(FDI *fdi) { bit_add (fdi, 0); } +static void s00(FDI *fdi) { bit_add (fdi, 0); } /* bit 1*/ -static void s01(FDI *fdi) { bit_add (fdi, 1); } -/* 4489 */ +static void s01(FDI *fdi) { bit_add (fdi, 1); } +/* 4489 */ static void s02(FDI *fdi) { word_add (fdi, 0x4489); } -/* 5224 */ +/* 5224 */ static void s03(FDI *fdi) { word_add (fdi, 0x5224); } -/* mfm sync bit */ +/* mfm sync bit */ static void s04(FDI *fdi) { add_mfm_sync_bit (fdi); } -/* RLE MFM-encoded data */ +/* RLE MFM-encoded data */ static void s08(FDI *fdi) { int bytes = *fdi->track_src++; uae_u8 byte = *fdi->track_src++; - if (bytes == 0) bytes = 256; - debuglog ("s08:len=%d,data=%02.2X",bytes,byte); - while(bytes--) byte_add (fdi, byte); + if (bytes == 0) bytes = 256; + debuglog ("s08:len=%d,data=%02.2X",bytes,byte); + while(bytes--) byte_add (fdi, byte); } -/* RLE MFM-decoded data */ +/* RLE MFM-decoded data */ static void s09(FDI *fdi) { int bytes = *fdi->track_src++; uae_u8 byte = *fdi->track_src++; - if (bytes == 0) bytes = 256; + if (bytes == 0) bytes = 256; bit_drop_next (fdi); - debuglog ("s09:len=%d,data=%02.2X",bytes,byte); + debuglog ("s09:len=%d,data=%02.2X",bytes,byte); while(bytes--) byte_mfm_add (fdi, byte); } /* MFM-encoded data */ @@ -494,13 +496,13 @@ static void s0a(FDI *fdi) debuglog ("s0a:bits=%d,data=%s", bits, datalog(fdi->track_src, (bits + 7) / 8)); while (bits >= 8) { byte_add (fdi, *fdi->track_src++); - bits -= 8; + bits -= 8; } - if (bits > 0) { + if (bits > 0) { i = 7; b = *fdi->track_src++; while (bits--) { - bit_add (fdi, b & (1 << i)); + bit_add (fdi, b & (1 << i)); i--; } } @@ -508,19 +510,19 @@ static void s0a(FDI *fdi) /* MFM-encoded data */ static void s0b(FDI *fdi) { - int i, bits = ((fdi->track_src[0] << 8) | fdi->track_src[1]) + 65536; + int i, bits = ((fdi->track_src[0] << 8) | fdi->track_src[1]) + 65536; uae_u8 b; fdi->track_src += 2; debuglog ("s0b:bits=%d,data=%s", bits, datalog(fdi->track_src, (bits + 7) / 8)); while (bits >= 8) { byte_add (fdi, *fdi->track_src++); - bits -= 8; + bits -= 8; } - if (bits > 0) { + if (bits > 0) { i = 7; b = *fdi->track_src++; while (bits--) { - bit_add (fdi, b & (1 << i)); + bit_add (fdi, b & (1 << i)); i--; } } @@ -535,12 +537,12 @@ static void s0c(FDI *fdi) debuglog ("s0c:bits=%d,data=%s", bits, datalog(fdi->track_src, (bits + 7) / 8)); while (bits >= 8) { byte_mfm_add (fdi, *fdi->track_src++); - bits -= 8; + bits -= 8; } - if (bits > 0) { + if (bits > 0) { i = 7; b = *fdi->track_src++; - while(bits--) { + while(bits--) { bit_mfm_add (fdi, b & (1 << i)); i--; } @@ -549,19 +551,19 @@ static void s0c(FDI *fdi) /* MFM-decoded data */ static void s0d(FDI *fdi) { - int i, bits = ((fdi->track_src[0] << 8) | fdi->track_src[1]) + 65536; + int i, bits = ((fdi->track_src[0] << 8) | fdi->track_src[1]) + 65536; uae_u8 b; fdi->track_src += 2; bit_drop_next (fdi); debuglog ("s0d:bits=%d,data=%s", bits, datalog(fdi->track_src, (bits + 7) / 8)); while (bits >= 8) { byte_mfm_add (fdi, *fdi->track_src++); - bits -= 8; + bits -= 8; } - if (bits > 0) { + if (bits > 0) { i = 7; b = *fdi->track_src++; - while(bits--) { + while(bits--) { bit_mfm_add (fdi, b & (1 << i)); i--; } @@ -572,15 +574,15 @@ static void s0d(FDI *fdi) /* AMIGA */ /* ***** */ -/* just for testing integrity of Amiga sectors */ +/* just for testing integrity of Amiga sectors */ -static void rotateonebit (uae_u8 *start, uae_u8 *end, int shift) +static void rotateonebit (uae_u8 *start, uae_u8 *end, int shift) { - if (shift == 0) - return; - while (start <= end) { + if (shift == 0) + return; + while (start <= end) { start[0] <<= shift; - start[0] |= start[1] >> (8 - shift); + start[0] |= start[1] >> (8 - shift); start++; } } @@ -588,9 +590,9 @@ static void rotateonebit (uae_u8 *start, uae_u8 *end, int shift) static int check_offset; static uae_u16 getmfmword (uae_u8 *mbuf) { - uae_u32 v; + uae_u32 v; - v = (mbuf[0] << 8) | (mbuf[1] << 0); + v = (mbuf[0] << 8) | (mbuf[1] << 0); if (check_offset == 0) return v; v <<= 8; @@ -599,19 +601,19 @@ static uae_u16 getmfmword (uae_u8 *mbuf) return v; } -#define MFMMASK 0x55555555 +#define MFMMASK 0x55555555 static uae_u32 getmfmlong (uae_u8 * mbuf) { return ((getmfmword (mbuf) << 16) | getmfmword (mbuf + 2)) & MFMMASK; } -static int amiga_check_track (FDI *fdi) +static int amiga_check_track (FDI *fdi) { int i, j, secwritten = 0; int fwlen = fdi->out / 8; - int length = 2 * fwlen; + int length = 2 * fwlen; int drvsec = 11; - uae_u32 odd, even, chksum, id, dlong; + uae_u32 odd, even, chksum, id, dlong; uae_u8 *secdata; uae_u8 secbuf[544]; uae_u8 bigmfmbuf[60000]; @@ -624,17 +626,17 @@ static int amiga_check_track (FDI *fdi) memset (bigmfmbuf, 0, sizeof (bigmfmbuf)); mbuf = bigmfmbuf; check_offset = 0; - for (i = 0; i < (fdi->out + 7) / 8; i++) - *mbuf++ = raw[i]; + for (i = 0; i < (fdi->out + 7) / 8; i++) + *mbuf++ = raw[i]; off = fdi->out & 7; #if 1 - if (off > 0) { - mbuf--; + if (off > 0) { + mbuf--; *mbuf &= ~((1 << (8 - off)) - 1); } j = 0; - while (i < (fdi->out + 7) / 8 + 600) { - *mbuf++ |= (raw[j] >> off) | ((raw[j + 1]) << (8 - off)); + while (i < (fdi->out + 7) / 8 + 600) { + *mbuf++ |= (raw[j] >> off) | ((raw[j + 1]) << (8 - off)); j++; i++; } @@ -642,9 +644,9 @@ static int amiga_check_track (FDI *fdi) mbuf = bigmfmbuf; memset (sectable, 0, sizeof (sectable)); - //memcpy (mbuf + fwlen, mbuf, fwlen * sizeof (uae_u16)); + //memcpy (mbuf + fwlen, mbuf, fwlen * sizeof (uae_u16)); mend = bigmfmbuf + length; - mend -= (4 + 16 + 8 + 512); + mend -= (4 + 16 + 8 + 512); while (secwritten < drvsec) { int trackoffs; @@ -653,175 +655,175 @@ static int amiga_check_track (FDI *fdi) rotateonebit (bigmfmbuf, mend, 1); if (getmfmword (mbuf) == 0) break; - if (secwritten == 10) { - mbuf[0] = 0x44; - mbuf[1] = 0x89; + if (secwritten == 10) { + mbuf[0] = 0x44; + mbuf[1] = 0x89; } -// check_offset++; - if (check_offset > 7) { +// check_offset++; + if (check_offset > 7) { check_offset = 0; - mbuf++; - if (mbuf >= mend || *mbuf == 0) + mbuf++; + if (mbuf >= mend || *mbuf == 0) break; } if (getmfmword (mbuf) == 0x4489) break; } - if (mbuf >= mend || *mbuf == 0) + if (mbuf >= mend || *mbuf == 0) break; rotateonebit (bigmfmbuf, mend, check_offset); check_offset = 0; - mbuf2 = mbuf; while (getmfmword (mbuf) == 0x4489) mbuf+= 1 * 2; + mbuf2 = mbuf + 8; odd = getmfmlong (mbuf); - even = getmfmlong (mbuf + 2 * 2); - mbuf += 4 * 2; - id = (odd << 1) | even; - - trackoffs = (id & 0xff00) >> 8; - if (trackoffs + 1 > drvsec) { - debuglog("illegal sector offset %d\n",trackoffs); - ok = 0; + even = getmfmlong (mbuf + 2 * 2); + mbuf += 4 * 2; + id = (odd << 1) | even; + + trackoffs = (id & 0xff00) >> 8; + if (trackoffs + 1 > drvsec) { + outlog("illegal sector offset %d\n",trackoffs); + ok = 0; mbuf = mbuf2; continue; } - if ((id >> 24) != 0xff) { - debuglog ("sector %d format type %02.2X?\n", trackoffs, id >> 24); - ok = 0; + if ((id >> 24) != 0xff) { + outlog ("sector %d format type %02.2X?\n", trackoffs, id >> 24); + ok = 0; } chksum = odd ^ even; slabel = 0; - for (i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { odd = getmfmlong (mbuf); - even = getmfmlong (mbuf + 8 * 2); - mbuf += 2* 2; + even = getmfmlong (mbuf + 8 * 2); + mbuf += 2* 2; - dlong = (odd << 1) | even; + dlong = (odd << 1) | even; if (dlong) slabel = 1; - chksum ^= odd ^ even; + chksum ^= odd ^ even; } - mbuf += 8 * 2; + mbuf += 8 * 2; odd = getmfmlong (mbuf); - even = getmfmlong (mbuf + 2 * 2); - mbuf += 4 * 2; - if (((odd << 1) | even) != chksum) { - debuglog("sector %d header crc error\n", trackoffs); - ok = 0; + even = getmfmlong (mbuf + 2 * 2); + mbuf += 4 * 2; + if (((odd << 1) | even) != chksum) { + outlog("sector %d header crc error\n", trackoffs); + ok = 0; mbuf = mbuf2; continue; } - debuglog("sector %d header crc ok\n", trackoffs); - if (((id & 0x00ff0000) >> 16) != (uae_u32)fdi->current_track) { - debuglog("illegal track number %d <> %d\n",fdi->current_track,(id & 0x00ff0000) >> 16); + outlog("sector %d header crc ok\n", trackoffs); + if (((id & 0x00ff0000) >> 16) != (uae_u32)fdi->current_track) { + outlog("illegal track number %d <> %d\n",fdi->current_track,(id & 0x00ff0000) >> 16); ok++; mbuf = mbuf2; continue; } odd = getmfmlong (mbuf); - even = getmfmlong (mbuf + 2 * 2); - mbuf += 4 * 2; + even = getmfmlong (mbuf + 2 * 2); + mbuf += 4 * 2; chksum = (odd << 1) | even; - secdata = secbuf + 32; - for (i = 0; i < 128; i++) { + secdata = secbuf + 32; + for (i = 0; i < 128; i++) { odd = getmfmlong (mbuf); - even = getmfmlong (mbuf + 256 * 2); - mbuf += 2 * 2; - dlong = (odd << 1) | even; - *secdata++ = (uae_u8) (dlong >> 24); - *secdata++ = (uae_u8) (dlong >> 16); - *secdata++ = (uae_u8) (dlong >> 8); + even = getmfmlong (mbuf + 256 * 2); + mbuf += 2 * 2; + dlong = (odd << 1) | even; + *secdata++ = (uae_u8) (dlong >> 24); + *secdata++ = (uae_u8) (dlong >> 16); + *secdata++ = (uae_u8) (dlong >> 8); *secdata++ = (uae_u8) dlong; - chksum ^= odd ^ even; + chksum ^= odd ^ even; } - mbuf += 256 * 2; + mbuf += 256 * 2; if (chksum) { - debuglog("sector %d data checksum error\n",trackoffs); - ok = 0; - } else if (sectable[trackoffs]) { - debuglog("sector %d already found?\n", trackoffs); + outlog("sector %d data checksum error\n",trackoffs); + ok = 0; + } else if (sectable[trackoffs]) { + outlog("sector %d already found?\n", trackoffs); mbuf = mbuf2; } else { - debuglog("sector %d ok\n",trackoffs); - if (slabel) debuglog("(non-empty sector header)\n"); + outlog("sector %d ok\n",trackoffs); + if (slabel) outlog("(non-empty sector header)\n"); sectable[trackoffs] = 1; secwritten++; if (trackoffs == 9) - mbuf += 0x228; + mbuf += 0x228; } } - for (i = 0; i < drvsec; i++) { + for (i = 0; i < drvsec; i++) { if (!sectable[i]) { - debuglog ("sector %d missing\n", i); - ok = 0; + outlog ("sector %d missing\n", i); + ok = 0; } } return ok; } -static void amiga_data_raw (FDI *fdi, uae_u8 *secbuf, uae_u8 *crc, int len) +static void amiga_data_raw (FDI *fdi, uae_u8 *secbuf, uae_u8 *crc, int len) { int i; uae_u8 crcbuf[4]; if (!crc) { - memset (crcbuf, 0, 4); + memset (crcbuf, 0, 4); } else { - memcpy (crcbuf, crc ,4); + memcpy (crcbuf, crc ,4); } - for (i = 0; i < 4; i++) + for (i = 0; i < 4; i++) byte_mfm_add (fdi, crcbuf[i]); - for (i = 0; i < len; i++) + for (i = 0; i < len; i++) byte_mfm_add (fdi, secbuf[i]); } static void amiga_data (FDI *fdi, uae_u8 *secbuf) { - uae_u16 mfmbuf[4 + 512]; - uae_u32 dodd, deven, dck; + uae_u16 mfmbuf[4 + 512]; + uae_u32 dodd, deven, dck; int i; - for (i = 0; i < 512; i += 4) { - deven = ((secbuf[i + 0] << 24) | (secbuf[i + 1] << 16) - | (secbuf[i + 2] << 8) | (secbuf[i + 3])); - dodd = deven >> 1; + for (i = 0; i < 512; i += 4) { + deven = ((secbuf[i + 0] << 24) | (secbuf[i + 1] << 16) + | (secbuf[i + 2] << 8) | (secbuf[i + 3])); + dodd = deven >> 1; deven &= 0x55555555; - dodd &= 0x55555555; - mfmbuf[(i >> 1) + 4] = (uae_u16) (dodd >> 16); - mfmbuf[(i >> 1) + 5] = (uae_u16) dodd; - mfmbuf[(i >> 1) + 256 + 4] = (uae_u16) (deven >> 16); - mfmbuf[(i >> 1) + 256 + 5] = (uae_u16) deven; + dodd &= 0x55555555; + mfmbuf[(i >> 1) + 4] = (uae_u16) (dodd >> 16); + mfmbuf[(i >> 1) + 5] = (uae_u16) dodd; + mfmbuf[(i >> 1) + 256 + 4] = (uae_u16) (deven >> 16); + mfmbuf[(i >> 1) + 256 + 5] = (uae_u16) deven; } dck = 0; - for (i = 4; i < 4 + 512; i += 2) + for (i = 4; i < 4 + 512; i += 2) dck ^= (mfmbuf[i] << 16) | mfmbuf[i + 1]; - deven = dodd = dck; + deven = dodd = dck; dodd >>= 1; deven &= 0x55555555; - dodd &= 0x55555555; + dodd &= 0x55555555; mfmbuf[0] = (uae_u16) (dodd >> 16); mfmbuf[1] = (uae_u16) dodd; - mfmbuf[2] = (uae_u16) (deven >> 16); + mfmbuf[2] = (uae_u16) (deven >> 16); mfmbuf[3] = (uae_u16) deven; - for (i = 0; i < 4 + 512; i ++) - word_post_mfm_add (fdi, mfmbuf[i]); + for (i = 0; i < 4 + 512; i ++) + word_post_mfm_add (fdi, mfmbuf[i]); } -static void amiga_sector_header (FDI *fdi, uae_u8 *header, uae_u8 *data, int sector, int untilgap) +static void amiga_sector_header (FDI *fdi, uae_u8 *header, uae_u8 *data, int sector, int untilgap) { uae_u8 headerbuf[4], databuf[16]; - uae_u32 deven, dodd, hck; - uae_u16 mfmbuf[24]; + uae_u32 deven, dodd, hck; + uae_u16 mfmbuf[24]; int i; byte_mfm_add (fdi, 0); byte_mfm_add (fdi, 0); - word_add (fdi, 0x4489); - word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); if (header) { memcpy (headerbuf, header, 4); } else { @@ -835,47 +837,47 @@ static void amiga_sector_header (FDI *fdi, uae_u8 *header, uae_u8 *data, int sec else memset (databuf, 0, 16); - deven = ((headerbuf[0] << 24) | (headerbuf[1] << 16) - | (headerbuf[2] << 8) | (headerbuf[3])); - dodd = deven >> 1; + deven = ((headerbuf[0] << 24) | (headerbuf[1] << 16) + | (headerbuf[2] << 8) | (headerbuf[3])); + dodd = deven >> 1; deven &= 0x55555555; - dodd &= 0x55555555; + dodd &= 0x55555555; mfmbuf[0] = (uae_u16) (dodd >> 16); mfmbuf[1] = (uae_u16) dodd; - mfmbuf[2] = (uae_u16) (deven >> 16); + mfmbuf[2] = (uae_u16) (deven >> 16); mfmbuf[3] = (uae_u16) deven; - for (i = 0; i < 16; i += 4) { - deven = ((databuf[i] << 24) | (databuf[i + 1] << 16) - | (databuf[i + 2] << 8) | (databuf[i + 3])); - dodd = deven >> 1; + for (i = 0; i < 16; i += 4) { + deven = ((databuf[i] << 24) | (databuf[i + 1] << 16) + | (databuf[i + 2] << 8) | (databuf[i + 3])); + dodd = deven >> 1; deven &= 0x55555555; - dodd &= 0x55555555; - mfmbuf[(i >> 1) + 0 + 4] = (uae_u16) (dodd >> 16); - mfmbuf[(i >> 1) + 0 + 5] = (uae_u16) dodd; - mfmbuf[(i >> 1) + 8 + 4] = (uae_u16) (deven >> 16); - mfmbuf[(i >> 1) + 8 + 5] = (uae_u16) deven; + dodd &= 0x55555555; + mfmbuf[(i >> 1) + 0 + 4] = (uae_u16) (dodd >> 16); + mfmbuf[(i >> 1) + 0 + 5] = (uae_u16) dodd; + mfmbuf[(i >> 1) + 8 + 4] = (uae_u16) (deven >> 16); + mfmbuf[(i >> 1) + 8 + 5] = (uae_u16) deven; } hck = 0; - for (i = 0; i < 4 + 16; i += 2) + for (i = 0; i < 4 + 16; i += 2) hck ^= (mfmbuf[i] << 16) | mfmbuf[i + 1]; - deven = dodd = hck; + deven = dodd = hck; dodd >>= 1; deven &= 0x55555555; - dodd &= 0x55555555; - mfmbuf[20] = (uae_u16) (dodd >> 16); + dodd &= 0x55555555; + mfmbuf[20] = (uae_u16) (dodd >> 16); mfmbuf[21] = (uae_u16) dodd; mfmbuf[22] = (uae_u16) (deven >> 16); mfmbuf[23] = (uae_u16) deven; - for (i = 0; i < 4 + 16 + 4; i ++) - word_post_mfm_add (fdi, mfmbuf[i]); + for (i = 0; i < 4 + 16 + 4; i ++) + word_post_mfm_add (fdi, mfmbuf[i]); } -/* standard super-extended Amiga sector header */ +/* standard super-extended Amiga sector header */ static void s20(FDI *fdi) { bit_drop_next (fdi); - debuglog ("s20:header=%s,data=%s", datalog(fdi->track_src, 4), datalog(fdi->track_src + 4, 16)); + debuglog ("s20:header=%s,data=%s", datalog(fdi->track_src, 4), datalog(fdi->track_src + 4, 16)); amiga_sector_header (fdi, fdi->track_src, fdi->track_src + 4, 0, 0); fdi->track_src += 4 + 16; } @@ -883,54 +885,54 @@ static void s20(FDI *fdi) static void s21(FDI *fdi) { bit_drop_next (fdi); - debuglog ("s21:header=%s", datalog(fdi->track_src, 4)); - amiga_sector_header (fdi, fdi->track_src, 0, 0, 0); + debuglog ("s21:header=%s", datalog(fdi->track_src, 4)); + amiga_sector_header (fdi, fdi->track_src, 0, 0, 0); fdi->track_src += 4; } -/* standard Amiga sector header */ +/* standard Amiga sector header */ static void s22(FDI *fdi) { bit_drop_next (fdi); debuglog("s22:sector=%d,untilgap=%d", fdi->track_src[0], fdi->track_src[1]); - amiga_sector_header (fdi, 0, 0, fdi->track_src[0], fdi->track_src[1]); + amiga_sector_header (fdi, 0, 0, fdi->track_src[0], fdi->track_src[1]); fdi->track_src += 2; } -/* standard 512-byte, CRC-correct Amiga data */ +/* standard 512-byte, CRC-correct Amiga data */ static void s23(FDI *fdi) { - debuglog("s23:data=%s", datalog (fdi->track_src, 512)); + debuglog("s23:data=%s", datalog (fdi->track_src, 512)); amiga_data (fdi, fdi->track_src); fdi->track_src += 512; } -/* not-decoded, 128*2^x-byte, CRC-correct Amiga data */ +/* not-decoded, 128*2^x-byte, CRC-correct Amiga data */ static void s24(FDI *fdi) { int shift = *fdi->track_src++; - debuglog("s24:shift=%d,data=%s", shift, datalog (fdi->track_src, 128 << shift)); - amiga_data_raw (fdi, fdi->track_src, 0, 128 << shift); - fdi->track_src += 128 << shift; + debuglog("s24:shift=%d,data=%s", shift, datalog (fdi->track_src, 128 << shift)); + amiga_data_raw (fdi, fdi->track_src, 0, 128 << shift); + fdi->track_src += 128 << shift; } -/* not-decoded, 128*2^x-byte, CRC-incorrect Amiga data */ +/* not-decoded, 128*2^x-byte, CRC-incorrect Amiga data */ static void s25(FDI *fdi) { int shift = *fdi->track_src++; - debuglog("s25:shift=%d,crc=%s,data=%s", shift, datalog (fdi->track_src, 4), datalog (fdi->track_src + 4, 128 << shift)); - amiga_data_raw (fdi, fdi->track_src + 4, fdi->track_src, 128 << shift); + debuglog("s25:shift=%d,crc=%s,data=%s", shift, datalog (fdi->track_src, 4), datalog (fdi->track_src + 4, 128 << shift)); + amiga_data_raw (fdi, fdi->track_src + 4, fdi->track_src, 128 << shift); fdi->track_src += 4 + (128 << shift); } /* standard extended Amiga sector */ static void s26(FDI *fdi) { s21 (fdi); - debuglog("s26:data=%s", datalog (fdi->track_src, 512)); + debuglog("s26:data=%s", datalog (fdi->track_src, 512)); amiga_data (fdi, fdi->track_src); fdi->track_src += 512; } -/* standard short Amiga sector */ +/* standard short Amiga sector */ static void s27(FDI *fdi) { s22 (fdi); - debuglog("s27:data=%s", datalog (fdi->track_src, 512)); + debuglog("s27:data=%s", datalog (fdi->track_src, 512)); amiga_data (fdi, fdi->track_src); fdi->track_src += 512; } @@ -939,37 +941,37 @@ static void s27(FDI *fdi) /* IBM */ /* *** */ -static uae_u16 ibm_crc (uae_u8 byte, int reset) +static uae_u16 ibm_crc (uae_u8 byte, int reset) { static uae_u16 crc; int i; if (reset) crc = 0xcdb4; - for (i = 0; i < 8; i++) { - if (crc & 0x8000) { - crc <<= 1; - if (!(byte & 0x80)) crc ^= 0x1021; + for (i = 0; i < 8; i++) { + if (crc & 0x8000) { + crc <<= 1; + if (!(byte & 0x80)) crc ^= 0x1021; } else { - crc <<= 1; - if (byte & 0x80) crc ^= 0x1021; + crc <<= 1; + if (byte & 0x80) crc ^= 0x1021; } byte <<= 1; } return crc; } -static void ibm_data (FDI *fdi, uae_u8 *data, uae_u8 *crc, int len) +static void ibm_data (FDI *fdi, uae_u8 *data, uae_u8 *crc, int len) { int i; uae_u8 crcbuf[2]; - uae_u16 crcv; + uae_u16 crcv; - word_add (fdi, 0x4489); - word_add (fdi, 0x4489); - word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); byte_mfm_add (fdi, 0xfb); - ibm_crc (0xfb, 1); - for (i = 0; i < len; i++) { + ibm_crc (0xfb, 1); + for (i = 0; i < len; i++) { byte_mfm_add (fdi, data[i]); crcv = ibm_crc (data[i], 0); } @@ -982,18 +984,18 @@ static void ibm_data (FDI *fdi, uae_u8 *data, uae_u8 *crc, int len) byte_mfm_add (fdi, crc[1]); } -static void ibm_sector_header (FDI *fdi, uae_u8 *data, uae_u8 *crc, int secnum, int pre) +static void ibm_sector_header (FDI *fdi, uae_u8 *data, uae_u8 *crc, int secnum, int pre) { uae_u8 secbuf[5]; uae_u8 crcbuf[2]; - uae_u16 crcv; + uae_u16 crcv; int i; if (pre) bytes_mfm_add (fdi, 0, 12); - word_add (fdi, 0x4489); - word_add (fdi, 0x4489); - word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); secbuf[0] = 0xfe; if (secnum >= 0) { secbuf[1] = (uae_u8)(fdi->current_track/2); @@ -1003,18 +1005,18 @@ static void ibm_sector_header (FDI *fdi, uae_u8 *data, uae_u8 *crc, int secnum, } else { memcpy (secbuf + 1, data, 4); } - ibm_crc (secbuf[0], 1); - ibm_crc (secbuf[1], 0); - ibm_crc (secbuf[2], 0); - ibm_crc (secbuf[3], 0); + ibm_crc (secbuf[0], 1); + ibm_crc (secbuf[1], 0); + ibm_crc (secbuf[2], 0); + ibm_crc (secbuf[3], 0); crcv = ibm_crc (secbuf[4], 0); if (crc) { - memcpy (crcbuf, crc, 2); + memcpy (crcbuf, crc, 2); } else { crcbuf[0] = (uae_u8)(crcv >> 8); crcbuf[1] = (uae_u8)crcv; } - /* data */ + /* data */ for (i = 0;i < 5; i++) byte_mfm_add (fdi, secbuf[i]); /* crc */ @@ -1022,17 +1024,17 @@ static void ibm_sector_header (FDI *fdi, uae_u8 *data, uae_u8 *crc, int secnum, byte_mfm_add (fdi, crcbuf[1]); } -/* standard IBM index address mark */ +/* standard IBM index address mark */ static void s10(FDI *fdi) { bit_drop_next (fdi); bytes_mfm_add (fdi, 0, 12); - word_add (fdi, 0x5224); - word_add (fdi, 0x5224); - word_add (fdi, 0x5224); + word_add (fdi, 0x5224); + word_add (fdi, 0x5224); + word_add (fdi, 0x5224); byte_mfm_add (fdi, 0xfc); } -/* standard IBM pre-gap */ +/* standard IBM pre-gap */ static void s11(FDI *fdi) { bit_drop_next (fdi); @@ -1047,19 +1049,19 @@ static void s12(FDI *fdi) bit_drop_next (fdi); bytes_mfm_add (fdi, 0x4e, 78); } -/* standard extended IBM sector header */ +/* standard extended IBM sector header */ static void s13(FDI *fdi) { bit_drop_next (fdi); debuglog ("s13:header=%s", datalog (fdi->track_src, 4)); - ibm_sector_header (fdi, fdi->track_src, 0, -1, 1); + ibm_sector_header (fdi, fdi->track_src, 0, -1, 1); fdi->track_src += 4; } /* standard mini-extended IBM sector header */ static void s14(FDI *fdi) { debuglog ("s14:header=%s", datalog (fdi->track_src, 4)); - ibm_sector_header (fdi, fdi->track_src, 0, -1, 0); + ibm_sector_header (fdi, fdi->track_src, 0, -1, 0); fdi->track_src += 4; } /* standard short IBM sector header */ @@ -1067,33 +1069,33 @@ static void s15(FDI *fdi) { bit_drop_next (fdi); debuglog ("s15:sector=%d", *fdi->track_src); - ibm_sector_header (fdi, 0, 0, *fdi->track_src++, 1); + ibm_sector_header (fdi, 0, 0, *fdi->track_src++, 1); } /* standard mini-short IBM sector header */ static void s16(FDI *fdi) { debuglog ("s16:track=%d", *fdi->track_src); - ibm_sector_header (fdi, 0, 0, *fdi->track_src++, 0); + ibm_sector_header (fdi, 0, 0, *fdi->track_src++, 0); } -/* standard CRC-incorrect mini-extended IBM sector header */ +/* standard CRC-incorrect mini-extended IBM sector header */ static void s17(FDI *fdi) { debuglog ("s17:header=%s,crc=%s", datalog (fdi->track_src, 4), datalog (fdi->track_src + 4, 2)); - ibm_sector_header (fdi, fdi->track_src, fdi->track_src + 4, -1, 0); + ibm_sector_header (fdi, fdi->track_src, fdi->track_src + 4, -1, 0); fdi->track_src += 4 + 2; } -/* standard CRC-incorrect mini-short IBM sector header */ +/* standard CRC-incorrect mini-short IBM sector header */ static void s18(FDI *fdi) { - debuglog ("s18:sector=%d,header=%s", *fdi->track_src, datalog (fdi->track_src + 1, 4)); - ibm_sector_header (fdi, 0, fdi->track_src + 1, *fdi->track_src, 0); + debuglog ("s18:sector=%d,header=%s", *fdi->track_src, datalog (fdi->track_src + 1, 4)); + ibm_sector_header (fdi, 0, fdi->track_src + 1, *fdi->track_src, 0); fdi->track_src += 1 + 4; } /* standard 512-byte CRC-correct IBM data */ static void s19(FDI *fdi) { debuglog ("s19:data=%s", datalog (fdi->track_src , 512)); - ibm_data (fdi, fdi->track_src, 0, 512); + ibm_data (fdi, fdi->track_src, 0, 512); fdi->track_src += 512; } /* standard 128*2^x-byte-byte CRC-correct IBM data */ @@ -1102,17 +1104,17 @@ static void s1a(FDI *fdi) int shift = *fdi->track_src++; debuglog ("s1a:shift=%d,data=%s", shift, datalog (fdi->track_src , 128 << shift)); ibm_data (fdi, fdi->track_src, 0, 128 << shift); - fdi->track_src += 128 << shift; + fdi->track_src += 128 << shift; } -/* standard 128*2^x-byte-byte CRC-incorrect IBM data */ +/* standard 128*2^x-byte-byte CRC-incorrect IBM data */ static void s1b(FDI *fdi) { int shift = *fdi->track_src++; - debuglog ("s1b:shift=%d,crc=%s,data=%s", shift, datalog (fdi->track_src + (128 << shift), 2), datalog (fdi->track_src , 128 << shift)); - ibm_data (fdi, fdi->track_src, fdi->track_src + (128 << shift), 128 << shift); + debuglog ("s1b:shift=%d,crc=%s,data=%s", shift, datalog (fdi->track_src + (128 << shift), 2), datalog (fdi->track_src , 128 << shift)); + ibm_data (fdi, fdi->track_src, fdi->track_src + (128 << shift), 128 << shift); fdi->track_src += (128 << shift) + 2; } -/* standard extended IBM sector */ +/* standard extended IBM sector */ static void s1c(FDI *fdi) { int shift = fdi->track_src[3]; @@ -1120,9 +1122,9 @@ static void s1c(FDI *fdi) bytes_mfm_add (fdi, 0x4e, 22); bytes_mfm_add (fdi, 0x00, 12); ibm_data (fdi, fdi->track_src, 0, 128 << shift); - fdi->track_src += 128 << shift; + fdi->track_src += 128 << shift; } -/* standard short IBM sector */ +/* standard short IBM sector */ static void s1d(FDI *fdi) { s15 (fdi); @@ -1136,7 +1138,7 @@ static void sff(FDI *fdi) { } -typedef void (*decode_described_track_func)(FDI*); +typedef void (*decode_described_track_func)(FDI*); static decode_described_track_func decode_sectors_described_track[] = { @@ -1155,22 +1157,22 @@ static decode_described_track_func decode_sectors_described_track[] = dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* C0-CF */ dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* D0-DF */ dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* E0-EF */ - dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,sff /* F0-FF */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,sff /* F0-FF */ }; -static void track_amiga (struct fdi *fdi, int first_sector, int max_sector) +static void track_amiga (struct fdi *fdi, int first_sector, int max_sector) { int i; - bit_add (fdi, 0); + bit_add (fdi, 0); bit_drop_next (fdi); - for (i = 0; i < max_sector; i++) { - amiga_sector_header (fdi, 0, 0, first_sector, max_sector - i); - amiga_data (fdi, fdi->track_src + first_sector * 512); - first_sector++; - if (first_sector >= max_sector) first_sector = 0; + for (i = 0; i < max_sector; i++) { + amiga_sector_header (fdi, 0, 0, first_sector, max_sector - i); + amiga_data (fdi, fdi->track_src + first_sector * 512); + first_sector++; + if (first_sector >= max_sector) first_sector = 0; } - bytes_mfm_add (fdi, 0, 260); /* gap */ + bytes_mfm_add (fdi, 0, 260); /* gap */ } static void track_atari_st (struct fdi *fdi, int max_sector) { @@ -1179,7 +1181,7 @@ static void track_atari_st (struct fdi *fdi, int max_sector) switch (max_sector) { - case 9: + case 9: gap3 = 40; break; case 10: @@ -1187,15 +1189,15 @@ static void track_atari_st (struct fdi *fdi, int max_sector) break; } s15 (fdi); - for (i = 0; i < max_sector; i++) { + for (i = 0; i < max_sector; i++) { byte_mfm_add (fdi, 0x4e); byte_mfm_add (fdi, 0x4e); - ibm_sector_header (fdi, 0, 0, fdi->current_track, 1); + ibm_sector_header (fdi, 0, 0, fdi->current_track, 1); ibm_data (fdi, p + i * 512, 0, 512); bytes_mfm_add (fdi, 0x4e, gap3); } - bytes_mfm_add (fdi, 0x4e, 660 - gap3); - fdi->track_src += fdi->track_len * 256; + bytes_mfm_add (fdi, 0x4e, 660 - gap3); + fdi->track_src += fdi->track_len * 256; } static void track_pc (struct fdi *fdi, int max_sector) { @@ -1204,26 +1206,26 @@ static void track_pc (struct fdi *fdi, int max_sector) switch (max_sector) { - case 8: + case 8: gap3 = 116; break; - case 9: + case 9: gap3 = 54; break; default: - gap3 = 100; /* fixme */ + gap3 = 100; /* fixme */ break; } s11 (fdi); - for (i = 0; i < max_sector; i++) { + for (i = 0; i < max_sector; i++) { byte_mfm_add (fdi, 0x4e); byte_mfm_add (fdi, 0x4e); - ibm_sector_header (fdi, 0, 0, fdi->current_track, 1); + ibm_sector_header (fdi, 0, 0, fdi->current_track, 1); ibm_data (fdi, p + i * 512, 0, 512); bytes_mfm_add (fdi, 0x4e, gap3); } - bytes_mfm_add (fdi, 0x4e, 600 - gap3); - fdi->track_src += fdi->track_len * 256; + bytes_mfm_add (fdi, 0x4e, 600 - gap3); + fdi->track_src += fdi->track_len * 256; } /* amiga dd */ @@ -1240,69 +1242,69 @@ static void track_amiga_hd (struct fdi *fdi) track_amiga (fdi, 0, 22); fdi->track_src = p + fdi->track_len * 256; } -/* atari st 9 sector */ +/* atari st 9 sector */ static void track_atari_st_9 (struct fdi *fdi) { track_atari_st (fdi, 9); } /* atari st 10 sector */ -static void track_atari_st_10 (struct fdi *fdi) +static void track_atari_st_10 (struct fdi *fdi) { track_atari_st (fdi, 10); } -/* pc 8 sector */ +/* pc 8 sector */ static void track_pc_8 (struct fdi *fdi) { track_pc (fdi, 8); } -/* pc 9 sector */ +/* pc 9 sector */ static void track_pc_9 (struct fdi *fdi) { track_pc (fdi, 9); } -/* pc 15 sector */ -static void track_pc_15 (struct fdi *fdi) +/* pc 15 sector */ +static void track_pc_15 (struct fdi *fdi) { track_pc (fdi, 15); } -/* pc 18 sector */ -static void track_pc_18 (struct fdi *fdi) +/* pc 18 sector */ +static void track_pc_18 (struct fdi *fdi) { track_pc (fdi, 18); } -/* pc 36 sector */ -static void track_pc_36 (struct fdi *fdi) +/* pc 36 sector */ +static void track_pc_36 (struct fdi *fdi) { track_pc (fdi, 36); } -typedef void (*decode_normal_track_func)(FDI*); +typedef void (*decode_normal_track_func)(FDI*); -static decode_normal_track_func decode_normal_track[] = +static decode_normal_track_func decode_normal_track[] = { - track_empty, /* 0 */ - track_amiga_dd, track_amiga_hd, /* 1-2 */ - track_atari_st_9, track_atari_st_10, /* 3-4 */ - track_pc_8, track_pc_9, track_pc_15, track_pc_18, track_pc_36, /* 5-9 */ + track_empty, /* 0 */ + track_amiga_dd, track_amiga_hd, /* 1-2 */ + track_atari_st_9, track_atari_st_10, /* 3-4 */ + track_pc_8, track_pc_9, track_pc_15, track_pc_18, track_pc_36, /* 5-9 */ zxx,zxx,zxx,zxx,zxx /* A-F */ }; static void fix_mfm_sync (FDI *fdi) { - int i, pos, off1, off2, off3, mask1, mask2, mask3; + int i, pos, off1, off2, off3, mask1, mask2, mask3; - for (i = 0; i < fdi->mfmsync_offset; i++) { + for (i = 0; i < fdi->mfmsync_offset; i++) { pos = fdi->mfmsync_buffer[i]; off1 = (pos - 1) >> 3; off2 = (pos + 1) >> 3; off3 = pos >> 3; - mask1 = 1 << (7 - ((pos - 1) & 7)); - mask2 = 1 << (7 - ((pos + 1) & 7)); - mask3 = 1 << (7 - (pos & 7)); - if (!(fdi->track_dst[off1] & mask1) && !(fdi->track_dst[off2] & mask2)) - fdi->track_dst[off3] |= mask3; + mask1 = 1 << (7 - ((pos - 1) & 7)); + mask2 = 1 << (7 - ((pos + 1) & 7)); + mask3 = 1 << (7 - (pos & 7)); + if (!(fdi->track_dst[off1] & mask1) && !(fdi->track_dst[off2] & mask2)) + fdi->track_dst[off3] |= mask3; else - fdi->track_dst[off3] &= ~mask3; + fdi->track_dst[off3] &= ~mask3; } } @@ -1310,28 +1312,28 @@ static int handle_sectors_described_track (FDI *fdi) { int oldout; uae_u8 *start_src = fdi->track_src ; - fdi->encoding_type = *fdi->track_src++; + fdi->encoding_type = *fdi->track_src++; fdi->index_offset = get_u32(fdi->track_src); fdi->index_offset >>= 8; fdi->track_src += 3; outlog ("sectors_described, index offset: %d\n",fdi->index_offset); do { - fdi->track_type = *fdi->track_src++; - outlog ("%06.6X %06.6X %02.2X:",fdi->track_src - start_src + 0x200, fdi->out/8, fdi->track_type); + fdi->track_type = *fdi->track_src++; + outlog ("%06.6X %06.6X %02.2X:",fdi->track_src - start_src + 0x200, fdi->out/8, fdi->track_type); oldout = fdi->out; decode_sectors_described_track[fdi->track_type](fdi); - outlog(" %d\n", fdi->out - oldout); + outlog(" %d\n", fdi->out - oldout); oldout = fdi->out; - if (fdi->out < 0 || fdi->err) { - outlog ("\nin %d bytes, out %d bits\n", fdi->track_src - fdi->track_src_buffer, fdi->out); + if (fdi->out < 0 || fdi->err) { + outlog ("\nin %d bytes, out %d bits\n", fdi->track_src - fdi->track_src_buffer, fdi->out); return -1; } if (fdi->track_src - fdi->track_src_buffer >= fdi->track_src_len) { - outlog ("source buffer overrun, previous type: %02.2X\n", fdi->track_type); + outlog ("source buffer overrun, previous type: %02.2X\n", fdi->track_type); return -1; } - } while (fdi->track_type != 0xff); + } while (fdi->track_type != 0xff); outlog("\n"); fix_mfm_sync (fdi); return fdi->out; @@ -1339,25 +1341,25 @@ static int handle_sectors_described_track (FDI *fdi) static uae_u8 *fdi_decompress (int pulses, uae_u8 *sizep, uae_u8 *src, int *dofree) { - uae_u32 size = get_u24 (sizep); - uae_u32 *dst2; - int len = size & 0x3fffff; + uae_u32 size = get_u24 (sizep); + uae_u32 *dst2; + int len = size & 0x3fffff; uae_u8 *dst; - int mode = size >> 22, i; + int mode = size >> 22, i; - *dofree = 0; - if (mode == 0 && pulses * 2 > len) + *dofree = 0; + if (mode == 0 && pulses * 2 > len) mode = 1; if (mode == 0) { dst2 = (uae_u32*)src; - for (i = 0; i < pulses; i++) { - *dst2++ = get_u32 (src); + dst = src; + for (i = 0; i < pulses; i++) { + *dst2++ = get_u32 (src); src += 4; } - dst = src; - } else if (mode == 1) { + } else if (mode == 1) { dst = fdi_malloc (pulses *4); - *dofree = 1; + *dofree = 1; fdi_decode (src, pulses, dst); } else { dst = 0; @@ -1367,13 +1369,15 @@ static uae_u8 *fdi_decompress (int pulses, uae_u8 *sizep, uae_u8 *src, int *dofr static void dumpstream(int track, uae_u8 *stream, int len) { +#if 0 char name[100]; FILE *f; sprintf (name, "track_%d.raw", track); - f = fopen(name, "wb"); - fwrite (stream, 1, len * 4, f); - fclose (f); + f = fopen(name, "wb"); + fwrite (stream, 1, len * 4, f); + fclose (f); +#endif } static int bitoffset; @@ -1382,7 +1386,7 @@ STATIC_INLINE void addbit (uae_u8 *p, int bit) { int off1 = bitoffset / 8; int off2 = bitoffset % 8; - p[off1] |= bit << (7 - off2); + p[off1] |= bit << (7 - off2); bitoffset++; } @@ -1392,121 +1396,429 @@ struct pulse_sample { int number_of_bits; }; -#define FDI_MAX_ARRAY 6 /* change this value as you want */ -static int pulse_limitval = 20; + +#define FDI_MAX_ARRAY 10 /* change this value as you want */ +static int pulse_limitval = 15; /* tolerance of 15% */ static struct pulse_sample psarray[FDI_MAX_ARRAY]; -static int array_index; -static unsigned long total; +static int array_index; +static unsigned long total; static int totaldiv; -static void init_array(unsigned long standard_MFM_2_bit_cell_size) +static void init_array(unsigned long standard_MFM_2_bit_cell_size, int nb_of_bits) { int i; - for (i = 0; i < FDI_MAX_ARRAY; i++) { - psarray[i].size = standard_MFM_2_bit_cell_size; // That is (total track length / 50000) for Amiga double density + for (i = 0; i < FDI_MAX_ARRAY; i++) { + psarray[i].size = standard_MFM_2_bit_cell_size; // That is (total track length / 50000) for Amiga double density total += psarray[i].size; - psarray[i].number_of_bits = 2; + psarray[i].number_of_bits = nb_of_bits; totaldiv += psarray[i].number_of_bits; } array_index = 0; } -static void fdi2_mfm_decode(FDI *fdi, unsigned long totalavg, uae_u32 *avgp, uae_u8 *idx, int idx_off1, int idx_off2, int idx_off3, int maxidx, int pulses) +#if 0 + +static void fdi2_decode (FDI *fdi, unsigned long totalavg, uae_u32 *avgp, uae_u32 *minp, uae_u32 *maxp, uae_u8 *idx, int maxidx, int *indexoffsetp, int pulses, int mfm) { unsigned long adjust; unsigned long adjusted_pulse; - unsigned long standard_MFM_2_bit_cell_size = totalavg / 50000; - int real_size, i, j; + unsigned long standard_MFM_2_bit_cell_size = totalavg / 50000; + unsigned long standard_MFM_8_bit_cell_size = totalavg / 12500; + int real_size, i, j, eodat, outstep; + int indexoffset = *indexoffsetp; uae_u8 *d = fdi->track_dst_buffer; - uae_u16 *pt = fdi->track_dst_buffer_timing; + uae_u16 *pt = fdi->track_dst_buffer_timing; + uae_u32 ref_pulse, pulse; + + /* detects a long-enough stable pulse coming just after another stable pulse */ + i = 1; + while ( (i < pulses) && ( (idx[i] < maxidx) + || (idx[i - 1] < maxidx) + || (avgp[i] < (standard_MFM_2_bit_cell_size - (standard_MFM_2_bit_cell_size / 4))) ) ) + i++; + if (i == pulses) { + outlog ("No stable and long-enough pulse in track.\n"); + return; + } + i--; + eodat = i; + adjust = 0; + total = 0; + totaldiv = 0; + init_array(standard_MFM_2_bit_cell_size, 2); + bitoffset = 0; + ref_pulse = 0; + outstep = 0; + while (outstep < 2) { + + /* calculates the current average bitrate from previous decoded data */ + uae_u32 avg_size = (total << 3) / totaldiv; /* this is the new average size for one MFM bit */ + /* uae_u32 avg_size = (uae_u32)((((float)total)*8.0) / ((float)totaldiv)); */ + /* you can try tighter ranges than 25%, or wider ranges. I would probably go for tighter... */ + if ((avg_size < (standard_MFM_8_bit_cell_size - (pulse_limitval * standard_MFM_8_bit_cell_size / 100))) || + (avg_size > (standard_MFM_8_bit_cell_size + (pulse_limitval * standard_MFM_8_bit_cell_size / 100)))) { + //init_array(standard_MFM_2_bit_cell_size, 2); + avg_size = standard_MFM_8_bit_cell_size; + } + /* this is to prevent the average value from going too far + * from the theoretical value, otherwise it could progressively go to (2 * + * real value), or (real value / 2), etc. */ + + /* gets the next long-enough pulse (this may require more than one pulse) */ + pulse = 0; + while (pulse < ((avg_size / 4) - (avg_size / 16))) { + int indx; + i++; + if (i >= pulses) + i = 0; + indx = idx[i]; + if (rand() <= (indx * RAND_MAX) / maxidx) { + pulse += avgp[i] - ref_pulse; + if (indx >= maxidx) + ref_pulse = 0; + else + ref_pulse = avgp[i]; + } + if (i == eodat) + outstep++; + if (outstep == 1 && indexoffset == i) + *indexoffsetp = bitoffset; + } + /* gets the size in bits from the pulse width, considering the current average bitrate */ + adjusted_pulse = pulse; + real_size = 0; + while (adjusted_pulse >= avg_size) { + real_size += 4; + adjusted_pulse -= avg_size / 2; + } + adjusted_pulse <<= 3; + while (adjusted_pulse >= ((avg_size * 4) + (avg_size / 4))) { + real_size += 2; + adjusted_pulse -= avg_size * 2; + } + if (adjusted_pulse >= ((avg_size * 3) + (avg_size / 4))) { + if (adjusted_pulse <= ((avg_size * 4) - (avg_size / 4))) { + if ((2 * ((adjusted_pulse >> 2) - adjust)) <= ((2 * avg_size) - (avg_size / 4))) + real_size += 3; + else + real_size += 4; + } else + real_size += 4; + } else { + if (adjusted_pulse > ((avg_size * 3) - (avg_size / 4))) { + real_size += 3; + } else { + if (adjusted_pulse >= ((avg_size * 2) + (avg_size / 4))) { + if ((2 * ((adjusted_pulse >> 2) - adjust)) < (avg_size + (avg_size / 4))) + real_size += 2; + else + real_size += 3; + } else + real_size += 2; + } + } + + if (outstep == 1) { + for (j = real_size; j > 1; j--) + addbit (d, 0); + addbit (d, 1); + for (j = 0; j < real_size; j++) + *pt++ = (uae_u16)(pulse / real_size); + } + + /* prepares for the next pulse */ + adjust = ((real_size * avg_size)/8) - pulse; + total -= psarray[array_index].size; + totaldiv -= psarray[array_index].number_of_bits; + psarray[array_index].size = pulse; + psarray[array_index].number_of_bits = real_size; + total += pulse; + totaldiv += real_size; + array_index++; + if (array_index >= FDI_MAX_ARRAY) + array_index = 0; + } + + fdi->out = bitoffset; +} + +#else + +static void fdi2_decode (FDI *fdi, unsigned long totalavg, uae_u32 *avgp, uae_u32 *minp, uae_u32 *maxp, uae_u8 *idx, int maxidx, int *indexoffsetp, int pulses, int mfm) +{ + unsigned long adjust; + unsigned long adjusted_pulse; + unsigned long standard_MFM_2_bit_cell_size = totalavg / 50000; + unsigned long standard_MFM_8_bit_cell_size = totalavg / 12500; + int real_size, i, j, nexti, eodat, outstep, randval; + int indexoffset = *indexoffsetp; + uae_u8 *d = fdi->track_dst_buffer; + uae_u16 *pt = fdi->track_dst_buffer_timing; + uae_u32 ref_pulse, pulse; + long jitter; + + /* detects a long-enough stable pulse coming just after another stable pulse */ + i = 1; + while ( (i < pulses) && ( (idx[i] < maxidx) + || (idx[i - 1] < maxidx) + || (minp[i] < (standard_MFM_2_bit_cell_size - (standard_MFM_2_bit_cell_size / 4))) ) ) + i++; + if (i == pulses) { + outlog ("FDI: No stable and long-enough pulse in track.\n"); + return; + } + nexti = i; + eodat = i; + i--; adjust = 0; - total = 0; + total = 0; totaldiv = 0; - init_array(standard_MFM_2_bit_cell_size); + init_array(standard_MFM_2_bit_cell_size, 1 + mfm); bitoffset = 0; - for (i = 0; i < pulses; i++) - { - if (idx[idx_off1] + idx[idx_off2] >= maxidx) { - uae_u32 pulse = avgp[i]; - uae_u32 avg_size = total / totaldiv; /* this is the new average size for one MFM bit */ - /* you can try tighter ranges than 25%, or wider ranges. I would probably go for tighter... */ - if ((avg_size < ((standard_MFM_2_bit_cell_size / 2) - (pulse_limitval * standard_MFM_2_bit_cell_size / 200))) || - (avg_size > ((standard_MFM_2_bit_cell_size / 2) + (pulse_limitval * standard_MFM_2_bit_cell_size /200)))) - init_array(standard_MFM_2_bit_cell_size); - /* this is to prevent the average value from going too far - * from the theoretical value, otherwise it could progressively go to (2 * - * real value), or (real value / 2), etc. */ - if ((pulse > adjust) && (adjust < avg_size)) - adjusted_pulse = pulse - adjust; - else - adjusted_pulse = pulse; - adjusted_pulse = pulse; - real_size = 1; - do { + ref_pulse = 0; + jitter = 0; + outstep = -1; + while (outstep < 2) { + + /* calculates the current average bitrate from previous decoded data */ + uae_u32 avg_size = (total << (2 + mfm)) / totaldiv; /* this is the new average size for one MFM bit */ + /* uae_u32 avg_size = (uae_u32)((((float)total)*((float)(mfm+1))*4.0) / ((float)totaldiv)); */ + /* you can try tighter ranges than 25%, or wider ranges. I would probably go for tighter... */ + if ((avg_size < (standard_MFM_8_bit_cell_size - (pulse_limitval * standard_MFM_8_bit_cell_size / 100))) || + (avg_size > (standard_MFM_8_bit_cell_size + (pulse_limitval * standard_MFM_8_bit_cell_size / 100)))) { + //init_array(standard_MFM_2_bit_cell_size, mfm + 1); + avg_size = standard_MFM_8_bit_cell_size; + } + /* this is to prevent the average value from going too far + * from the theoretical value, otherwise it could progressively go to (2 * + * real value), or (real value / 2), etc. */ + + /* gets the next long-enough pulse (this may require more than one pulse) */ + pulse = 0; + while (pulse < ((avg_size / 4) - (avg_size / 16))) { + uae_u32 avg_pulse, min_pulse, max_pulse; + i++; + if (i >= pulses) + i = 0; + if (i == nexti) { + do { + nexti++; + if (nexti >= pulses) + nexti = 0; + } while (idx[nexti] < maxidx); + } + if (idx[i] >= maxidx) { /* stable pulse */ + avg_pulse = avgp[i] - jitter; + min_pulse = minp[i]; + max_pulse = maxp[i]; + if (jitter >= 0) + max_pulse -= jitter; + else + min_pulse -= jitter; + if ((maxp[nexti] - avgp[nexti]) < (avg_pulse - min_pulse)) + min_pulse = avg_pulse - (maxp[nexti] - avgp[nexti]); + if ((avgp[nexti] - minp[nexti]) < (max_pulse - avg_pulse)) + max_pulse = avg_pulse + (avgp[nexti] - minp[nexti]); + if (min_pulse < ref_pulse) + min_pulse = ref_pulse; + randval = rand(); + if (randval < (RAND_MAX / 2)) { + if (randval > (RAND_MAX / 4)) { + if (randval <= (3 * RAND_MAX / 8)) + randval = (2 * randval) - (RAND_MAX /4); + else + randval = (4 * randval) - RAND_MAX; + } + jitter = 0 - (randval * (avg_pulse - min_pulse)) / RAND_MAX; + } else { + randval -= RAND_MAX / 2; + if (randval > (RAND_MAX / 4)) { + if (randval <= (3 * RAND_MAX / 8)) + randval = (2 * randval) - (RAND_MAX /4); + else + randval = (4 * randval) - RAND_MAX; + } + jitter = (randval * (max_pulse - avg_pulse)) / RAND_MAX; + } + avg_pulse += jitter; + if ((avg_pulse < min_pulse) || (avg_pulse > max_pulse)) { + outlog ("FDI: avg_pulse outside bounds! avg=%u min=%u max=%u\n", avg_pulse, min_pulse, max_pulse); + outlog ("FDI: avgp=%u (%u) minp=%u (%u) maxp=%u (%u) jitter=%d i=%d ni=%d\n", + avgp[i], avgp[nexti], minp[i], minp[nexti], maxp[i], maxp[nexti], jitter, i, nexti); + } + if (avg_pulse < ref_pulse) + outlog ("FDI: avg_pulse < ref_pulse! (%u < %u)\n", avg_pulse, ref_pulse); + pulse += avg_pulse - ref_pulse; + ref_pulse = 0; + if (i == eodat) + outstep++; + } else if (rand() <= ((idx[i] * RAND_MAX) / maxidx)) { + avg_pulse = avgp[i]; + min_pulse = minp[i]; + max_pulse = maxp[i]; + randval = rand(); + if (randval < (RAND_MAX / 2)) { + if (randval > (RAND_MAX / 4)) { + if (randval <= (3 * RAND_MAX / 8)) + randval = (2 * randval) - (RAND_MAX /4); + else + randval = (4 * randval) - RAND_MAX; + } + avg_pulse -= (randval * (avg_pulse - min_pulse)) / RAND_MAX; + } else { + randval -= RAND_MAX / 2; + if (randval > (RAND_MAX / 4)) { + if (randval <= (3 * RAND_MAX / 8)) + randval = (2 * randval) - (RAND_MAX /4); + else + randval = (4 * randval) - RAND_MAX; + } + avg_pulse += (randval * (max_pulse - avg_pulse)) / RAND_MAX; + } + if ((avg_pulse > ref_pulse) && (avg_pulse < (avgp[nexti] - jitter))) { + pulse += avg_pulse - ref_pulse; + ref_pulse = avg_pulse; + } + } + if (outstep == 1 && indexoffset == i) + *indexoffsetp = bitoffset; + } + + /* gets the size in bits from the pulse width, considering the current average bitrate */ + adjusted_pulse = pulse; + real_size = 0; + if (mfm) { + while (adjusted_pulse >= avg_size) { + real_size += 4; + adjusted_pulse -= avg_size / 2; + } + adjusted_pulse <<= 3; + while (adjusted_pulse >= ((avg_size * 4) + (avg_size / 4))) { + real_size += 2; + adjusted_pulse -= avg_size * 2; + } + if (adjusted_pulse >= ((avg_size * 3) + (avg_size / 4))) { + if (adjusted_pulse <= ((avg_size * 4) - (avg_size / 4))) { + if ((2 * ((adjusted_pulse >> 2) - adjust)) <= ((2 * avg_size) - (avg_size / 4))) + real_size += 3; + else + real_size += 4; + } else + real_size += 4; + } else { + if (adjusted_pulse > ((avg_size * 3) - (avg_size / 4))) { + real_size += 3; + } else { + if (adjusted_pulse >= ((avg_size * 2) + (avg_size / 4))) { + if ((2 * ((adjusted_pulse >> 2) - adjust)) < (avg_size + (avg_size / 4))) + real_size += 2; + else + real_size += 3; + } else + real_size += 2; + } + } + } else { + while (adjusted_pulse >= (2*avg_size)) + { + real_size+=4; + adjusted_pulse-=avg_size; + } + adjusted_pulse<<=2; + while (adjusted_pulse >= ((avg_size*3)+(avg_size/4))) + { + real_size+=2; + adjusted_pulse-=avg_size*2; + } + if (adjusted_pulse >= ((avg_size*2)+(avg_size/4))) + { + if (adjusted_pulse <= ((avg_size*3)-(avg_size/4))) + { + if (((adjusted_pulse>>1)-adjust) < (avg_size+(avg_size/4))) + real_size+=2; + else + real_size+=3; + } + else + real_size+=3; + } + else + { + if (adjusted_pulse > ((avg_size*2)-(avg_size/4))) + real_size+=2; + else + { + if (adjusted_pulse >= (avg_size+(avg_size/4))) + { + if (((adjusted_pulse>>1)-adjust) <= (avg_size-(avg_size/4))) + real_size++; + else + real_size+=2; + } + else + real_size++; + } + } + } + + /* after one pass to correctly initialize the average bitrate, outputs the bits */ + if (outstep == 1) { + for (j = real_size; j > 1; j--) addbit (d, 0); - real_size++; - } while (adjusted_pulse > avg_size * real_size + avg_size / 2); addbit (d, 1); -#if 1 - for (j = 0; j < real_size; j++) - *pt++ = (uae_u16)(adjusted_pulse / real_size); -#endif - /* Note that you should also consider values above 4! Too lazy to do it here ;-) */ - adjust = (real_size * avg_size) - pulse; - /* function to transform the value in real_size to '01', '001' or '0001', and append this to the decoded MFM stream */ - total -= psarray[array_index].size; - totaldiv -= psarray[array_index].number_of_bits; - psarray[array_index].size = pulse; - psarray[array_index].number_of_bits = real_size; - total += pulse; - totaldiv += real_size; - array_index++; - if (array_index >= FDI_MAX_ARRAY) - array_index = 0; + for (j = 0; j < real_size; j++) + *pt++ = (uae_u16)(pulse / real_size); } - idx += idx_off3; + + /* prepares for the next pulse */ + adjust = ((real_size * avg_size) / (4 << mfm)) - pulse; + total -= psarray[array_index].size; + totaldiv -= psarray[array_index].number_of_bits; + psarray[array_index].size = pulse; + psarray[array_index].number_of_bits = real_size; + total += pulse; + totaldiv += real_size; + array_index++; + if (array_index >= FDI_MAX_ARRAY) + array_index = 0; } + fdi->out = bitoffset; - write_log ("result bits: %d\n", bitoffset); } -static void fdi2_celltiming (FDI *fdi, unsigned long totalavg, int bitoffset) +#endif + +static void fdi2_celltiming (FDI *fdi, unsigned long totalavg, int bitoffset, uae_u16 *out) { - uae_u16 *pt2, *pt; + uae_u16 *pt2, *pt; double avg_bit_len; - int timed = 0; int i; avg_bit_len = (double)totalavg / (double)bitoffset; - pt2 = pt = fdi->track_dst_buffer_timing; - for (i = 0; i < bitoffset / 8; i++) { - double v = (pt2[0] + pt2[1] + pt2[2] + pt2[3] + pt2[4] + pt2[5] + pt2[6] + pt2[7]) / 8.0; - uae_u16 vv; + pt2 = fdi->track_dst_buffer_timing; + pt = out; + for (i = 0; i < bitoffset / 8; i++) { + double v = (pt2[0] + pt2[1] + pt2[2] + pt2[3] + pt2[4] + pt2[5] + pt2[6] + pt2[7]) / 8.0; v = 1000.0 * v / avg_bit_len; - vv = (uae_u16)v; - *pt++ = vv; - if (vv > 1030 || vv < 970) - timed = 1; + *pt++ = (uae_u16)v; pt2 += 8; } - *pt++ = fdi->track_dst_buffer_timing[0]; - *pt = fdi->track_dst_buffer_timing[0]; - if (!timed) - fdi->track_dst_buffer_timing[0] = 0; + *pt++ = out[0]; + *pt = out[0]; } -static int decode_lowlevel_track (FDI *fdi, int *indexoffsetp, int track) +static int decode_lowlevel_track (FDI *fdi, int track, struct fdi_cache *cache) { - uae_u8 *p1, *d; - uae_u32 *p2; - uae_u32 *avgp, *minp = 0, *maxp = 0; + uae_u8 *p1, *d; + uae_u32 *p2; + uae_u32 *avgp, *minp = 0, *maxp = 0; uae_u8 *idxp = 0; - uae_u32 maxidx, minidx, totalavg, weakbits; - int i, len, pulses, indexoffset; + uae_u32 maxidx, totalavg, weakbits; + int i, j, len, pulses, indexoffset; int avg_free, min_free = 0, max_free = 0, idx_free; - int idx_off1, idx_off2, idx_off3; + int idx_off1, idx_off2, idx_off3; d = fdi->track_dst; p1 = fdi->track_src; @@ -1515,27 +1827,31 @@ static int decode_lowlevel_track (FDI *fdi, int *indexoffsetp, int track) return -1; p1 += 4; len = 12; - avgp = (uae_u32*)fdi_decompress (pulses, p1 + 0, p1 + len, &avg_free); - //dumpstream(track, (uae_u8*)avgp, pulses); - len += get_u24 (p1 + 0) & 0x3fffff; + avgp = (uae_u32*)fdi_decompress (pulses, p1 + 0, p1 + len, &avg_free); + dumpstream(track, (uae_u8*)avgp, pulses); + len += get_u24 (p1 + 0) & 0x3fffff; if (!avgp) return -1; - if (get_u24 (p1 + 3) && get_u24 (p1 + 6)) { -#if 0 - minp = (uae_u32*)fdi_decompress (pulses, p1 + 3, p1 + len, &min_free); -#endif - len += get_u24 (p1 + 3) & 0x3fffff; -#if 0 - maxp = (uae_u32*)fdi_decompress (pulses, p1 + 6, p1 + len, &max_free); -#endif - len += get_u24 (p1 + 6) & 0x3fffff; + if (get_u24 (p1 + 3) && get_u24 (p1 + 6)) { + minp = (uae_u32*)fdi_decompress (pulses, p1 + 3, p1 + len, &min_free); + len += get_u24 (p1 + 3) & 0x3fffff; + maxp = (uae_u32*)fdi_decompress (pulses, p1 + 6, p1 + len, &max_free); + len += get_u24 (p1 + 6) & 0x3fffff; + /* Computes the real min and max values */ + for (i = 0; i < pulses; i++) { + maxp[i] = avgp[i] + minp[i] - maxp[i]; + minp[i] = avgp[i] - minp[i]; + } + } else { + minp = avgp; + maxp = avgp; } - if (get_u24 (p1 + 9)) { + if (get_u24 (p1 + 9)) { idx_off1 = 0; idx_off2 = 1; idx_off3 = 2; idxp = fdi_decompress (pulses, p1 + 9, p1 + len, &idx_free); - if (idx_free) { + if (idx_free) { if (idxp[0] == 0 && idxp[1] == 0) { idx_off1 = 2; idx_off2 = 3; @@ -1546,92 +1862,121 @@ static int decode_lowlevel_track (FDI *fdi, int *indexoffsetp, int track) idx_off3 = 4; } } else { - idxp = fdi_malloc (pulses * 2); + idxp = fdi_malloc (pulses * 2); idx_free = 1; - for (i = 0; i < pulses; i++) { - idxp[i * 2 + 0] = 2; - idxp[i * 2 + 1] = 0; + for (i = 0; i < pulses; i++) { + idxp[i * 2 + 0] = 2; + idxp[i * 2 + 1] = 0; } - idxp[0] = 1; - idxp[1] = 1; + idxp[0] = 1; + idxp[1] = 1; } maxidx = 0; - minidx = 255; indexoffset = 0; p1 = idxp; - for (i = 0; i < pulses; i++) { - if (p1[idx_off1] + p1[idx_off2] > maxidx) - maxidx = p1[idx_off1] + p1[idx_off2]; - if (abs (p1[idx_off1] - p1[idx_off2]) < minidx) { - minidx = abs (p1[idx_off1] - p1[idx_off2]); - indexoffset = i; - } + for (i = 0; i < pulses; i++) { + if (p1[idx_off1] + p1[idx_off2] > maxidx) + maxidx = p1[idx_off1] + p1[idx_off2]; + p1 += idx_off3; + } + p1 = idxp; + for (i = 0; (i < pulses) && (p1[idx_off2] != 0); i++) /* falling edge, replace with idx_off1 for rising edge */ p1 += idx_off3; + if (i < pulses) { + j = i; + do { + i++; + p1 += idx_off3; + if (i >= pulses) { + i = 0; + p1 = idxp; + } + } while ((i != j) && (p1[idx_off2] == 0)); /* falling edge, replace with idx_off1 for rising edge */ + if (i != j) /* index pulse detected */ + { + while ((i != j) && (p1[idx_off1] > p1[idx_off2])) { /* falling edge, replace with "<" for rising edge */ + i++; + p1 += idx_off3; + if (i >= pulses) { + i = 0; + p1 = idxp; + } + } + if (i != j) + indexoffset = i; /* index position detected */ + } } p1 = idxp; p2 = avgp; totalavg = 0; weakbits = 0; - for (i = 0; i < pulses; i++) { - if (p1[idx_off1] + p1[idx_off2] >= maxidx) { + for (i = 0; i < pulses; i++) { + int sum = p1[idx_off1] + p1[idx_off2]; + if (sum >= maxidx) { totalavg += *p2; } else { weakbits++; } p2++; - p1 += idx_off3; + p1 += idx_off3; + idxp[i] = sum; } len = totalavg / 100000; - outlog("totalavg=%d index=%d maxidx=%d weakbits=%d len=%d\n", + outlog("totalavg=%u index=%d (%d) maxidx=%d weakbits=%d len=%d\n", totalavg, indexoffset, maxidx, weakbits, len); - fdi2_mfm_decode (fdi, totalavg, avgp, idxp, idx_off1, idx_off2, idx_off3, maxidx, pulses); - outlog("number of bits=%d avg len=%.2f\n", bitoffset, (double)totalavg / bitoffset); - fdi2_celltiming (fdi, totalavg, bitoffset); - - *indexoffsetp = indexoffset; - if (avg_free) - fdi_free (avgp); - if (min_free) - fdi_free (minp); - if (max_free) - fdi_free (maxp); - if (idx_free) - fdi_free (idxp); - return bitoffset; -} - -static unsigned char fdiid[]={"Formatted Disk Image file"}; -static int bit_rate_table[16] = { 125,150,250,300,500,1000 }; + cache->avgp = avgp; + cache->idxp = idxp; + cache->minp = minp; + cache->maxp = maxp; + cache->avg_free = avg_free; + cache->idx_free = idx_free; + cache->min_free = min_free; + cache->max_free = max_free; + cache->totalavg = totalavg; + cache->pulses = pulses; + cache->maxidx = maxidx; + cache->indexoffset = indexoffset; + cache->weakbits = weakbits; + cache->lowlevel = 1; + + return 1; +} + +static unsigned char fdiid[]={"Formatted Disk Image file"}; +static int bit_rate_table[16] = { 125,150,250,300,500,1000 }; void fdi2raw_header_free (FDI *fdi) { - int i, j; + int i; - fdi_free (fdi->mfmsync_buffer); + fdi_free (fdi->mfmsync_buffer); fdi_free (fdi->track_src_buffer); fdi_free (fdi->track_dst_buffer); fdi_free (fdi->track_dst_buffer_timing); - for (i = 0; i < MAX_TRACKS; i++) { + for (i = 0; i < MAX_TRACKS; i++) { struct fdi_cache *c = &fdi->cache[i]; - for (j = 0; j < MAX_REVOLUTIONS; j++) - fdi_free (c->cache_buffer[j]); - fdi_free (c->cache_buffer_timing); + if (c->idx_free) + fdi_free (c->idxp); + if (c->avg_free) + fdi_free (c->avgp); + if (c->min_free) + fdi_free (c->minp); + if (c->max_free) + fdi_free (c->maxp); } - fdi_free (fdi); -#ifdef DEBUG - write_log ("FREE: memory allocated %d\n", fdi_allocated); -#endif + fdi_free (fdi); + debuglog ("FREE: memory allocated %d\n", fdi_allocated); } -int fdi2raw_get_last_track (FDI *fdi) +int fdi2raw_get_last_track (FDI *fdi) { - return fdi->last_track; + return fdi->last_track; } -int fdi2raw_get_num_sector (FDI *fdi) +int fdi2raw_get_num_sector (FDI *fdi) { - if (fdi->header[152] == 0x02) + if (fdi->header[152] == 0x02) return 22; return 11; } @@ -1651,7 +1996,7 @@ int fdi2raw_get_bit_rate (FDI *fdi) return fdi->bit_rate; } -int fdi2raw_get_type (FDI *fdi) +int fdi2raw_get_type (FDI *fdi) { return fdi->disk_type; } @@ -1663,132 +2008,140 @@ int fdi2raw_get_write_protect (FDI *fdi) FDI *fdi2raw_header(struct zfile *f) { - int i, offset, oldseek; + int i, offset, oldseek; uae_u8 type, size; FDI *fdi; -#ifdef DEBUG - write_log ("ALLOC: memory allocated %d\n", fdi_allocated); -#endif + debuglog ("ALLOC: memory allocated %d\n", fdi_allocated); fdi = fdi_malloc(sizeof(FDI)); - memset (fdi, 0, sizeof (FDI)); + memset (fdi, 0, sizeof (FDI)); fdi->file = f; - oldseek = zfile_ftell (fdi->file); - zfile_fseek (fdi->file, 0, SEEK_SET); - zfile_fread (fdi->header, 2048, 1, fdi->file); - zfile_fseek (fdi->file, oldseek, SEEK_SET); - if (memcmp (fdiid, fdi->header, strlen (fdiid)) ) { + oldseek = zfile_ftell (fdi->file); + zfile_fseek (fdi->file, 0, SEEK_SET); + zfile_fread (fdi->header, 2048, 1, fdi->file); + zfile_fseek (fdi->file, oldseek, SEEK_SET); + if (memcmp (fdiid, fdi->header, strlen (fdiid)) ) { fdi_free(fdi); return NULL; } - if ((fdi->header[140] != 1 && fdi->header[140] != 2) || fdi->header[141] != 0) { + if ((fdi->header[140] != 1 && fdi->header[140] != 2) || fdi->header[141] != 0) { fdi_free(fdi); return NULL; } - fdi->mfmsync_buffer = fdi_malloc (MAX_MFM_SYNC_BUFFER * sizeof(int)); - fdi->track_src_buffer = fdi_malloc (MAX_SRC_BUFFER); - fdi->track_dst_buffer = fdi_malloc (MAX_DST_BUFFER); + fdi->mfmsync_buffer = fdi_malloc (MAX_MFM_SYNC_BUFFER * sizeof(int)); + fdi->track_src_buffer = fdi_malloc (MAX_SRC_BUFFER); + fdi->track_dst_buffer = fdi_malloc (MAX_DST_BUFFER); fdi->track_dst_buffer_timing = fdi_malloc (MAX_TIMING_BUFFER); - fdi->last_track = ((fdi->header[142] << 8) + fdi->header[143]) + 1; - fdi->last_track *= fdi->header[144] + 1; + fdi->last_track = ((fdi->header[142] << 8) + fdi->header[143]) + 1; + fdi->last_track *= fdi->header[144] + 1; if (fdi->last_track > MAX_TRACKS) - fdi->last_track = MAX_TRACKS; + fdi->last_track = MAX_TRACKS; fdi->last_head = fdi->header[144]; fdi->disk_type = fdi->header[145]; fdi->rotation_speed = fdi->header[146] + 128; - fdi->write_protect = fdi->header[147] & 1; + fdi->write_protect = fdi->header[147] & 1; outlog ("FDI version %d.%d\n", fdi->header[140], fdi->header[141]); outlog ("last_track=%d rotation_speed=%d\n",fdi->last_track,fdi->rotation_speed); offset = 512; i = fdi->last_track; - if (i > 180) { + if (i > 180) { offset += 512; i -= 180; - while (i > 256) { + while (i > 256) { offset += 512; i -= 256; } } - for (i = 0; i < fdi->last_track; i++) { - fdi->track_offsets[i] = offset; + for (i = 0; i < fdi->last_track; i++) { + fdi->track_offsets[i] = offset; type = fdi->header[152 + i * 2]; size = fdi->header[152 + i * 2 + 1]; if (type == 1) - offset += (size & 15) * 512; - else if ((type & 0xc0) == 0x80) - offset += (((type & 0x3f) << 8) | size) * 256; + offset += (size & 15) * 512; + else if ((type & 0xc0) == 0x80) + offset += (((type & 0x3f) << 8) | size) * 256; else offset += size * 256; } - fdi->track_offsets[i] = offset; + fdi->track_offsets[i] = offset; return fdi; } -int fdi2raw_loadtrack (FDI *fdi, uae_u16 *mfmbuf, uae_u16 **trackpointers, uae_u16 **tracktiming, int track, int *tracklengths, int *revolutions, int *indexoffsetp) +int fdi2raw_loadrevolution_2 (FDI *fdi, uae_u16 *mfmbuf, uae_u16 *tracktiming, int track, int *tracklength, int *indexoffsetp, int *multirev, int mfm) +{ + struct fdi_cache *cache = &fdi->cache[track]; + int len, i, idx; + + memset (fdi->track_dst_buffer, 0, MAX_DST_BUFFER); + idx = cache->indexoffset; + fdi2_decode (fdi, cache->totalavg, + cache->avgp, cache->minp, cache->maxp, cache->idxp, + cache->maxidx, &idx, cache->pulses, mfm); + //fdi2_gcr_decode (fdi, totalavg, avgp, minp, maxp, idxp, idx_off1, idx_off2, idx_off3, maxidx, pulses); + outlog("track %d: nbits=%d avg len=%.2f weakbits=%d idx=%d\n", + track, bitoffset, (double)cache->totalavg / bitoffset, cache->weakbits, cache->indexoffset); + len = fdi->out; + if (cache->weakbits >= 10 && multirev) + *multirev = 1; + *tracklength = len; + + for (i = 0; i < (len + 15) / (2 * 8); i++) { + uae_u8 *data = fdi->track_dst_buffer + i * 2; + *mfmbuf++ = 256 * *data + *(data + 1); + } + fdi2_celltiming (fdi, cache->totalavg, len, tracktiming); + if (indexoffsetp) + *indexoffsetp = idx; + return 1; +} + +int fdi2raw_loadrevolution (FDI *fdi, uae_u16 *mfmbuf, uae_u16 *tracktiming, int track, int *tracklength, int mfm) +{ + return fdi2raw_loadrevolution_2 (fdi, mfmbuf, tracktiming, track, tracklength, 0, 0, mfm); +} + +int fdi2raw_loadtrack (FDI *fdi, uae_u16 *mfmbuf, uae_u16 *tracktiming, int track, int *tracklength, int *indexoffsetp, int *multirev, int mfm) { uae_u8 *p; - int outlen, i, j, indexoffset = 0; - struct fdi_cache *cache; - - *revolutions = 1; - *tracktiming = 0; - trackpointers[0] = mfmbuf; - - cache = &fdi->cache[track]; - if (cache->cache_buffer[0]) { - uae_u16 *tt; - *revolutions = 0; - for (j = 0; j < MAX_REVOLUTIONS && cache->cache_buffer[j]; j++) { - (*revolutions)++; - tracklengths[j] = cache->length[j]; - trackpointers[j] = mfmbuf; - for (i = 0; i < (tracklengths[j] + 15) / (2 * 8); i++) { - uae_u8 *data = cache->cache_buffer[j] + i * 2; - *mfmbuf++ = 256 * *data + *(data + 1); - } - } - if (cache->cache_buffer_timing) { - tt = xmalloc ((tracklengths[0] + 7) / 8 * sizeof (uae_u16)); - memcpy (tt, cache->cache_buffer_timing, (tracklengths[0] + 7) / 8 * sizeof (uae_u16)); - *tracktiming = tt; - } - *indexoffsetp = cache->indexoffset; - return 1; - } - + int outlen, i, indexoffset = 0; + struct fdi_cache *cache = &fdi->cache[track]; + + if (cache->lowlevel) + return fdi2raw_loadrevolution_2 (fdi, mfmbuf, tracktiming, track, tracklength, indexoffsetp, multirev, mfm); + fdi->err = 0; - fdi->track_src_len = fdi->track_offsets[track + 1] - fdi->track_offsets[track]; - zfile_fseek (fdi->file, fdi->track_offsets[track], SEEK_SET); - zfile_fread (fdi->track_src_buffer, fdi->track_src_len, 1, fdi->file); + fdi->track_src_len = fdi->track_offsets[track + 1] - fdi->track_offsets[track]; + zfile_fseek (fdi->file, fdi->track_offsets[track], SEEK_SET); + zfile_fread (fdi->track_src_buffer, fdi->track_src_len, 1, fdi->file); memset (fdi->track_dst_buffer, 0, MAX_DST_BUFFER); - fdi->track_dst_buffer_timing[0] = 0; + fdi->track_dst_buffer_timing[0] = 0; fdi->current_track = track; - fdi->track_src = fdi->track_src_buffer; - fdi->track_dst = fdi->track_dst_buffer; - p = fdi->header + 152 + fdi->current_track * 2; - fdi->track_type = *p++; + fdi->track_src = fdi->track_src_buffer; + fdi->track_dst = fdi->track_dst_buffer; + p = fdi->header + 152 + fdi->current_track * 2; + fdi->track_type = *p++; fdi->track_len = *p++; - fdi->bit_rate = 0; + fdi->bit_rate = 0; fdi->out = 0; fdi->mfmsync_offset = 0; - if ((fdi->track_type & 0xf0) == 0xf0 || (fdi->track_type & 0xf0) == 0xe0) - fdi->bit_rate = bit_rate_table[fdi->track_type & 0x0f]; + if ((fdi->track_type & 0xf0) == 0xf0 || (fdi->track_type & 0xf0) == 0xe0) + fdi->bit_rate = bit_rate_table[fdi->track_type & 0x0f]; else - fdi->bit_rate = 250; + fdi->bit_rate = 250; outlog ("track %d: srclen: %d track_type: %02.2X, bitrate: %d\n", - fdi->current_track, fdi->track_src_len, fdi->track_type, fdi->bit_rate); + fdi->current_track, fdi->track_src_len, fdi->track_type, fdi->bit_rate); - if ((fdi->track_type & 0xc0) == 0x80) { + if ((fdi->track_type & 0xc0) == 0x80) { - outlen = decode_lowlevel_track (fdi, &indexoffset, track); + outlen = decode_lowlevel_track (fdi, track, cache); } else if ((fdi->track_type & 0xf0) == 0xf0) { @@ -1796,7 +2149,7 @@ int fdi2raw_loadtrack (FDI *fdi, uae_u16 *mfmbuf, uae_u16 **trackpointers, uae_u } else if ((fdi->track_type & 0xf0) == 0xe0) { - outlen = handle_sectors_described_track (fdi); + outlen = handle_sectors_described_track (fdi); } else if ((fdi->track_type & 0xf0)) { @@ -1816,26 +2169,20 @@ int fdi2raw_loadtrack (FDI *fdi, uae_u16 *mfmbuf, uae_u16 **trackpointers, uae_u } +// amiga_check_track (fdi); + if (fdi->err) return 0; if (outlen > 0) { - for (j = 0; j < MAX_REVOLUTIONS; j++) { - fdi_free (cache->cache_buffer[j]); - cache->cache_buffer[j] = 0; - } - fdi_free (cache->cache_buffer_timing); - cache->cache_buffer_timing = 0; - cache->indexoffset = indexoffset; - cache->length[0] = outlen; - cache->cache_buffer[0] = fdi_malloc ((outlen + 7) / 8); - memcpy (cache->cache_buffer[0], fdi->track_dst_buffer, (outlen + 7) / 8); - if (fdi->track_dst_buffer_timing[0] > 0) { - cache->cache_buffer_timing = fdi_malloc ((outlen + 7) / 8 * sizeof (uae_u16)); - memcpy (cache->cache_buffer_timing, fdi->track_dst_buffer_timing, (outlen + 7) / 8 * sizeof (uae_u16)); + if (cache->lowlevel) + return fdi2raw_loadrevolution_2 (fdi, mfmbuf, tracktiming, track, tracklength, indexoffsetp, multirev, mfm); + *tracklength = fdi->out; + for (i = 0; i < ((*tracklength) + 15) / (2 * 8); i++) { + uae_u8 *data = fdi->track_dst_buffer + i * 2; + *mfmbuf++ = 256 * *data + *(data + 1); } - return fdi2raw_loadtrack (fdi, mfmbuf, trackpointers, tracktiming, track, tracklengths, revolutions, indexoffsetp); } - return 0; + return outlen; } diff --git a/fdi2raw2.c b/fdi2raw2.c new file mode 100755 index 00000000..3c2dc194 --- /dev/null +++ b/fdi2raw2.c @@ -0,0 +1,1986 @@ +/* + + FDI to raw bit stream converter + Copyright (c) 2001 by Toni Wilen + FDI 2.0 support + Copyright (c) 2003-2004 by Toni Wilen + and Vincent Joguin + + FDI format created by Vincent "ApH" Joguin + + Tiny changes - function type fixes, multiple drives, addition of + get_last_head and C++ callability - by Thomas Harte, 2001, + T.Harte@excite.co.uk + + + 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 +#include +#include + +/* IF UAE */ +#include "sysconfig.h" +#include "sysdeps.h" +#include "zfile.h" +/* ELSE */ +//#include "types.h" + +#include "fdi2raw.h" + +#undef DEBUG +#define VERBOSE +//#undef VERBOSE + +#include + +#ifdef DEBUG +static char *datalog(uae_u8 *src, int len) +{ + static char buf[1000]; + static int offset; + int i = 0, offset2; + + offset2 = offset; + buf[offset++]='\''; + while(len--) { + sprintf (buf + offset, "%02.2X", src[i]); + offset += 2; + i++; + if (i > 10) break; + } + buf[offset++]='\''; + buf[offset++] = 0; + if (offset >= 900) offset = 0; + return buf + offset2; +} +#else +static char *datalog(uae_u8 *src, int len) { return ""; } +#endif + +#ifdef DEBUG +#define debuglog write_log +#else +#define debuglog +#endif +#ifdef VERBOSE +#define outlog write_log +#else +#define outlog +#endif + +static int fdi_allocated; +#ifdef DEBUG +static void fdi_free (void *p) +{ + int size; + if (!p) + return; + size = ((int*)p)[-1]; + fdi_allocated -= size; + write_log ("%d freed (%d)\n", size, fdi_allocated); + free ((int*)p - 1); +} +static void *fdi_malloc (int size) +{ + void *p = xmalloc (size + sizeof (int)); + ((int*)p)[0] = size; + fdi_allocated += size; + write_log ("%d allocated (%d)\n", size, fdi_allocated); + return (int*)p + 1; +} +#else +#define fdi_free free +#define fdi_malloc xmalloc +#endif + +#define MAX_SRC_BUFFER 4194304 +#define MAX_DST_BUFFER 40000 +#define MAX_MFM_SYNC_BUFFER 60000 +#define MAX_TIMING_BUFFER 400000 +#define MAX_TRACKS 166 + +struct fdi_cache { + uae_u32 *avgp, *minp, *maxp; + uae_u8 *idxp; + int avg_free, idx_free, min_free, max_free; + uae_u32 totalavg, pulses, maxidx, indexoffset; + int weakbits; + int lowlevel; +}; + +struct fdi { + uae_u8 *track_src_buffer; + uae_u8 *track_src; + int track_src_len; + uae_u8 *track_dst_buffer; + uae_u8 *track_dst; + uae_u16 *track_dst_buffer_timing; + uae_u8 track_len; + uae_u8 track_type; + int current_track; + int last_track; + int last_head; + int rotation_speed; + int bit_rate; + int disk_type; + int write_protect; + int err; + uae_u8 header[2048]; + int track_offsets[MAX_TRACKS]; + struct zfile *file; + int out; + int mfmsync_offset; + int *mfmsync_buffer; + /* sector described only */ + int index_offset; + int encoding_type; + /* bit handling */ + int nextdrop; + struct fdi_cache cache[MAX_TRACKS]; +}; + +#define get_u32(x) ((((x)[0])<<24)|(((x)[1])<<16)|(((x)[2])<<8)|((x)[3])) +#define get_u24(x) ((((x)[0])<<16)|(((x)[1])<<8)|((x)[2])) +STATIC_INLINE put_u32 (uae_u8 *d, uae_u32 v) +{ + d[0] = v >> 24; + d[1] = v >> 16; + d[2] = v >> 8; + d[3] = v; +} + +struct node { + uae_u16 v; + struct node *left; + struct node *right; +}; +typedef struct node NODE; + +static uae_u8 temp, temp2; + +static uae_u8 *expand_tree (uae_u8 *stream, NODE *node) +{ + if (temp & temp2) { + fdi_free (node->left); + node->left = 0; + fdi_free (node->right); + node->right = 0; + temp2 >>= 1; + if (!temp2) { + temp = *stream++; + temp2 = 0x80; + } + return stream; + } else { + uae_u8 *stream_temp; + temp2 >>= 1; + if (!temp2) { + temp = *stream++; + temp2 = 0x80; + } + node->left = fdi_malloc (sizeof (NODE)); + memset (node->left, 0, sizeof (NODE)); + stream_temp = expand_tree (stream, node->left); + node->right = fdi_malloc (sizeof (NODE)); + memset (node->right, 0, sizeof (NODE)); + return expand_tree (stream_temp, node->right); + } +} + +static uae_u8 *values_tree8 (uae_u8 *stream, NODE *node) +{ + if (node->left == 0) { + node->v = *stream++; + return stream; + } else { + uae_u8 *stream_temp = values_tree8 (stream, node->left); + return values_tree8 (stream_temp, node->right); + } +} + +static uae_u8 *values_tree16 (uae_u8 *stream, NODE *node) +{ + if (node->left == 0) { + uae_u16 high_8_bits = (*stream++) << 8; + node->v = high_8_bits | (*stream++); + return stream; + } else { + uae_u8 *stream_temp = values_tree16 (stream, node->left); + return values_tree16 (stream_temp, node->right); + } +} + +static void free_nodes (NODE *node) +{ + if (node) { + free_nodes (node->left); + free_nodes (node->right); + fdi_free (node); + } +} + +static uae_u32 sign_extend16 (uae_u32 v) +{ + if (v & 0x8000) + v |= 0xffff0000; + return v; +} + +static uae_u32 sign_extend8 (uae_u32 v) +{ + if (v & 0x80) + v |= 0xffffff00; + return v; +} + +static void fdi_decode (uae_u8 *stream, int size, uae_u8 *out) +{ + int i; + uae_u8 sign_extend, sixteen_bit, sub_stream_shift; + NODE root; + NODE *current_node; + + memset (out, 0, size * 4); + sub_stream_shift = 1; + while (sub_stream_shift) { + + //sub-stream header decode + sign_extend = *stream++; + sub_stream_shift = sign_extend & 0x7f; + sign_extend &= 0x80; + sixteen_bit = (*stream++) & 0x80; + + //huffman tree architecture decode + temp = *stream++; + temp2 = 0x80; + stream = expand_tree (stream, &root); + if (temp2 == 0x80) + stream--; + + //huffman output values decode + if (sixteen_bit) + stream = values_tree16 (stream, &root); + else + stream = values_tree8 (stream, &root); + + //sub-stream data decode + temp2 = 0; + for (i = 0; i < size; i++) { + uae_u32 v; + uae_u8 decode = 1; + current_node = &root; + while (decode) { + if (current_node->left == 0) { + decode = 0; + } else { + temp2 >>= 1; + if (!temp2) { + temp2 = 0x80; + temp = *stream++; + } + if (temp & temp2) + current_node = current_node->right; + else + current_node = current_node->left; + } + } + v = ((uae_u32*)out)[i]; + if (sign_extend) { + if (sixteen_bit) + v |= sign_extend16 (current_node->v) << sub_stream_shift; + else + v |= sign_extend8 (current_node->v) << sub_stream_shift; + } else { + v |= current_node->v << sub_stream_shift; + } + ((uae_u32*)out)[i] = v; + } + free_nodes (root.left); + free_nodes (root.right); + } +} + + +static int decode_raw_track (FDI *fdi) +{ + int size = get_u32(fdi->track_src); + memcpy (fdi->track_dst, fdi->track_src, (size + 7) >> 3); + fdi->track_src += (size + 7) >> 3; + return size; +} + +/* unknown track */ +static void zxx (FDI *fdi) +{ + outlog ("track %d: unknown track type 0x%02.2X\n", fdi->current_track, fdi->track_type); +// return -1; +} +/* unsupported track */ +static void zyy (FDI *fdi) +{ + outlog ("track %d: unsupported track type 0x%02.2X\n", fdi->current_track, fdi->track_type); +// return -1; +} +/* empty track */ +static void track_empty (FDI *fdi) +{ +// return 0; +} + +/* unknown sector described type */ +static void dxx (FDI *fdi) +{ + outlog ("\ntrack %d: unknown sector described type 0x%02.2X\n", fdi->current_track, fdi->track_type); + fdi->err = 1; +} +/* unsupported sector described type */ +static void dyy (FDI *fdi) +{ + outlog ("\ntrack %d: unsupported sector described 0x%02.2X\n", fdi->current_track, fdi->track_type); + fdi->err = 1; +} +/* add position of mfm sync bit */ +static void add_mfm_sync_bit (FDI *fdi) +{ + if (fdi->nextdrop) { + fdi->nextdrop = 0; + return; + } + fdi->mfmsync_buffer[fdi->mfmsync_offset++] = fdi->out; + if (fdi->out == 0) { + outlog ("illegal position for mfm sync bit, offset=%d\n",fdi->out); + fdi->err = 1; + } + if (fdi->mfmsync_offset >= MAX_MFM_SYNC_BUFFER) { + fdi->mfmsync_offset = 0; + outlog ("mfmsync buffer overflow\n"); + fdi->err = 1; + } + fdi->out++; +} + +#define BIT_BYTEOFFSET ((fdi->out) >> 3) +#define BIT_BITOFFSET (7-((fdi->out)&7)) + +/* add one bit */ +static void bit_add (FDI *fdi, int bit) +{ + if (fdi->nextdrop) { + fdi->nextdrop = 0; + return; + } + fdi->track_dst[BIT_BYTEOFFSET] &= ~(1 << BIT_BITOFFSET); + if (bit) + fdi->track_dst[BIT_BYTEOFFSET] |= (1 << BIT_BITOFFSET); + fdi->out++; + if (fdi->out >= MAX_DST_BUFFER * 8) { + outlog ("destination buffer overflow\n"); + fdi->err = 1; + fdi->out = 1; + } +} +/* add bit and mfm sync bit */ +static void bit_mfm_add (FDI *fdi, int bit) +{ + add_mfm_sync_bit (fdi); + bit_add (fdi, bit); +} +/* remove following bit */ +static void bit_drop_next (FDI *fdi) +{ + if (fdi->nextdrop > 0) { + outlog("multiple bit_drop_next() called"); + } else if (fdi->nextdrop < 0) { + fdi->nextdrop = 0; + debuglog(":DNN:"); + return; + } + debuglog(":DN:"); + fdi->nextdrop = 1; +} + +/* ignore next bit_drop_next() */ +static void bit_dedrop (FDI *fdi) +{ + if (fdi->nextdrop) { + outlog("bit_drop_next called before bit_dedrop"); + } + fdi->nextdrop = -1; + debuglog(":BDD:"); +} + +/* add one byte */ +static void byte_add (FDI *fdi, uae_u8 v) +{ + int i; + for (i = 7; i >= 0; i--) + bit_add (fdi, v & (1 << i)); +} +/* add one word */ +static void word_add (FDI *fdi, uae_u16 v) +{ + byte_add (fdi, (uae_u8)(v >> 8)); + byte_add (fdi, (uae_u8)v); +} +/* add one byte and mfm encode it */ +static void byte_mfm_add (FDI *fdi, uae_u8 v) +{ + int i; + for (i = 7; i >= 0; i--) + bit_mfm_add (fdi, v & (1 << i)); +} +/* add multiple bytes and mfm encode them */ +static void bytes_mfm_add (FDI *fdi, uae_u8 v, int len) +{ + int i; + for (i = 0; i < len; i++) byte_mfm_add (fdi, v); +} +/* add one mfm encoded word and re-mfm encode it */ +static void word_post_mfm_add (FDI *fdi, uae_u16 v) +{ + int i; + for (i = 14; i >= 0; i -= 2) + bit_mfm_add (fdi, v & (1 << i)); +} + +/* bit 0 */ +static void s00(FDI *fdi) { bit_add (fdi, 0); } +/* bit 1*/ +static void s01(FDI *fdi) { bit_add (fdi, 1); } +/* 4489 */ +static void s02(FDI *fdi) { word_add (fdi, 0x4489); } +/* 5224 */ +static void s03(FDI *fdi) { word_add (fdi, 0x5224); } +/* mfm sync bit */ +static void s04(FDI *fdi) { add_mfm_sync_bit (fdi); } +/* RLE MFM-encoded data */ +static void s08(FDI *fdi) +{ + int bytes = *fdi->track_src++; + uae_u8 byte = *fdi->track_src++; + if (bytes == 0) bytes = 256; + debuglog ("s08:len=%d,data=%02.2X",bytes,byte); + while(bytes--) byte_add (fdi, byte); +} +/* RLE MFM-decoded data */ +static void s09(FDI *fdi) +{ + int bytes = *fdi->track_src++; + uae_u8 byte = *fdi->track_src++; + if (bytes == 0) bytes = 256; + bit_drop_next (fdi); + debuglog ("s09:len=%d,data=%02.2X",bytes,byte); + while(bytes--) byte_mfm_add (fdi, byte); +} +/* MFM-encoded data */ +static void s0a(FDI *fdi) +{ + int i, bits = (fdi->track_src[0] << 8) | fdi->track_src[1]; + uae_u8 b; + fdi->track_src += 2; + debuglog ("s0a:bits=%d,data=%s", bits, datalog(fdi->track_src, (bits + 7) / 8)); + while (bits >= 8) { + byte_add (fdi, *fdi->track_src++); + bits -= 8; + } + if (bits > 0) { + i = 7; + b = *fdi->track_src++; + while (bits--) { + bit_add (fdi, b & (1 << i)); + i--; + } + } +} +/* MFM-encoded data */ +static void s0b(FDI *fdi) +{ + int i, bits = ((fdi->track_src[0] << 8) | fdi->track_src[1]) + 65536; + uae_u8 b; + fdi->track_src += 2; + debuglog ("s0b:bits=%d,data=%s", bits, datalog(fdi->track_src, (bits + 7) / 8)); + while (bits >= 8) { + byte_add (fdi, *fdi->track_src++); + bits -= 8; + } + if (bits > 0) { + i = 7; + b = *fdi->track_src++; + while (bits--) { + bit_add (fdi, b & (1 << i)); + i--; + } + } +} +/* MFM-decoded data */ +static void s0c(FDI *fdi) +{ + int i, bits = (fdi->track_src[0] << 8) | fdi->track_src[1]; + uae_u8 b; + fdi->track_src += 2; + bit_drop_next (fdi); + debuglog ("s0c:bits=%d,data=%s", bits, datalog(fdi->track_src, (bits + 7) / 8)); + while (bits >= 8) { + byte_mfm_add (fdi, *fdi->track_src++); + bits -= 8; + } + if (bits > 0) { + i = 7; + b = *fdi->track_src++; + while(bits--) { + bit_mfm_add (fdi, b & (1 << i)); + i--; + } + } +} +/* MFM-decoded data */ +static void s0d(FDI *fdi) +{ + int i, bits = ((fdi->track_src[0] << 8) | fdi->track_src[1]) + 65536; + uae_u8 b; + fdi->track_src += 2; + bit_drop_next (fdi); + debuglog ("s0d:bits=%d,data=%s", bits, datalog(fdi->track_src, (bits + 7) / 8)); + while (bits >= 8) { + byte_mfm_add (fdi, *fdi->track_src++); + bits -= 8; + } + if (bits > 0) { + i = 7; + b = *fdi->track_src++; + while(bits--) { + bit_mfm_add (fdi, b & (1 << i)); + i--; + } + } +} + +/* ***** */ +/* AMIGA */ +/* ***** */ + +/* just for testing integrity of Amiga sectors */ + +static void rotateonebit (uae_u8 *start, uae_u8 *end, int shift) +{ + if (shift == 0) + return; + while (start <= end) { + start[0] <<= shift; + start[0] |= start[1] >> (8 - shift); + start++; + } +} + +static int check_offset; +static uae_u16 getmfmword (uae_u8 *mbuf) +{ + uae_u32 v; + + v = (mbuf[0] << 8) | (mbuf[1] << 0); + if (check_offset == 0) + return v; + v <<= 8; + v |= mbuf[2]; + v >>= check_offset; + return v; +} + +#define MFMMASK 0x55555555 +static uae_u32 getmfmlong (uae_u8 * mbuf) +{ + return ((getmfmword (mbuf) << 16) | getmfmword (mbuf + 2)) & MFMMASK; +} + +static int amiga_check_track (FDI *fdi) +{ + int i, j, secwritten = 0; + int fwlen = fdi->out / 8; + int length = 2 * fwlen; + int drvsec = 11; + uae_u32 odd, even, chksum, id, dlong; + uae_u8 *secdata; + uae_u8 secbuf[544]; + uae_u8 bigmfmbuf[60000]; + uae_u8 *mbuf, *mbuf2, *mend; + char sectable[22]; + uae_u8 *raw = fdi->track_dst_buffer; + int slabel, off; + int ok = 1; + + memset (bigmfmbuf, 0, sizeof (bigmfmbuf)); + mbuf = bigmfmbuf; + check_offset = 0; + for (i = 0; i < (fdi->out + 7) / 8; i++) + *mbuf++ = raw[i]; + off = fdi->out & 7; +#if 1 + if (off > 0) { + mbuf--; + *mbuf &= ~((1 << (8 - off)) - 1); + } + j = 0; + while (i < (fdi->out + 7) / 8 + 600) { + *mbuf++ |= (raw[j] >> off) | ((raw[j + 1]) << (8 - off)); + j++; + i++; + } +#endif + mbuf = bigmfmbuf; + + memset (sectable, 0, sizeof (sectable)); + //memcpy (mbuf + fwlen, mbuf, fwlen * sizeof (uae_u16)); + mend = bigmfmbuf + length; + mend -= (4 + 16 + 8 + 512); + + while (secwritten < drvsec) { + int trackoffs; + + for (;;) { + rotateonebit (bigmfmbuf, mend, 1); + if (getmfmword (mbuf) == 0) + break; + if (secwritten == 10) { + mbuf[0] = 0x44; + mbuf[1] = 0x89; + } +// check_offset++; + if (check_offset > 7) { + check_offset = 0; + mbuf++; + if (mbuf >= mend || *mbuf == 0) + break; + } + if (getmfmword (mbuf) == 0x4489) + break; + } + if (mbuf >= mend || *mbuf == 0) + break; + + rotateonebit (bigmfmbuf, mend, check_offset); + check_offset = 0; + + while (getmfmword (mbuf) == 0x4489) + mbuf+= 1 * 2; + mbuf2 = mbuf + 8; + + odd = getmfmlong (mbuf); + even = getmfmlong (mbuf + 2 * 2); + mbuf += 4 * 2; + id = (odd << 1) | even; + + trackoffs = (id & 0xff00) >> 8; + if (trackoffs + 1 > drvsec) { + outlog("illegal sector offset %d\n",trackoffs); + ok = 0; + mbuf = mbuf2; + continue; + } + if ((id >> 24) != 0xff) { + outlog ("sector %d format type %02.2X?\n", trackoffs, id >> 24); + ok = 0; + } + chksum = odd ^ even; + slabel = 0; + for (i = 0; i < 4; i++) { + odd = getmfmlong (mbuf); + even = getmfmlong (mbuf + 8 * 2); + mbuf += 2* 2; + + dlong = (odd << 1) | even; + if (dlong) slabel = 1; + chksum ^= odd ^ even; + } + mbuf += 8 * 2; + odd = getmfmlong (mbuf); + even = getmfmlong (mbuf + 2 * 2); + mbuf += 4 * 2; + if (((odd << 1) | even) != chksum) { + outlog("sector %d header crc error\n", trackoffs); + ok = 0; + mbuf = mbuf2; + continue; + } + outlog("sector %d header crc ok\n", trackoffs); + if (((id & 0x00ff0000) >> 16) != (uae_u32)fdi->current_track) { + outlog("illegal track number %d <> %d\n",fdi->current_track,(id & 0x00ff0000) >> 16); + ok++; + mbuf = mbuf2; + continue; + } + odd = getmfmlong (mbuf); + even = getmfmlong (mbuf + 2 * 2); + mbuf += 4 * 2; + chksum = (odd << 1) | even; + secdata = secbuf + 32; + for (i = 0; i < 128; i++) { + odd = getmfmlong (mbuf); + even = getmfmlong (mbuf + 256 * 2); + mbuf += 2 * 2; + dlong = (odd << 1) | even; + *secdata++ = (uae_u8) (dlong >> 24); + *secdata++ = (uae_u8) (dlong >> 16); + *secdata++ = (uae_u8) (dlong >> 8); + *secdata++ = (uae_u8) dlong; + chksum ^= odd ^ even; + } + mbuf += 256 * 2; + if (chksum) { + outlog("sector %d data checksum error\n",trackoffs); + ok = 0; + } else if (sectable[trackoffs]) { + outlog("sector %d already found?\n", trackoffs); + mbuf = mbuf2; + } else { + outlog("sector %d ok\n",trackoffs); + if (slabel) outlog("(non-empty sector header)\n"); + sectable[trackoffs] = 1; + secwritten++; + if (trackoffs == 9) + mbuf += 0x228; + } + } + for (i = 0; i < drvsec; i++) { + if (!sectable[i]) { + outlog ("sector %d missing\n", i); + ok = 0; + } + } + return ok; +} + +static void amiga_data_raw (FDI *fdi, uae_u8 *secbuf, uae_u8 *crc, int len) +{ + int i; + uae_u8 crcbuf[4]; + + if (!crc) { + memset (crcbuf, 0, 4); + } else { + memcpy (crcbuf, crc ,4); + } + for (i = 0; i < 4; i++) + byte_mfm_add (fdi, crcbuf[i]); + for (i = 0; i < len; i++) + byte_mfm_add (fdi, secbuf[i]); +} + +static void amiga_data (FDI *fdi, uae_u8 *secbuf) +{ + uae_u16 mfmbuf[4 + 512]; + uae_u32 dodd, deven, dck; + int i; + + for (i = 0; i < 512; i += 4) { + deven = ((secbuf[i + 0] << 24) | (secbuf[i + 1] << 16) + | (secbuf[i + 2] << 8) | (secbuf[i + 3])); + dodd = deven >> 1; + deven &= 0x55555555; + dodd &= 0x55555555; + mfmbuf[(i >> 1) + 4] = (uae_u16) (dodd >> 16); + mfmbuf[(i >> 1) + 5] = (uae_u16) dodd; + mfmbuf[(i >> 1) + 256 + 4] = (uae_u16) (deven >> 16); + mfmbuf[(i >> 1) + 256 + 5] = (uae_u16) deven; + } + dck = 0; + for (i = 4; i < 4 + 512; i += 2) + dck ^= (mfmbuf[i] << 16) | mfmbuf[i + 1]; + deven = dodd = dck; + dodd >>= 1; + deven &= 0x55555555; + dodd &= 0x55555555; + mfmbuf[0] = (uae_u16) (dodd >> 16); + mfmbuf[1] = (uae_u16) dodd; + mfmbuf[2] = (uae_u16) (deven >> 16); + mfmbuf[3] = (uae_u16) deven; + + for (i = 0; i < 4 + 512; i ++) + word_post_mfm_add (fdi, mfmbuf[i]); +} + +static void amiga_sector_header (FDI *fdi, uae_u8 *header, uae_u8 *data, int sector, int untilgap) +{ + uae_u8 headerbuf[4], databuf[16]; + uae_u32 deven, dodd, hck; + uae_u16 mfmbuf[24]; + int i; + + byte_mfm_add (fdi, 0); + byte_mfm_add (fdi, 0); + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + if (header) { + memcpy (headerbuf, header, 4); + } else { + headerbuf[0] = 0xff; + headerbuf[1] = (uae_u8)fdi->current_track; + headerbuf[2] = (uae_u8)sector; + headerbuf[3] = (uae_u8)untilgap; + } + if (data) + memcpy (databuf, data, 16); + else + memset (databuf, 0, 16); + + deven = ((headerbuf[0] << 24) | (headerbuf[1] << 16) + | (headerbuf[2] << 8) | (headerbuf[3])); + dodd = deven >> 1; + deven &= 0x55555555; + dodd &= 0x55555555; + mfmbuf[0] = (uae_u16) (dodd >> 16); + mfmbuf[1] = (uae_u16) dodd; + mfmbuf[2] = (uae_u16) (deven >> 16); + mfmbuf[3] = (uae_u16) deven; + for (i = 0; i < 16; i += 4) { + deven = ((databuf[i] << 24) | (databuf[i + 1] << 16) + | (databuf[i + 2] << 8) | (databuf[i + 3])); + dodd = deven >> 1; + deven &= 0x55555555; + dodd &= 0x55555555; + mfmbuf[(i >> 1) + 0 + 4] = (uae_u16) (dodd >> 16); + mfmbuf[(i >> 1) + 0 + 5] = (uae_u16) dodd; + mfmbuf[(i >> 1) + 8 + 4] = (uae_u16) (deven >> 16); + mfmbuf[(i >> 1) + 8 + 5] = (uae_u16) deven; + } + hck = 0; + for (i = 0; i < 4 + 16; i += 2) + hck ^= (mfmbuf[i] << 16) | mfmbuf[i + 1]; + deven = dodd = hck; + dodd >>= 1; + deven &= 0x55555555; + dodd &= 0x55555555; + mfmbuf[20] = (uae_u16) (dodd >> 16); + mfmbuf[21] = (uae_u16) dodd; + mfmbuf[22] = (uae_u16) (deven >> 16); + mfmbuf[23] = (uae_u16) deven; + + for (i = 0; i < 4 + 16 + 4; i ++) + word_post_mfm_add (fdi, mfmbuf[i]); +} + +/* standard super-extended Amiga sector header */ +static void s20(FDI *fdi) +{ + bit_drop_next (fdi); + debuglog ("s20:header=%s,data=%s", datalog(fdi->track_src, 4), datalog(fdi->track_src + 4, 16)); + amiga_sector_header (fdi, fdi->track_src, fdi->track_src + 4, 0, 0); + fdi->track_src += 4 + 16; +} +/* standard extended Amiga sector header */ +static void s21(FDI *fdi) +{ + bit_drop_next (fdi); + debuglog ("s21:header=%s", datalog(fdi->track_src, 4)); + amiga_sector_header (fdi, fdi->track_src, 0, 0, 0); + fdi->track_src += 4; +} +/* standard Amiga sector header */ +static void s22(FDI *fdi) +{ + bit_drop_next (fdi); + debuglog("s22:sector=%d,untilgap=%d", fdi->track_src[0], fdi->track_src[1]); + amiga_sector_header (fdi, 0, 0, fdi->track_src[0], fdi->track_src[1]); + fdi->track_src += 2; +} +/* standard 512-byte, CRC-correct Amiga data */ +static void s23(FDI *fdi) +{ + debuglog("s23:data=%s", datalog (fdi->track_src, 512)); + amiga_data (fdi, fdi->track_src); + fdi->track_src += 512; +} +/* not-decoded, 128*2^x-byte, CRC-correct Amiga data */ +static void s24(FDI *fdi) +{ + int shift = *fdi->track_src++; + debuglog("s24:shift=%d,data=%s", shift, datalog (fdi->track_src, 128 << shift)); + amiga_data_raw (fdi, fdi->track_src, 0, 128 << shift); + fdi->track_src += 128 << shift; +} +/* not-decoded, 128*2^x-byte, CRC-incorrect Amiga data */ +static void s25(FDI *fdi) +{ + int shift = *fdi->track_src++; + debuglog("s25:shift=%d,crc=%s,data=%s", shift, datalog (fdi->track_src, 4), datalog (fdi->track_src + 4, 128 << shift)); + amiga_data_raw (fdi, fdi->track_src + 4, fdi->track_src, 128 << shift); + fdi->track_src += 4 + (128 << shift); +} +/* standard extended Amiga sector */ +static void s26(FDI *fdi) +{ + s21 (fdi); + debuglog("s26:data=%s", datalog (fdi->track_src, 512)); + amiga_data (fdi, fdi->track_src); + fdi->track_src += 512; +} +/* standard short Amiga sector */ +static void s27(FDI *fdi) +{ + s22 (fdi); + debuglog("s27:data=%s", datalog (fdi->track_src, 512)); + amiga_data (fdi, fdi->track_src); + fdi->track_src += 512; +} + +/* *** */ +/* IBM */ +/* *** */ + +static uae_u16 ibm_crc (uae_u8 byte, int reset) +{ + static uae_u16 crc; + int i; + + if (reset) crc = 0xcdb4; + for (i = 0; i < 8; i++) { + if (crc & 0x8000) { + crc <<= 1; + if (!(byte & 0x80)) crc ^= 0x1021; + } else { + crc <<= 1; + if (byte & 0x80) crc ^= 0x1021; + } + byte <<= 1; + } + return crc; +} + +static void ibm_data (FDI *fdi, uae_u8 *data, uae_u8 *crc, int len) +{ + int i; + uae_u8 crcbuf[2]; + uae_u16 crcv; + + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + byte_mfm_add (fdi, 0xfb); + ibm_crc (0xfb, 1); + for (i = 0; i < len; i++) { + byte_mfm_add (fdi, data[i]); + crcv = ibm_crc (data[i], 0); + } + if (!crc) { + crc = crcbuf; + crc[0] = (uae_u8)(crcv >> 8); + crc[1] = (uae_u8)crcv; + } + byte_mfm_add (fdi, crc[0]); + byte_mfm_add (fdi, crc[1]); +} + +static void ibm_sector_header (FDI *fdi, uae_u8 *data, uae_u8 *crc, int secnum, int pre) +{ + uae_u8 secbuf[5]; + uae_u8 crcbuf[2]; + uae_u16 crcv; + int i; + + if (pre) + bytes_mfm_add (fdi, 0, 12); + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + secbuf[0] = 0xfe; + if (secnum >= 0) { + secbuf[1] = (uae_u8)(fdi->current_track/2); + secbuf[2] = (uae_u8)(fdi->current_track%2); + secbuf[3] = (uae_u8)secnum; + secbuf[4] = 2; + } else { + memcpy (secbuf + 1, data, 4); + } + ibm_crc (secbuf[0], 1); + ibm_crc (secbuf[1], 0); + ibm_crc (secbuf[2], 0); + ibm_crc (secbuf[3], 0); + crcv = ibm_crc (secbuf[4], 0); + if (crc) { + memcpy (crcbuf, crc, 2); + } else { + crcbuf[0] = (uae_u8)(crcv >> 8); + crcbuf[1] = (uae_u8)crcv; + } + /* data */ + for (i = 0;i < 5; i++) + byte_mfm_add (fdi, secbuf[i]); + /* crc */ + byte_mfm_add (fdi, crcbuf[0]); + byte_mfm_add (fdi, crcbuf[1]); +} + +/* standard IBM index address mark */ +static void s10(FDI *fdi) +{ + bit_drop_next (fdi); + bytes_mfm_add (fdi, 0, 12); + word_add (fdi, 0x5224); + word_add (fdi, 0x5224); + word_add (fdi, 0x5224); + byte_mfm_add (fdi, 0xfc); +} +/* standard IBM pre-gap */ +static void s11(FDI *fdi) +{ + bit_drop_next (fdi); + bytes_mfm_add (fdi, 0x4e, 78); + bit_dedrop (fdi); + s10 (fdi); + bytes_mfm_add (fdi, 0x4e, 50); +} +/* standard ST pre-gap */ +static void s12(FDI *fdi) +{ + bit_drop_next (fdi); + bytes_mfm_add (fdi, 0x4e, 78); +} +/* standard extended IBM sector header */ +static void s13(FDI *fdi) +{ + bit_drop_next (fdi); + debuglog ("s13:header=%s", datalog (fdi->track_src, 4)); + ibm_sector_header (fdi, fdi->track_src, 0, -1, 1); + fdi->track_src += 4; +} +/* standard mini-extended IBM sector header */ +static void s14(FDI *fdi) +{ + debuglog ("s14:header=%s", datalog (fdi->track_src, 4)); + ibm_sector_header (fdi, fdi->track_src, 0, -1, 0); + fdi->track_src += 4; +} +/* standard short IBM sector header */ +static void s15(FDI *fdi) +{ + bit_drop_next (fdi); + debuglog ("s15:sector=%d", *fdi->track_src); + ibm_sector_header (fdi, 0, 0, *fdi->track_src++, 1); +} +/* standard mini-short IBM sector header */ +static void s16(FDI *fdi) +{ + debuglog ("s16:track=%d", *fdi->track_src); + ibm_sector_header (fdi, 0, 0, *fdi->track_src++, 0); +} +/* standard CRC-incorrect mini-extended IBM sector header */ +static void s17(FDI *fdi) +{ + debuglog ("s17:header=%s,crc=%s", datalog (fdi->track_src, 4), datalog (fdi->track_src + 4, 2)); + ibm_sector_header (fdi, fdi->track_src, fdi->track_src + 4, -1, 0); + fdi->track_src += 4 + 2; +} +/* standard CRC-incorrect mini-short IBM sector header */ +static void s18(FDI *fdi) +{ + debuglog ("s18:sector=%d,header=%s", *fdi->track_src, datalog (fdi->track_src + 1, 4)); + ibm_sector_header (fdi, 0, fdi->track_src + 1, *fdi->track_src, 0); + fdi->track_src += 1 + 4; +} +/* standard 512-byte CRC-correct IBM data */ +static void s19(FDI *fdi) +{ + debuglog ("s19:data=%s", datalog (fdi->track_src , 512)); + ibm_data (fdi, fdi->track_src, 0, 512); + fdi->track_src += 512; +} +/* standard 128*2^x-byte-byte CRC-correct IBM data */ +static void s1a(FDI *fdi) +{ + int shift = *fdi->track_src++; + debuglog ("s1a:shift=%d,data=%s", shift, datalog (fdi->track_src , 128 << shift)); + ibm_data (fdi, fdi->track_src, 0, 128 << shift); + fdi->track_src += 128 << shift; +} +/* standard 128*2^x-byte-byte CRC-incorrect IBM data */ +static void s1b(FDI *fdi) +{ + int shift = *fdi->track_src++; + debuglog ("s1b:shift=%d,crc=%s,data=%s", shift, datalog (fdi->track_src + (128 << shift), 2), datalog (fdi->track_src , 128 << shift)); + ibm_data (fdi, fdi->track_src, fdi->track_src + (128 << shift), 128 << shift); + fdi->track_src += (128 << shift) + 2; +} +/* standard extended IBM sector */ +static void s1c(FDI *fdi) +{ + int shift = fdi->track_src[3]; + s13 (fdi); + bytes_mfm_add (fdi, 0x4e, 22); + bytes_mfm_add (fdi, 0x00, 12); + ibm_data (fdi, fdi->track_src, 0, 128 << shift); + fdi->track_src += 128 << shift; +} +/* standard short IBM sector */ +static void s1d(FDI *fdi) +{ + s15 (fdi); + bytes_mfm_add (fdi, 0x4e, 22); + bytes_mfm_add (fdi, 0x00, 12); + s19 (fdi); +} + +/* end marker */ +static void sff(FDI *fdi) +{ +} + +typedef void (*decode_described_track_func)(FDI*); + +static decode_described_track_func decode_sectors_described_track[] = +{ + s00,s01,s02,s03,s04,dxx,dxx,dxx,s08,s09,s0a,s0b,s0c,s0d,dxx,dxx, /* 00-0F */ + s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s1a,s1b,s1c,s1d,dxx,dxx, /* 10-1F */ + s20,s21,s22,s23,s24,s25,s26,s27,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 20-2F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 30-3F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 40-4F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 50-5F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 60-6F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 70-7F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 80-8F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 90-9F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* A0-AF */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* B0-BF */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* C0-CF */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* D0-DF */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* E0-EF */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,sff /* F0-FF */ +}; + +static void track_amiga (struct fdi *fdi, int first_sector, int max_sector) +{ + int i; + + bit_add (fdi, 0); + bit_drop_next (fdi); + for (i = 0; i < max_sector; i++) { + amiga_sector_header (fdi, 0, 0, first_sector, max_sector - i); + amiga_data (fdi, fdi->track_src + first_sector * 512); + first_sector++; + if (first_sector >= max_sector) first_sector = 0; + } + bytes_mfm_add (fdi, 0, 260); /* gap */ +} +static void track_atari_st (struct fdi *fdi, int max_sector) +{ + int i, gap3; + uae_u8 *p = fdi->track_src; + + switch (max_sector) + { + case 9: + gap3 = 40; + break; + case 10: + gap3 = 24; + break; + } + s15 (fdi); + for (i = 0; i < max_sector; i++) { + byte_mfm_add (fdi, 0x4e); + byte_mfm_add (fdi, 0x4e); + ibm_sector_header (fdi, 0, 0, fdi->current_track, 1); + ibm_data (fdi, p + i * 512, 0, 512); + bytes_mfm_add (fdi, 0x4e, gap3); + } + bytes_mfm_add (fdi, 0x4e, 660 - gap3); + fdi->track_src += fdi->track_len * 256; +} +static void track_pc (struct fdi *fdi, int max_sector) +{ + int i, gap3; + uae_u8 *p = fdi->track_src; + + switch (max_sector) + { + case 8: + gap3 = 116; + break; + case 9: + gap3 = 54; + break; + default: + gap3 = 100; /* fixme */ + break; + } + s11 (fdi); + for (i = 0; i < max_sector; i++) { + byte_mfm_add (fdi, 0x4e); + byte_mfm_add (fdi, 0x4e); + ibm_sector_header (fdi, 0, 0, fdi->current_track, 1); + ibm_data (fdi, p + i * 512, 0, 512); + bytes_mfm_add (fdi, 0x4e, gap3); + } + bytes_mfm_add (fdi, 0x4e, 600 - gap3); + fdi->track_src += fdi->track_len * 256; +} + +/* amiga dd */ +static void track_amiga_dd (struct fdi *fdi) +{ + uae_u8 *p = fdi->track_src; + track_amiga (fdi, fdi->track_len >> 4, 11); + fdi->track_src = p + (fdi->track_len & 15) * 512; +} +/* amiga hd */ +static void track_amiga_hd (struct fdi *fdi) +{ + uae_u8 *p = fdi->track_src; + track_amiga (fdi, 0, 22); + fdi->track_src = p + fdi->track_len * 256; +} +/* atari st 9 sector */ +static void track_atari_st_9 (struct fdi *fdi) +{ + track_atari_st (fdi, 9); +} +/* atari st 10 sector */ +static void track_atari_st_10 (struct fdi *fdi) +{ + track_atari_st (fdi, 10); +} +/* pc 8 sector */ +static void track_pc_8 (struct fdi *fdi) +{ + track_pc (fdi, 8); +} +/* pc 9 sector */ +static void track_pc_9 (struct fdi *fdi) +{ + track_pc (fdi, 9); +} +/* pc 15 sector */ +static void track_pc_15 (struct fdi *fdi) +{ + track_pc (fdi, 15); +} +/* pc 18 sector */ +static void track_pc_18 (struct fdi *fdi) +{ + track_pc (fdi, 18); +} +/* pc 36 sector */ +static void track_pc_36 (struct fdi *fdi) +{ + track_pc (fdi, 36); +} + +typedef void (*decode_normal_track_func)(FDI*); + +static decode_normal_track_func decode_normal_track[] = +{ + track_empty, /* 0 */ + track_amiga_dd, track_amiga_hd, /* 1-2 */ + track_atari_st_9, track_atari_st_10, /* 3-4 */ + track_pc_8, track_pc_9, track_pc_15, track_pc_18, track_pc_36, /* 5-9 */ + zxx,zxx,zxx,zxx,zxx /* A-F */ +}; + +static void fix_mfm_sync (FDI *fdi) +{ + int i, pos, off1, off2, off3, mask1, mask2, mask3; + + for (i = 0; i < fdi->mfmsync_offset; i++) { + pos = fdi->mfmsync_buffer[i]; + off1 = (pos - 1) >> 3; + off2 = (pos + 1) >> 3; + off3 = pos >> 3; + mask1 = 1 << (7 - ((pos - 1) & 7)); + mask2 = 1 << (7 - ((pos + 1) & 7)); + mask3 = 1 << (7 - (pos & 7)); + if (!(fdi->track_dst[off1] & mask1) && !(fdi->track_dst[off2] & mask2)) + fdi->track_dst[off3] |= mask3; + else + fdi->track_dst[off3] &= ~mask3; + } +} + +static int handle_sectors_described_track (FDI *fdi) +{ + int oldout; + uae_u8 *start_src = fdi->track_src ; + fdi->encoding_type = *fdi->track_src++; + fdi->index_offset = get_u32(fdi->track_src); + fdi->index_offset >>= 8; + fdi->track_src += 3; + outlog ("sectors_described, index offset: %d\n",fdi->index_offset); + + do { + fdi->track_type = *fdi->track_src++; + outlog ("%06.6X %06.6X %02.2X:",fdi->track_src - start_src + 0x200, fdi->out/8, fdi->track_type); + oldout = fdi->out; + decode_sectors_described_track[fdi->track_type](fdi); + outlog(" %d\n", fdi->out - oldout); + oldout = fdi->out; + if (fdi->out < 0 || fdi->err) { + outlog ("\nin %d bytes, out %d bits\n", fdi->track_src - fdi->track_src_buffer, fdi->out); + return -1; + } + if (fdi->track_src - fdi->track_src_buffer >= fdi->track_src_len) { + outlog ("source buffer overrun, previous type: %02.2X\n", fdi->track_type); + return -1; + } + } while (fdi->track_type != 0xff); + outlog("\n"); + fix_mfm_sync (fdi); + return fdi->out; +} + +static uae_u8 *fdi_decompress (int pulses, uae_u8 *sizep, uae_u8 *src, int *dofree) +{ + uae_u32 size = get_u24 (sizep); + uae_u32 *dst2; + int len = size & 0x3fffff; + uae_u8 *dst; + int mode = size >> 22, i; + + *dofree = 0; + if (mode == 0 && pulses * 2 > len) + mode = 1; + if (mode == 0) { + dst2 = (uae_u32*)src; + dst = src; + for (i = 0; i < pulses; i++) { + *dst2++ = get_u32 (src); + src += 4; + } + } else if (mode == 1) { + dst = fdi_malloc (pulses *4); + *dofree = 1; + fdi_decode (src, pulses, dst); + } else { + dst = 0; + } + return dst; +} + +static void dumpstream(int track, uae_u8 *stream, int len) +{ +#if 0 + char name[100]; + FILE *f; + + sprintf (name, "track_%d.raw", track); + f = fopen(name, "wb"); + fwrite (stream, 1, len * 4, f); + fclose (f); +#endif +} + +static int bitoffset; + +STATIC_INLINE void addbit (uae_u8 *p, int bit) +{ + int off1 = bitoffset / 8; + int off2 = bitoffset % 8; + p[off1] |= bit << (7 - off2); + bitoffset++; +} + + +struct pulse_sample { + unsigned long size; + int number_of_bits; +}; + +#define FDI_MAX_ARRAY 10 /* change this value as you want */ +static int pulse_limitval = 15; /* tolerance of 15% */ +static struct pulse_sample psarray[FDI_MAX_ARRAY]; +static int array_index; +static unsigned long total; +static int totaldiv; + +static void init_array(unsigned long standard_MFM_2_bit_cell_size, int nb_of_bits) +{ + int i; + + for (i = 0; i < FDI_MAX_ARRAY; i++) { + psarray[i].size = standard_MFM_2_bit_cell_size; // That is (total track length / 50000) for Amiga double density + total += psarray[i].size; + psarray[i].number_of_bits = nb_of_bits; + totaldiv += psarray[i].number_of_bits; + } + array_index = 0; +} + +static void fdi2_mfm_decode(FDI *fdi, unsigned long totalavg, uae_u32 *avgp, uae_u32 *minp, uae_u32 *maxp, uae_u8 *idx, int maxidx, int pulses) +{ + unsigned long adjust; + unsigned long adjusted_pulse; + unsigned long standard_MFM_2_bit_cell_size = totalavg / 50000; + unsigned long standard_MFM_8_bit_cell_size = totalavg / 12500; + int real_size, i, j, nexti, eodat, outstep, randval; + uae_u8 *d = fdi->track_dst_buffer; + uae_u16 *pt = fdi->track_dst_buffer_timing; + uae_u32 ref_pulse, pulse; + long jitter; + + /* detects a long-enough stable pulse coming just after another stable pulse */ + i = 1; + while ( (i < pulses) && ( (idx[i] < maxidx) + || (idx[i - 1] < maxidx) + || (minp[i] < (standard_MFM_2_bit_cell_size - (standard_MFM_2_bit_cell_size / 4))) ) ) + i++; + if (i == pulses) { + outlog ("No stable and long-enough pulse in track.\n"); + return; + } + nexti = i; + eodat = i; + i--; + adjust = 0; + total = 0; + totaldiv = 0; + init_array(standard_MFM_2_bit_cell_size, 2); + bitoffset = 0; + ref_pulse = 0; + jitter = 0; + outstep = -1; + while (outstep < 2) { + + /* calculates the current average bitrate from previous decoded data */ + uae_u32 avg_size = (total << 3) / totaldiv; /* this is the new average size for one MFM bit */ + /* uae_u32 avg_size = (uae_u32)((((float)total)*8.0) / ((float)totaldiv)); */ + /* you can try tighter ranges than 25%, or wider ranges. I would probably go for tighter... */ + if ((avg_size < (standard_MFM_8_bit_cell_size - (pulse_limitval * standard_MFM_8_bit_cell_size / 100))) || + (avg_size > (standard_MFM_8_bit_cell_size + (pulse_limitval * standard_MFM_8_bit_cell_size / 100)))) { + //init_array(standard_MFM_2_bit_cell_size, 2); + avg_size = standard_MFM_8_bit_cell_size; + } + /* this is to prevent the average value from going too far + * from the theoretical value, otherwise it could progressively go to (2 * + * real value), or (real value / 2), etc. */ + + /* gets the next long-enough pulse (this may require more than one pulse) */ + pulse = 0; + while (pulse < ((avg_size / 4) - (avg_size / 16))) { + uae_u32 avg_pulse, min_pulse, max_pulse; + i++; + if (i >= pulses) + i = 0; + if (i == nexti) { + do { + nexti++; + if (nexti >= pulses) + nexti = 0; + } while (idx[nexti] < maxidx); + } + if (idx[i] >= maxidx) { /* stable pulse */ + avg_pulse = avgp[i] - jitter; + min_pulse = minp[i]; + max_pulse = maxp[i]; + if (jitter >= 0) + min_pulse -= jitter; + else + max_pulse -= jitter; + if ((maxp[nexti] - avgp[nexti]) < (avg_pulse - min_pulse)) + min_pulse = avg_pulse - (maxp[nexti] - avgp[nexti]); + if ((avgp[nexti] - minp[nexti]) < (max_pulse - avg_pulse)) + max_pulse = avg_pulse + (avgp[nexti] - minp[nexti]); + if (min_pulse < ref_pulse) + min_pulse = ref_pulse; + randval = rand(); + if (randval < (RAND_MAX / 2)) { + if (randval > (RAND_MAX / 4)) { + if (randval <= (3 * RAND_MAX / 8)) + randval = (2 * randval) - (RAND_MAX /4); + else + randval = (4 * randval) - RAND_MAX; + } + jitter = 0 - (randval * (avg_pulse - min_pulse)) / RAND_MAX; + } else { + randval -= RAND_MAX / 2; + if (randval > (RAND_MAX / 4)) { + if (randval <= (3 * RAND_MAX / 8)) + randval = (2 * randval) - (RAND_MAX /4); + else + randval = (4 * randval) - RAND_MAX; + } + jitter = (randval * (max_pulse - avg_pulse)) / RAND_MAX; + } + avg_pulse += jitter; + if ((avg_pulse < min_pulse) || (avg_pulse > max_pulse)) { + outlog ("avg_pulse outside bounds! avg=%u min=%u max=%u\n", avg_pulse, min_pulse, max_pulse); + outlog("avgp=%u (%u) minp=%u (%u) maxp=%u (%u) jitter=%d i=%d ni=%d\n", + avgp[i], avgp[nexti], minp[i], minp[nexti], maxp[i], maxp[nexti], jitter, i, nexti); + } + if (avg_pulse < ref_pulse) + outlog ("avg_pulse < ref_pulse! (%u < %u)\n", avg_pulse, ref_pulse); + pulse += avg_pulse - ref_pulse; + ref_pulse = 0; + if (i == eodat) + outstep++; + } else if (rand() <= ((idx[i] * RAND_MAX) / maxidx)) { + avg_pulse = avgp[i]; + min_pulse = minp[i]; + max_pulse = maxp[i]; + randval = rand(); + if (randval < (RAND_MAX / 2)) { + if (randval > (RAND_MAX / 4)) { + if (randval <= (3 * RAND_MAX / 8)) + randval = (2 * randval) - (RAND_MAX /4); + else + randval = (4 * randval) - RAND_MAX; + } + avg_pulse -= (randval * (avg_pulse - min_pulse)) / RAND_MAX; + } else { + randval -= RAND_MAX / 2; + if (randval > (RAND_MAX / 4)) { + if (randval <= (3 * RAND_MAX / 8)) + randval = (2 * randval) - (RAND_MAX /4); + else + randval = (4 * randval) - RAND_MAX; + } + avg_pulse += (randval * (max_pulse - avg_pulse)) / RAND_MAX; + } + if ((avg_pulse > ref_pulse) && (avg_pulse < (avgp[nexti] - jitter))) { + pulse += avg_pulse - ref_pulse; + ref_pulse = avg_pulse; + } + } + } + + /* gets the size in bits from the pulse width, considering the current average bitrate */ + adjusted_pulse = pulse; + real_size = 0; + while (adjusted_pulse >= avg_size) { + real_size += 4; + adjusted_pulse -= avg_size / 2; + } + adjusted_pulse <<= 3; + while (adjusted_pulse >= ((avg_size * 4) + (avg_size / 4))) { + real_size += 2; + adjusted_pulse -= avg_size * 2; + } + if (adjusted_pulse >= ((avg_size * 3) + (avg_size / 4))) { + if (adjusted_pulse <= ((avg_size * 4) - (avg_size / 4))) { + if ((2 * ((adjusted_pulse >> 2) - adjust)) <= ((2 * avg_size) - (avg_size / 4))) + real_size += 3; + else + real_size += 4; + } else + real_size += 4; + } else { + if (adjusted_pulse > ((avg_size * 3) - (avg_size / 4))) { + real_size += 3; + } else { + if (adjusted_pulse >= ((avg_size * 2) + (avg_size / 4))) { + if ((2 * ((adjusted_pulse >> 2) - adjust)) < (avg_size + (avg_size / 4))) + real_size += 2; + else + real_size += 3; + } else + real_size += 2; + } + } + + if (outstep == 1) { + for (j = real_size; j > 1; j--) + addbit (d, 0); + addbit (d, 1); + for (j = 0; j < real_size; j++) + *pt++ = (uae_u16)(pulse / real_size); + } + + /* prepares for the next pulse */ + adjust = ((real_size * avg_size)/8) - pulse; + total -= psarray[array_index].size; + totaldiv -= psarray[array_index].number_of_bits; + psarray[array_index].size = pulse; + psarray[array_index].number_of_bits = real_size; + total += pulse; + totaldiv += real_size; + array_index++; + if (array_index >= FDI_MAX_ARRAY) + array_index = 0; + } + + fdi->out = bitoffset; +} + +static void fdi2_celltiming (FDI *fdi, unsigned long totalavg, int bitoffset, uae_u16 *out) +{ + uae_u16 *pt2, *pt; + double avg_bit_len; + int i; + + avg_bit_len = (double)totalavg / (double)bitoffset; + pt2 = fdi->track_dst_buffer_timing; + pt = out; + for (i = 0; i < bitoffset / 8; i++) { + double v = (pt2[0] + pt2[1] + pt2[2] + pt2[3] + pt2[4] + pt2[5] + pt2[6] + pt2[7]) / 8.0; + v = 1000.0 * v / avg_bit_len; + *pt++ = (uae_u16)v; + pt2 += 8; + } + *out++ = *pt; + *out = *pt; +} + +static int decode_lowlevel_track (FDI *fdi, int *indexoffsetp, int track, struct fdi_cache *cache) +{ + uae_u8 *p1, *d; + uae_u32 *p2; + uae_u32 *avgp, *minp = 0, *maxp = 0; + uae_u8 *idxp = 0; + uae_u32 maxidx, minidx, totalavg, weakbits; + int i, len, pulses, indexoffset; + int avg_free, min_free = 0, max_free = 0, idx_free; + int idx_off1, idx_off2, idx_off3; + + d = fdi->track_dst; + p1 = fdi->track_src; + pulses = get_u32 (p1); + if (!pulses) + return -1; + p1 += 4; + len = 12; + avgp = (uae_u32*)fdi_decompress (pulses, p1 + 0, p1 + len, &avg_free); + dumpstream(track, (uae_u8*)avgp, pulses); + len += get_u24 (p1 + 0) & 0x3fffff; + if (!avgp) + return -1; + if (get_u24 (p1 + 3) && get_u24 (p1 + 6)) { + minp = (uae_u32*)fdi_decompress (pulses, p1 + 3, p1 + len, &min_free); + len += get_u24 (p1 + 3) & 0x3fffff; + maxp = (uae_u32*)fdi_decompress (pulses, p1 + 6, p1 + len, &max_free); + len += get_u24 (p1 + 6) & 0x3fffff; + /* Computes the real min and max values */ + for (i = 0; i < pulses; i++) { + maxp[i] = avgp[i] + minp[i] - maxp[i]; + minp[i] = avgp[i] - minp[i]; + } + } else { + minp = avgp; + maxp = avgp; + } + if (get_u24 (p1 + 9)) { + idx_off1 = 0; + idx_off2 = 1; + idx_off3 = 2; + idxp = fdi_decompress (pulses, p1 + 9, p1 + len, &idx_free); + if (idx_free) { + if (idxp[0] == 0 && idxp[1] == 0) { + idx_off1 = 2; + idx_off2 = 3; + } else { + idx_off1 = 1; + idx_off2 = 0; + } + idx_off3 = 4; + } + } else { + idxp = fdi_malloc (pulses * 2); + idx_free = 1; + for (i = 0; i < pulses; i++) { + idxp[i * 2 + 0] = 2; + idxp[i * 2 + 1] = 0; + } + idxp[0] = 1; + idxp[1] = 1; + } + + maxidx = 0; + minidx = 255; + indexoffset = 0; + p1 = idxp; + for (i = 0; i < pulses; i++) { + if (p1[idx_off1] + p1[idx_off2] > maxidx) + maxidx = p1[idx_off1] + p1[idx_off2]; + if (abs (p1[idx_off1] - p1[idx_off2]) < minidx) { + minidx = abs (p1[idx_off1] - p1[idx_off2]); + indexoffset = i; + } + p1 += idx_off3; + } + p1 = idxp; + p2 = avgp; + totalavg = 0; + weakbits = 0; + for (i = 0; i < pulses; i++) { + int sum = p1[idx_off1] + p1[idx_off2]; + if (sum >= maxidx) { + totalavg += *p2; + } else { + weakbits++; + } + p2++; + p1 += idx_off3; + idxp[i] = sum; + } + len = totalavg / 100000; + outlog("totalavg=%u index=%d maxidx=%d weakbits=%d len=%d\n", + totalavg, indexoffset, maxidx, weakbits, len); + cache->avgp = avgp; + cache->idxp = idxp; + cache->minp = minp; + cache->maxp = maxp; + cache->avg_free = avg_free; + cache->idx_free = idx_free; + cache->min_free = min_free; + cache->max_free = max_free; + cache->totalavg = totalavg; + cache->pulses = pulses; + cache->maxidx = maxidx; + cache->indexoffset = indexoffset; + cache->weakbits = weakbits; + cache->lowlevel = 1; + + return 1; +} + +static unsigned char fdiid[]={"Formatted Disk Image file"}; +static int bit_rate_table[16] = { 125,150,250,300,500,1000 }; + +void fdi2raw_header_free (FDI *fdi) +{ + int i; + + fdi_free (fdi->mfmsync_buffer); + fdi_free (fdi->track_src_buffer); + fdi_free (fdi->track_dst_buffer); + fdi_free (fdi->track_dst_buffer_timing); + for (i = 0; i < MAX_TRACKS; i++) { + struct fdi_cache *c = &fdi->cache[i]; + if (c->idx_free) + fdi_free (c->idxp); + if (c->avg_free) + fdi_free (c->avgp); + if (c->min_free) + fdi_free (c->minp); + if (c->max_free) + fdi_free (c->maxp); + } + fdi_free (fdi); + debuglog ("FREE: memory allocated %d\n", fdi_allocated); +} + +int fdi2raw_get_last_track (FDI *fdi) +{ + return fdi->last_track; +} + +int fdi2raw_get_num_sector (FDI *fdi) +{ + if (fdi->header[152] == 0x02) + return 22; + return 11; +} + +int fdi2raw_get_last_head (FDI *fdi) +{ + return fdi->last_head; +} + +int fdi2raw_get_rotation (FDI *fdi) +{ + return fdi->rotation_speed; +} + +int fdi2raw_get_bit_rate (FDI *fdi) +{ + return fdi->bit_rate; +} + +int fdi2raw_get_type (FDI *fdi) +{ + return fdi->disk_type; +} + +int fdi2raw_get_write_protect (FDI *fdi) +{ + return fdi->write_protect; +} + +FDI *fdi2raw_header(struct zfile *f) +{ + int i, offset, oldseek; + uae_u8 type, size; + FDI *fdi; + + debuglog ("ALLOC: memory allocated %d\n", fdi_allocated); + fdi = fdi_malloc(sizeof(FDI)); + memset (fdi, 0, sizeof (FDI)); + fdi->file = f; + oldseek = zfile_ftell (fdi->file); + zfile_fseek (fdi->file, 0, SEEK_SET); + zfile_fread (fdi->header, 2048, 1, fdi->file); + zfile_fseek (fdi->file, oldseek, SEEK_SET); + if (memcmp (fdiid, fdi->header, strlen (fdiid)) ) { + fdi_free(fdi); + return NULL; + } + if ((fdi->header[140] != 1 && fdi->header[140] != 2) || fdi->header[141] != 0) { + fdi_free(fdi); + return NULL; + } + + fdi->mfmsync_buffer = fdi_malloc (MAX_MFM_SYNC_BUFFER * sizeof(int)); + fdi->track_src_buffer = fdi_malloc (MAX_SRC_BUFFER); + fdi->track_dst_buffer = fdi_malloc (MAX_DST_BUFFER); + fdi->track_dst_buffer_timing = fdi_malloc (MAX_TIMING_BUFFER); + + fdi->last_track = ((fdi->header[142] << 8) + fdi->header[143]) + 1; + fdi->last_track *= fdi->header[144] + 1; + if (fdi->last_track > MAX_TRACKS) + fdi->last_track = MAX_TRACKS; + fdi->last_head = fdi->header[144]; + fdi->disk_type = fdi->header[145]; + fdi->rotation_speed = fdi->header[146] + 128; + fdi->write_protect = fdi->header[147] & 1; + outlog ("FDI version %d.%d\n", fdi->header[140], fdi->header[141]); + outlog ("last_track=%d rotation_speed=%d\n",fdi->last_track,fdi->rotation_speed); + + offset = 512; + i = fdi->last_track; + if (i > 180) { + offset += 512; + i -= 180; + while (i > 256) { + offset += 512; + i -= 256; + } + } + for (i = 0; i < fdi->last_track; i++) { + fdi->track_offsets[i] = offset; + type = fdi->header[152 + i * 2]; + size = fdi->header[152 + i * 2 + 1]; + if (type == 1) + offset += (size & 15) * 512; + else if ((type & 0xc0) == 0x80) + offset += (((type & 0x3f) << 8) | size) * 256; + else + offset += size * 256; + } + fdi->track_offsets[i] = offset; + + return fdi; +} + + +int fdi2raw_loadrevolution_2 (FDI *fdi, uae_u16 *mfmbuf, uae_u16 *tracktiming, int track, int *tracklength, int *indexoffsetp, int *multirev) +{ + struct fdi_cache *cache = &fdi->cache[track]; + int len, i; + + memset (fdi->track_dst_buffer, 0, MAX_DST_BUFFER); + fdi2_mfm_decode (fdi, cache->totalavg, + cache->avgp, cache->minp, cache->maxp, cache->idxp, + cache->maxidx, cache->pulses); + //fdi2_gcr_decode (fdi, totalavg, avgp, minp, maxp, idxp, idx_off1, idx_off2, idx_off3, maxidx, pulses); + outlog("track %d: number of bits=%d avg len=%.2f weakbits=%d\n", + track, bitoffset, (double)cache->totalavg / bitoffset, cache->weakbits); + len = fdi->out; + if (cache->weakbits >= 10 && multirev) + *multirev = 1; + *tracklength = len; + + for (i = 0; i < (len + 15) / (2 * 8); i++) { + uae_u8 *data = fdi->track_dst_buffer + i * 2; + *mfmbuf++ = 256 * *data + *(data + 1); + } + fdi2_celltiming (fdi, cache->totalavg, len, tracktiming); + if (indexoffsetp) + *indexoffsetp = cache->indexoffset; + return 1; +} + +int fdi2raw_loadrevolution (FDI *fdi, uae_u16 *mfmbuf, uae_u16 *tracktiming, int track, int *tracklength) +{ + return fdi2raw_loadrevolution_2 (fdi, mfmbuf, tracktiming, track, tracklength, 0, 0); +} + +int fdi2raw_loadtrack (FDI *fdi, uae_u16 *mfmbuf, uae_u16 *tracktiming, int track, int *tracklength, int *indexoffsetp, int *multirev) +{ + uae_u8 *p; + int outlen, i, indexoffset = 0; + struct fdi_cache *cache = &fdi->cache[track]; + + if (cache->lowlevel) + return fdi2raw_loadrevolution_2 (fdi, mfmbuf, tracktiming, track, tracklength, indexoffsetp, multirev); + + fdi->err = 0; + fdi->track_src_len = fdi->track_offsets[track + 1] - fdi->track_offsets[track]; + zfile_fseek (fdi->file, fdi->track_offsets[track], SEEK_SET); + zfile_fread (fdi->track_src_buffer, fdi->track_src_len, 1, fdi->file); + memset (fdi->track_dst_buffer, 0, MAX_DST_BUFFER); + fdi->track_dst_buffer_timing[0] = 0; + + fdi->current_track = track; + fdi->track_src = fdi->track_src_buffer; + fdi->track_dst = fdi->track_dst_buffer; + p = fdi->header + 152 + fdi->current_track * 2; + fdi->track_type = *p++; + fdi->track_len = *p++; + fdi->bit_rate = 0; + fdi->out = 0; + fdi->mfmsync_offset = 0; + + if ((fdi->track_type & 0xf0) == 0xf0 || (fdi->track_type & 0xf0) == 0xe0) + fdi->bit_rate = bit_rate_table[fdi->track_type & 0x0f]; + else + fdi->bit_rate = 250; + + outlog ("track %d: srclen: %d track_type: %02.2X, bitrate: %d\n", + fdi->current_track, fdi->track_src_len, fdi->track_type, fdi->bit_rate); + + if ((fdi->track_type & 0xc0) == 0x80) { + + outlen = decode_lowlevel_track (fdi, &indexoffset, track, cache); + + } else if ((fdi->track_type & 0xf0) == 0xf0) { + + outlen = decode_raw_track (fdi); + + } else if ((fdi->track_type & 0xf0) == 0xe0) { + + outlen = handle_sectors_described_track (fdi); + + } else if ((fdi->track_type & 0xf0)) { + + zxx (fdi); + outlen = -1; + + } else if (fdi->track_type < 0x10) { + + decode_normal_track[fdi->track_type](fdi); + fix_mfm_sync (fdi); + outlen = fdi->out; + + } else { + + zxx (fdi); + outlen = -1; + + } + +// amiga_check_track (fdi); + + if (fdi->err) + return 0; + + if (outlen > 0) { + if (cache->lowlevel) + return fdi2raw_loadrevolution_2 (fdi, mfmbuf, tracktiming, track, tracklength, indexoffsetp, multirev); + *tracklength = fdi->out; + for (i = 0; i < ((*tracklength) + 15) / (2 * 8); i++) { + uae_u8 *data = fdi->track_dst_buffer + i * 2; + *mfmbuf++ = 256 * *data + *(data + 1); + } + } + return outlen; +} + diff --git a/fdi2raw_old.c b/fdi2raw_old.c new file mode 100755 index 00000000..42efc71b --- /dev/null +++ b/fdi2raw_old.c @@ -0,0 +1,1835 @@ +/* + + FDI to raw bit stream converter + Copyright (c) 2001 by Toni Wilen + FDI 2.0 support + Copyright (c) 2003-2004 by Toni Wilen + and Vincent Joguin + + FDI format created by Vincent "ApH" Joguin + + Tiny changes - function type fixes, multiple drives, addition of + get_last_head and C++ callability - by Thomas Harte, 2001, + T.Harte@excite.co.uk + + + 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 +#include +#include + +/* IF UAE */ +#include "sysconfig.h" +#include "sysdeps.h" +#include "zfile.h" +/* ELSE */ +//#include "types.h" + +#include "fdi2raw.h" + +#undef DEBUG +#define VERBOSE + +#include + +#ifdef DEBUG +static char *datalog(uae_u8 *src, int len) +{ + static char buf[1000]; + static int offset; + int i = 0, offset2; + + offset2 = offset; + buf[offset++]='\''; + while(len--) { + sprintf (buf + offset, "%02.2X", src[i]); + offset += 2; + i++; + if (i > 10) break; + } + buf[offset++]='\''; + buf[offset++] = 0; + if (offset >= 900) offset = 0; + return buf + offset2; +} +#else +static char *datalog(uae_u8 *src, int len) { return ""; } +#endif + +#ifdef DEBUG +#define debuglog write_log +#else +#define debuglog +#endif +#ifdef VERBOSE +#define outlog write_log +#else +#define outlog +#endif + +static int fdi_allocated; +#ifdef DEBUG +static void fdi_free (void *p) +{ + int size; + if (!p) + return; + size = ((int*)p)[-1]; + fdi_allocated -= size; + write_log ("%d freed (%d)\n", size, fdi_allocated); + free ((int*)p - 1); +} +static void *fdi_malloc (int size) +{ + void *p = xmalloc (size + sizeof (int)); + ((int*)p)[0] = size; + fdi_allocated += size; + write_log ("%d allocated (%d)\n", size, fdi_allocated); + return (int*)p + 1; +} +#else +#define fdi_free free +#define fdi_malloc xmalloc +#endif + +#define MAX_SRC_BUFFER 4194304 +#define MAX_DST_BUFFER 40000 +#define MAX_MFM_SYNC_BUFFER 60000 +#define MAX_TIMING_BUFFER 400000 +#define MAX_TRACKS 166 +#define MAX_REVOLUTIONS 4 + +struct fdi_cache { + uae_u8 *cache_buffer[MAX_REVOLUTIONS]; + uae_u8 *cache_buffer_timing; + int length[MAX_REVOLUTIONS]; + int indexoffset; +}; + +struct fdi { + uae_u8 *track_src_buffer; + uae_u8 *track_src; + int track_src_len; + uae_u8 *track_dst_buffer; + uae_u8 *track_dst; + uae_u16 *track_dst_buffer_timing; + uae_u8 track_len; + uae_u8 track_type; + int current_track; + int last_track; + int last_head; + int rotation_speed; + int bit_rate; + int disk_type; + int write_protect; + int err; + uae_u8 header[2048]; + int track_offsets[MAX_TRACKS]; + struct zfile *file; + int out; + int mfmsync_offset; + int *mfmsync_buffer; + /* sector described only */ + int index_offset; + int encoding_type; + /* bit handling */ + int nextdrop; + struct fdi_cache cache[MAX_TRACKS]; +}; + +#define get_u32(x) ((((x)[0])<<24)|(((x)[1])<<16)|(((x)[2])<<8)|((x)[3])) +#define get_u24(x) ((((x)[0])<<16)|(((x)[1])<<8)|((x)[2])) +STATIC_INLINE put_u32 (uae_u8 *d, uae_u32 v) +{ + d[0] = v >> 24; + d[1] = v >> 16; + d[2] = v >> 8; + d[3] = v; +} + +struct node { + uae_u16 v; + struct node *left; + struct node *right; +}; +typedef struct node NODE; + +static uae_u8 temp, temp2; + +static uae_u8 *expand_tree (uae_u8 *stream, NODE *node) +{ + if (temp & temp2) { + fdi_free (node->left); + node->left = 0; + fdi_free (node->right); + node->right = 0; + temp2 >>= 1; + if (!temp2) { + temp = *stream++; + temp2 = 0x80; + } + return stream; + } else { + uae_u8 *stream_temp; + temp2 >>= 1; + if (!temp2) { + temp = *stream++; + temp2 = 0x80; + } + node->left = fdi_malloc (sizeof (NODE)); + memset (node->left, 0, sizeof (NODE)); + stream_temp = expand_tree (stream, node->left); + node->right = fdi_malloc (sizeof (NODE)); + memset (node->right, 0, sizeof (NODE)); + return expand_tree (stream_temp, node->right); + } +} + +static uae_u8 *values_tree8 (uae_u8 *stream, NODE *node) +{ + if (node->left == 0) { + node->v = *stream++; + return stream; + } else { + uae_u8 *stream_temp = values_tree8 (stream, node->left); + return values_tree8 (stream_temp, node->right); + } +} + +static uae_u8 *values_tree16 (uae_u8 *stream, NODE *node) +{ + if (node->left == 0) { + uae_u16 high_8_bits = (*stream++) << 8; + node->v = high_8_bits | (*stream++); + return stream; + } else { + uae_u8 *stream_temp = values_tree16 (stream, node->left); + return values_tree16 (stream_temp, node->right); + } +} + +static void free_nodes (NODE *node) +{ + if (node) { + free_nodes (node->left); + free_nodes (node->right); + fdi_free (node); + } +} + +static uae_u32 sign_extend16 (uae_u32 v) +{ + if (v & 0x8000) + v |= 0xffff0000; + return v; +} + +static uae_u32 sign_extend8 (uae_u32 v) +{ + if (v & 0x80) + v |= 0xffffff00; + return v; +} + +static void fdi_decode (uae_u8 *stream, int size, uae_u8 *out) +{ + int i; + uae_u8 sign_extend, sixteen_bit, sub_stream_shift; + NODE root; + NODE *current_node; + + memset (out, 0, size * 4); + sub_stream_shift = 1; + while (sub_stream_shift) { + + //sub-stream header decode + sign_extend = *stream++; + sub_stream_shift = sign_extend & 0x7f; + sign_extend &= 0x80; + sixteen_bit = (*stream++) & 0x80; + + //huffman tree architecture decode + temp = *stream++; + temp2 = 0x80; + stream = expand_tree (stream, &root); + if (temp2 == 0x80) + stream--; + + //huffman output values decode + if (sixteen_bit) + stream = values_tree16 (stream, &root); + else + stream = values_tree8 (stream, &root); + + //sub-stream data decode + temp2 = 0; + for (i = 0; i < size; i++) { + uae_u32 v; + uae_u8 decode = 1; + current_node = &root; + while (decode) { + if (current_node->left == 0) { + decode = 0; + } else { + temp2 >>= 1; + if (!temp2) { + temp2 = 0x80; + temp = *stream++; + } + if (temp & temp2) + current_node = current_node->right; + else + current_node = current_node->left; + } + } + v = ((uae_u32*)out)[i]; + if (sign_extend) { + if (sixteen_bit) + v |= sign_extend16 (current_node->v) << sub_stream_shift; + else + v |= sign_extend8 (current_node->v) << sub_stream_shift; + } else { + v |= current_node->v << sub_stream_shift; + } + ((uae_u32*)out)[i] = v; + } + free_nodes (root.left); + free_nodes (root.right); + } +} + + +static int decode_raw_track (FDI *fdi) +{ + int size = get_u32(fdi->track_src); + memcpy (fdi->track_dst, fdi->track_src, (size + 7) >> 3); + fdi->track_src += (size + 7) >> 3; + return size; +} + +/* unknown track */ +static void zxx (FDI *fdi) +{ + outlog ("track %d: unknown track type 0x%02.2X\n", fdi->current_track, fdi->track_type); +// return -1; +} +/* unsupported track */ +static void zyy (FDI *fdi) +{ + outlog ("track %d: unsupported track type 0x%02.2X\n", fdi->current_track, fdi->track_type); +// return -1; +} +/* empty track */ +static void track_empty (FDI *fdi) +{ +// return 0; +} + +/* unknown sector described type */ +static void dxx (FDI *fdi) +{ + outlog ("\ntrack %d: unknown sector described type 0x%02.2X\n", fdi->current_track, fdi->track_type); + fdi->err = 1; +} +/* unsupported sector described type */ +static void dyy (FDI *fdi) +{ + outlog ("\ntrack %d: unsupported sector described 0x%02.2X\n", fdi->current_track, fdi->track_type); + fdi->err = 1; +} +/* add position of mfm sync bit */ +static void add_mfm_sync_bit (FDI *fdi) +{ + if (fdi->nextdrop) { + fdi->nextdrop = 0; + return; + } + fdi->mfmsync_buffer[fdi->mfmsync_offset++] = fdi->out; + if (fdi->out == 0) { + outlog ("illegal position for mfm sync bit, offset=%d\n",fdi->out); + fdi->err = 1; + } + if (fdi->mfmsync_offset >= MAX_MFM_SYNC_BUFFER) { + fdi->mfmsync_offset = 0; + outlog ("mfmsync buffer overflow\n"); + fdi->err = 1; + } + fdi->out++; +} + +#define BIT_BYTEOFFSET ((fdi->out) >> 3) +#define BIT_BITOFFSET (7-((fdi->out)&7)) + +/* add one bit */ +static void bit_add (FDI *fdi, int bit) +{ + if (fdi->nextdrop) { + fdi->nextdrop = 0; + return; + } + fdi->track_dst[BIT_BYTEOFFSET] &= ~(1 << BIT_BITOFFSET); + if (bit) + fdi->track_dst[BIT_BYTEOFFSET] |= (1 << BIT_BITOFFSET); + fdi->out++; + if (fdi->out >= MAX_DST_BUFFER * 8) { + outlog ("destination buffer overflow\n"); + fdi->err = 1; + fdi->out = 1; + } +} +/* add bit and mfm sync bit */ +static void bit_mfm_add (FDI *fdi, int bit) +{ + add_mfm_sync_bit (fdi); + bit_add (fdi, bit); +} +/* remove following bit */ +static void bit_drop_next (FDI *fdi) +{ + if (fdi->nextdrop > 0) { + outlog("multiple bit_drop_next() called"); + } else if (fdi->nextdrop < 0) { + fdi->nextdrop = 0; + debuglog(":DNN:"); + return; + } + debuglog(":DN:"); + fdi->nextdrop = 1; +} + +/* ignore next bit_drop_next() */ +static void bit_dedrop (FDI *fdi) +{ + if (fdi->nextdrop) { + outlog("bit_drop_next called before bit_dedrop"); + } + fdi->nextdrop = -1; + debuglog(":BDD:"); +} + +/* add one byte */ +static void byte_add (FDI *fdi, uae_u8 v) +{ + int i; + for (i = 7; i >= 0; i--) + bit_add (fdi, v & (1 << i)); +} +/* add one word */ +static void word_add (FDI *fdi, uae_u16 v) +{ + byte_add (fdi, (uae_u8)(v >> 8)); + byte_add (fdi, (uae_u8)v); +} +/* add one byte and mfm encode it */ +static void byte_mfm_add (FDI *fdi, uae_u8 v) +{ + int i; + for (i = 7; i >= 0; i--) + bit_mfm_add (fdi, v & (1 << i)); +} +/* add multiple bytes and mfm encode them */ +static void bytes_mfm_add (FDI *fdi, uae_u8 v, int len) +{ + int i; + for (i = 0; i < len; i++) byte_mfm_add (fdi, v); +} +/* add one mfm encoded word and re-mfm encode it */ +static void word_post_mfm_add (FDI *fdi, uae_u16 v) +{ + int i; + for (i = 14; i >= 0; i -= 2) + bit_mfm_add (fdi, v & (1 << i)); +} + +/* bit 0 */ +static void s00(FDI *fdi) { bit_add (fdi, 0); } +/* bit 1*/ +static void s01(FDI *fdi) { bit_add (fdi, 1); } +/* 4489 */ +static void s02(FDI *fdi) { word_add (fdi, 0x4489); } +/* 5224 */ +static void s03(FDI *fdi) { word_add (fdi, 0x5224); } +/* mfm sync bit */ +static void s04(FDI *fdi) { add_mfm_sync_bit (fdi); } +/* RLE MFM-encoded data */ +static void s08(FDI *fdi) +{ + int bytes = *fdi->track_src++; + uae_u8 byte = *fdi->track_src++; + if (bytes == 0) bytes = 256; + debuglog ("s08:len=%d,data=%02.2X",bytes,byte); + while(bytes--) byte_add (fdi, byte); +} +/* RLE MFM-decoded data */ +static void s09(FDI *fdi) +{ + int bytes = *fdi->track_src++; + uae_u8 byte = *fdi->track_src++; + if (bytes == 0) bytes = 256; + bit_drop_next (fdi); + debuglog ("s09:len=%d,data=%02.2X",bytes,byte); + while(bytes--) byte_mfm_add (fdi, byte); +} +/* MFM-encoded data */ +static void s0a(FDI *fdi) +{ + int i, bits = (fdi->track_src[0] << 8) | fdi->track_src[1]; + uae_u8 b; + fdi->track_src += 2; + debuglog ("s0a:bits=%d,data=%s", bits, datalog(fdi->track_src, (bits + 7) / 8)); + while (bits >= 8) { + byte_add (fdi, *fdi->track_src++); + bits -= 8; + } + if (bits > 0) { + i = 7; + b = *fdi->track_src++; + while (bits--) { + bit_add (fdi, b & (1 << i)); + i--; + } + } +} +/* MFM-encoded data */ +static void s0b(FDI *fdi) +{ + int i, bits = ((fdi->track_src[0] << 8) | fdi->track_src[1]) + 65536; + uae_u8 b; + fdi->track_src += 2; + debuglog ("s0b:bits=%d,data=%s", bits, datalog(fdi->track_src, (bits + 7) / 8)); + while (bits >= 8) { + byte_add (fdi, *fdi->track_src++); + bits -= 8; + } + if (bits > 0) { + i = 7; + b = *fdi->track_src++; + while (bits--) { + bit_add (fdi, b & (1 << i)); + i--; + } + } +} +/* MFM-decoded data */ +static void s0c(FDI *fdi) +{ + int i, bits = (fdi->track_src[0] << 8) | fdi->track_src[1]; + uae_u8 b; + fdi->track_src += 2; + bit_drop_next (fdi); + debuglog ("s0c:bits=%d,data=%s", bits, datalog(fdi->track_src, (bits + 7) / 8)); + while (bits >= 8) { + byte_mfm_add (fdi, *fdi->track_src++); + bits -= 8; + } + if (bits > 0) { + i = 7; + b = *fdi->track_src++; + while(bits--) { + bit_mfm_add (fdi, b & (1 << i)); + i--; + } + } +} +/* MFM-decoded data */ +static void s0d(FDI *fdi) +{ + int i, bits = ((fdi->track_src[0] << 8) | fdi->track_src[1]) + 65536; + uae_u8 b; + fdi->track_src += 2; + bit_drop_next (fdi); + debuglog ("s0d:bits=%d,data=%s", bits, datalog(fdi->track_src, (bits + 7) / 8)); + while (bits >= 8) { + byte_mfm_add (fdi, *fdi->track_src++); + bits -= 8; + } + if (bits > 0) { + i = 7; + b = *fdi->track_src++; + while(bits--) { + bit_mfm_add (fdi, b & (1 << i)); + i--; + } + } +} + +/* ***** */ +/* AMIGA */ +/* ***** */ + +/* just for testing integrity of Amiga sectors */ + +static void rotateonebit (uae_u8 *start, uae_u8 *end, int shift) +{ + if (shift == 0) + return; + while (start <= end) { + start[0] <<= shift; + start[0] |= start[1] >> (8 - shift); + start++; + } +} + +static int check_offset; +static uae_u16 getmfmword (uae_u8 *mbuf) +{ + uae_u32 v; + + v = (mbuf[0] << 8) | (mbuf[1] << 0); + if (check_offset == 0) + return v; + v <<= 8; + v |= mbuf[2]; + v >>= check_offset; + return v; +} + +#define MFMMASK 0x55555555 +static uae_u32 getmfmlong (uae_u8 * mbuf) +{ + return ((getmfmword (mbuf) << 16) | getmfmword (mbuf + 2)) & MFMMASK; +} + +static int amiga_check_track (FDI *fdi) +{ + int i, j, secwritten = 0; + int fwlen = fdi->out / 8; + int length = 2 * fwlen; + int drvsec = 11; + uae_u32 odd, even, chksum, id, dlong; + uae_u8 *secdata; + uae_u8 secbuf[544]; + uae_u8 bigmfmbuf[60000]; + uae_u8 *mbuf, *mbuf2, *mend; + char sectable[22]; + uae_u8 *raw = fdi->track_dst_buffer; + int slabel, off; + int ok = 1; + + memset (bigmfmbuf, 0, sizeof (bigmfmbuf)); + mbuf = bigmfmbuf; + check_offset = 0; + for (i = 0; i < (fdi->out + 7) / 8; i++) + *mbuf++ = raw[i]; + off = fdi->out & 7; +#if 1 + if (off > 0) { + mbuf--; + *mbuf &= ~((1 << (8 - off)) - 1); + } + j = 0; + while (i < (fdi->out + 7) / 8 + 600) { + *mbuf++ |= (raw[j] >> off) | ((raw[j + 1]) << (8 - off)); + j++; + i++; + } +#endif + mbuf = bigmfmbuf; + + memset (sectable, 0, sizeof (sectable)); + //memcpy (mbuf + fwlen, mbuf, fwlen * sizeof (uae_u16)); + mend = bigmfmbuf + length; + mend -= (4 + 16 + 8 + 512); + + while (secwritten < drvsec) { + int trackoffs; + + for (;;) { + rotateonebit (bigmfmbuf, mend, 1); + if (getmfmword (mbuf) == 0) + break; + if (secwritten == 10) { + mbuf[0] = 0x44; + mbuf[1] = 0x89; + } +// check_offset++; + if (check_offset > 7) { + check_offset = 0; + mbuf++; + if (mbuf >= mend || *mbuf == 0) + break; + } + if (getmfmword (mbuf) == 0x4489) + break; + } + if (mbuf >= mend || *mbuf == 0) + break; + + rotateonebit (bigmfmbuf, mend, check_offset); + check_offset = 0; + mbuf2 = mbuf; + + while (getmfmword (mbuf) == 0x4489) + mbuf+= 1 * 2; + + odd = getmfmlong (mbuf); + even = getmfmlong (mbuf + 2 * 2); + mbuf += 4 * 2; + id = (odd << 1) | even; + + trackoffs = (id & 0xff00) >> 8; + if (trackoffs + 1 > drvsec) { + debuglog("illegal sector offset %d\n",trackoffs); + ok = 0; + mbuf = mbuf2; + continue; + } + if ((id >> 24) != 0xff) { + debuglog ("sector %d format type %02.2X?\n", trackoffs, id >> 24); + ok = 0; + } + chksum = odd ^ even; + slabel = 0; + for (i = 0; i < 4; i++) { + odd = getmfmlong (mbuf); + even = getmfmlong (mbuf + 8 * 2); + mbuf += 2* 2; + + dlong = (odd << 1) | even; + if (dlong) slabel = 1; + chksum ^= odd ^ even; + } + mbuf += 8 * 2; + odd = getmfmlong (mbuf); + even = getmfmlong (mbuf + 2 * 2); + mbuf += 4 * 2; + if (((odd << 1) | even) != chksum) { + debuglog("sector %d header crc error\n", trackoffs); + ok = 0; + mbuf = mbuf2; + continue; + } + debuglog("sector %d header crc ok\n", trackoffs); + if (((id & 0x00ff0000) >> 16) != (uae_u32)fdi->current_track) { + debuglog("illegal track number %d <> %d\n",fdi->current_track,(id & 0x00ff0000) >> 16); + ok++; + mbuf = mbuf2; + continue; + } + odd = getmfmlong (mbuf); + even = getmfmlong (mbuf + 2 * 2); + mbuf += 4 * 2; + chksum = (odd << 1) | even; + secdata = secbuf + 32; + for (i = 0; i < 128; i++) { + odd = getmfmlong (mbuf); + even = getmfmlong (mbuf + 256 * 2); + mbuf += 2 * 2; + dlong = (odd << 1) | even; + *secdata++ = (uae_u8) (dlong >> 24); + *secdata++ = (uae_u8) (dlong >> 16); + *secdata++ = (uae_u8) (dlong >> 8); + *secdata++ = (uae_u8) dlong; + chksum ^= odd ^ even; + } + mbuf += 256 * 2; + if (chksum) { + debuglog("sector %d data checksum error\n",trackoffs); + ok = 0; + } else if (sectable[trackoffs]) { + debuglog("sector %d already found?\n", trackoffs); + mbuf = mbuf2; + } else { + debuglog("sector %d ok\n",trackoffs); + if (slabel) debuglog("(non-empty sector header)\n"); + sectable[trackoffs] = 1; + secwritten++; + if (trackoffs == 9) + mbuf += 0x228; + } + } + for (i = 0; i < drvsec; i++) { + if (!sectable[i]) { + debuglog ("sector %d missing\n", i); + ok = 0; + } + } + return ok; +} + +static void amiga_data_raw (FDI *fdi, uae_u8 *secbuf, uae_u8 *crc, int len) +{ + int i; + uae_u8 crcbuf[4]; + + if (!crc) { + memset (crcbuf, 0, 4); + } else { + memcpy (crcbuf, crc ,4); + } + for (i = 0; i < 4; i++) + byte_mfm_add (fdi, crcbuf[i]); + for (i = 0; i < len; i++) + byte_mfm_add (fdi, secbuf[i]); +} + +static void amiga_data (FDI *fdi, uae_u8 *secbuf) +{ + uae_u16 mfmbuf[4 + 512]; + uae_u32 dodd, deven, dck; + int i; + + for (i = 0; i < 512; i += 4) { + deven = ((secbuf[i + 0] << 24) | (secbuf[i + 1] << 16) + | (secbuf[i + 2] << 8) | (secbuf[i + 3])); + dodd = deven >> 1; + deven &= 0x55555555; + dodd &= 0x55555555; + mfmbuf[(i >> 1) + 4] = (uae_u16) (dodd >> 16); + mfmbuf[(i >> 1) + 5] = (uae_u16) dodd; + mfmbuf[(i >> 1) + 256 + 4] = (uae_u16) (deven >> 16); + mfmbuf[(i >> 1) + 256 + 5] = (uae_u16) deven; + } + dck = 0; + for (i = 4; i < 4 + 512; i += 2) + dck ^= (mfmbuf[i] << 16) | mfmbuf[i + 1]; + deven = dodd = dck; + dodd >>= 1; + deven &= 0x55555555; + dodd &= 0x55555555; + mfmbuf[0] = (uae_u16) (dodd >> 16); + mfmbuf[1] = (uae_u16) dodd; + mfmbuf[2] = (uae_u16) (deven >> 16); + mfmbuf[3] = (uae_u16) deven; + + for (i = 0; i < 4 + 512; i ++) + word_post_mfm_add (fdi, mfmbuf[i]); +} + +static void amiga_sector_header (FDI *fdi, uae_u8 *header, uae_u8 *data, int sector, int untilgap) +{ + uae_u8 headerbuf[4], databuf[16]; + uae_u32 deven, dodd, hck; + uae_u16 mfmbuf[24]; + int i; + + byte_mfm_add (fdi, 0); + byte_mfm_add (fdi, 0); + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + if (header) { + memcpy (headerbuf, header, 4); + } else { + headerbuf[0] = 0xff; + headerbuf[1] = (uae_u8)fdi->current_track; + headerbuf[2] = (uae_u8)sector; + headerbuf[3] = (uae_u8)untilgap; + } + if (data) + memcpy (databuf, data, 16); + else + memset (databuf, 0, 16); + + deven = ((headerbuf[0] << 24) | (headerbuf[1] << 16) + | (headerbuf[2] << 8) | (headerbuf[3])); + dodd = deven >> 1; + deven &= 0x55555555; + dodd &= 0x55555555; + mfmbuf[0] = (uae_u16) (dodd >> 16); + mfmbuf[1] = (uae_u16) dodd; + mfmbuf[2] = (uae_u16) (deven >> 16); + mfmbuf[3] = (uae_u16) deven; + for (i = 0; i < 16; i += 4) { + deven = ((databuf[i] << 24) | (databuf[i + 1] << 16) + | (databuf[i + 2] << 8) | (databuf[i + 3])); + dodd = deven >> 1; + deven &= 0x55555555; + dodd &= 0x55555555; + mfmbuf[(i >> 1) + 0 + 4] = (uae_u16) (dodd >> 16); + mfmbuf[(i >> 1) + 0 + 5] = (uae_u16) dodd; + mfmbuf[(i >> 1) + 8 + 4] = (uae_u16) (deven >> 16); + mfmbuf[(i >> 1) + 8 + 5] = (uae_u16) deven; + } + hck = 0; + for (i = 0; i < 4 + 16; i += 2) + hck ^= (mfmbuf[i] << 16) | mfmbuf[i + 1]; + deven = dodd = hck; + dodd >>= 1; + deven &= 0x55555555; + dodd &= 0x55555555; + mfmbuf[20] = (uae_u16) (dodd >> 16); + mfmbuf[21] = (uae_u16) dodd; + mfmbuf[22] = (uae_u16) (deven >> 16); + mfmbuf[23] = (uae_u16) deven; + + for (i = 0; i < 4 + 16 + 4; i ++) + word_post_mfm_add (fdi, mfmbuf[i]); +} + +/* standard super-extended Amiga sector header */ +static void s20(FDI *fdi) +{ + bit_drop_next (fdi); + debuglog ("s20:header=%s,data=%s", datalog(fdi->track_src, 4), datalog(fdi->track_src + 4, 16)); + amiga_sector_header (fdi, fdi->track_src, fdi->track_src + 4, 0, 0); + fdi->track_src += 4 + 16; +} +/* standard extended Amiga sector header */ +static void s21(FDI *fdi) +{ + bit_drop_next (fdi); + debuglog ("s21:header=%s", datalog(fdi->track_src, 4)); + amiga_sector_header (fdi, fdi->track_src, 0, 0, 0); + fdi->track_src += 4; +} +/* standard Amiga sector header */ +static void s22(FDI *fdi) +{ + bit_drop_next (fdi); + debuglog("s22:sector=%d,untilgap=%d", fdi->track_src[0], fdi->track_src[1]); + amiga_sector_header (fdi, 0, 0, fdi->track_src[0], fdi->track_src[1]); + fdi->track_src += 2; +} +/* standard 512-byte, CRC-correct Amiga data */ +static void s23(FDI *fdi) +{ + debuglog("s23:data=%s", datalog (fdi->track_src, 512)); + amiga_data (fdi, fdi->track_src); + fdi->track_src += 512; +} +/* not-decoded, 128*2^x-byte, CRC-correct Amiga data */ +static void s24(FDI *fdi) +{ + int shift = *fdi->track_src++; + debuglog("s24:shift=%d,data=%s", shift, datalog (fdi->track_src, 128 << shift)); + amiga_data_raw (fdi, fdi->track_src, 0, 128 << shift); + fdi->track_src += 128 << shift; +} +/* not-decoded, 128*2^x-byte, CRC-incorrect Amiga data */ +static void s25(FDI *fdi) +{ + int shift = *fdi->track_src++; + debuglog("s25:shift=%d,crc=%s,data=%s", shift, datalog (fdi->track_src, 4), datalog (fdi->track_src + 4, 128 << shift)); + amiga_data_raw (fdi, fdi->track_src + 4, fdi->track_src, 128 << shift); + fdi->track_src += 4 + (128 << shift); +} +/* standard extended Amiga sector */ +static void s26(FDI *fdi) +{ + s21 (fdi); + debuglog("s26:data=%s", datalog (fdi->track_src, 512)); + amiga_data (fdi, fdi->track_src); + fdi->track_src += 512; +} +/* standard short Amiga sector */ +static void s27(FDI *fdi) +{ + s22 (fdi); + debuglog("s27:data=%s", datalog (fdi->track_src, 512)); + amiga_data (fdi, fdi->track_src); + fdi->track_src += 512; +} + +/* *** */ +/* IBM */ +/* *** */ + +static uae_u16 ibm_crc (uae_u8 byte, int reset) +{ + static uae_u16 crc; + int i; + + if (reset) crc = 0xcdb4; + for (i = 0; i < 8; i++) { + if (crc & 0x8000) { + crc <<= 1; + if (!(byte & 0x80)) crc ^= 0x1021; + } else { + crc <<= 1; + if (byte & 0x80) crc ^= 0x1021; + } + byte <<= 1; + } + return crc; +} + +static void ibm_data (FDI *fdi, uae_u8 *data, uae_u8 *crc, int len) +{ + int i; + uae_u8 crcbuf[2]; + uae_u16 crcv; + + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + byte_mfm_add (fdi, 0xfb); + ibm_crc (0xfb, 1); + for (i = 0; i < len; i++) { + byte_mfm_add (fdi, data[i]); + crcv = ibm_crc (data[i], 0); + } + if (!crc) { + crc = crcbuf; + crc[0] = (uae_u8)(crcv >> 8); + crc[1] = (uae_u8)crcv; + } + byte_mfm_add (fdi, crc[0]); + byte_mfm_add (fdi, crc[1]); +} + +static void ibm_sector_header (FDI *fdi, uae_u8 *data, uae_u8 *crc, int secnum, int pre) +{ + uae_u8 secbuf[5]; + uae_u8 crcbuf[2]; + uae_u16 crcv; + int i; + + if (pre) + bytes_mfm_add (fdi, 0, 12); + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + word_add (fdi, 0x4489); + secbuf[0] = 0xfe; + if (secnum >= 0) { + secbuf[1] = (uae_u8)(fdi->current_track/2); + secbuf[2] = (uae_u8)(fdi->current_track%2); + secbuf[3] = (uae_u8)secnum; + secbuf[4] = 2; + } else { + memcpy (secbuf + 1, data, 4); + } + ibm_crc (secbuf[0], 1); + ibm_crc (secbuf[1], 0); + ibm_crc (secbuf[2], 0); + ibm_crc (secbuf[3], 0); + crcv = ibm_crc (secbuf[4], 0); + if (crc) { + memcpy (crcbuf, crc, 2); + } else { + crcbuf[0] = (uae_u8)(crcv >> 8); + crcbuf[1] = (uae_u8)crcv; + } + /* data */ + for (i = 0;i < 5; i++) + byte_mfm_add (fdi, secbuf[i]); + /* crc */ + byte_mfm_add (fdi, crcbuf[0]); + byte_mfm_add (fdi, crcbuf[1]); +} + +/* standard IBM index address mark */ +static void s10(FDI *fdi) +{ + bit_drop_next (fdi); + bytes_mfm_add (fdi, 0, 12); + word_add (fdi, 0x5224); + word_add (fdi, 0x5224); + word_add (fdi, 0x5224); + byte_mfm_add (fdi, 0xfc); +} +/* standard IBM pre-gap */ +static void s11(FDI *fdi) +{ + bit_drop_next (fdi); + bytes_mfm_add (fdi, 0x4e, 78); + bit_dedrop (fdi); + s10 (fdi); + bytes_mfm_add (fdi, 0x4e, 50); +} +/* standard ST pre-gap */ +static void s12(FDI *fdi) +{ + bit_drop_next (fdi); + bytes_mfm_add (fdi, 0x4e, 78); +} +/* standard extended IBM sector header */ +static void s13(FDI *fdi) +{ + bit_drop_next (fdi); + debuglog ("s13:header=%s", datalog (fdi->track_src, 4)); + ibm_sector_header (fdi, fdi->track_src, 0, -1, 1); + fdi->track_src += 4; +} +/* standard mini-extended IBM sector header */ +static void s14(FDI *fdi) +{ + debuglog ("s14:header=%s", datalog (fdi->track_src, 4)); + ibm_sector_header (fdi, fdi->track_src, 0, -1, 0); + fdi->track_src += 4; +} +/* standard short IBM sector header */ +static void s15(FDI *fdi) +{ + bit_drop_next (fdi); + debuglog ("s15:sector=%d", *fdi->track_src); + ibm_sector_header (fdi, 0, 0, *fdi->track_src++, 1); +} +/* standard mini-short IBM sector header */ +static void s16(FDI *fdi) +{ + debuglog ("s16:track=%d", *fdi->track_src); + ibm_sector_header (fdi, 0, 0, *fdi->track_src++, 0); +} +/* standard CRC-incorrect mini-extended IBM sector header */ +static void s17(FDI *fdi) +{ + debuglog ("s17:header=%s,crc=%s", datalog (fdi->track_src, 4), datalog (fdi->track_src + 4, 2)); + ibm_sector_header (fdi, fdi->track_src, fdi->track_src + 4, -1, 0); + fdi->track_src += 4 + 2; +} +/* standard CRC-incorrect mini-short IBM sector header */ +static void s18(FDI *fdi) +{ + debuglog ("s18:sector=%d,header=%s", *fdi->track_src, datalog (fdi->track_src + 1, 4)); + ibm_sector_header (fdi, 0, fdi->track_src + 1, *fdi->track_src, 0); + fdi->track_src += 1 + 4; +} +/* standard 512-byte CRC-correct IBM data */ +static void s19(FDI *fdi) +{ + debuglog ("s19:data=%s", datalog (fdi->track_src , 512)); + ibm_data (fdi, fdi->track_src, 0, 512); + fdi->track_src += 512; +} +/* standard 128*2^x-byte-byte CRC-correct IBM data */ +static void s1a(FDI *fdi) +{ + int shift = *fdi->track_src++; + debuglog ("s1a:shift=%d,data=%s", shift, datalog (fdi->track_src , 128 << shift)); + ibm_data (fdi, fdi->track_src, 0, 128 << shift); + fdi->track_src += 128 << shift; +} +/* standard 128*2^x-byte-byte CRC-incorrect IBM data */ +static void s1b(FDI *fdi) +{ + int shift = *fdi->track_src++; + debuglog ("s1b:shift=%d,crc=%s,data=%s", shift, datalog (fdi->track_src + (128 << shift), 2), datalog (fdi->track_src , 128 << shift)); + ibm_data (fdi, fdi->track_src, fdi->track_src + (128 << shift), 128 << shift); + fdi->track_src += (128 << shift) + 2; +} +/* standard extended IBM sector */ +static void s1c(FDI *fdi) +{ + int shift = fdi->track_src[3]; + s13 (fdi); + bytes_mfm_add (fdi, 0x4e, 22); + bytes_mfm_add (fdi, 0x00, 12); + ibm_data (fdi, fdi->track_src, 0, 128 << shift); + fdi->track_src += 128 << shift; +} +/* standard short IBM sector */ +static void s1d(FDI *fdi) +{ + s15 (fdi); + bytes_mfm_add (fdi, 0x4e, 22); + bytes_mfm_add (fdi, 0x00, 12); + s19 (fdi); +} + +/* end marker */ +static void sff(FDI *fdi) +{ +} + +typedef void (*decode_described_track_func)(FDI*); + +static decode_described_track_func decode_sectors_described_track[] = +{ + s00,s01,s02,s03,s04,dxx,dxx,dxx,s08,s09,s0a,s0b,s0c,s0d,dxx,dxx, /* 00-0F */ + s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s1a,s1b,s1c,s1d,dxx,dxx, /* 10-1F */ + s20,s21,s22,s23,s24,s25,s26,s27,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 20-2F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 30-3F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 40-4F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 50-5F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 60-6F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 70-7F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 80-8F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* 90-9F */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* A0-AF */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* B0-BF */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* C0-CF */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* D0-DF */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx, /* E0-EF */ + dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,dxx,sff /* F0-FF */ +}; + +static void track_amiga (struct fdi *fdi, int first_sector, int max_sector) +{ + int i; + + bit_add (fdi, 0); + bit_drop_next (fdi); + for (i = 0; i < max_sector; i++) { + amiga_sector_header (fdi, 0, 0, first_sector, max_sector - i); + amiga_data (fdi, fdi->track_src + first_sector * 512); + first_sector++; + if (first_sector >= max_sector) first_sector = 0; + } + bytes_mfm_add (fdi, 0, 260); /* gap */ +} +static void track_atari_st (struct fdi *fdi, int max_sector) +{ + int i, gap3; + uae_u8 *p = fdi->track_src; + + switch (max_sector) + { + case 9: + gap3 = 40; + break; + case 10: + gap3 = 24; + break; + } + s15 (fdi); + for (i = 0; i < max_sector; i++) { + byte_mfm_add (fdi, 0x4e); + byte_mfm_add (fdi, 0x4e); + ibm_sector_header (fdi, 0, 0, fdi->current_track, 1); + ibm_data (fdi, p + i * 512, 0, 512); + bytes_mfm_add (fdi, 0x4e, gap3); + } + bytes_mfm_add (fdi, 0x4e, 660 - gap3); + fdi->track_src += fdi->track_len * 256; +} +static void track_pc (struct fdi *fdi, int max_sector) +{ + int i, gap3; + uae_u8 *p = fdi->track_src; + + switch (max_sector) + { + case 8: + gap3 = 116; + break; + case 9: + gap3 = 54; + break; + default: + gap3 = 100; /* fixme */ + break; + } + s11 (fdi); + for (i = 0; i < max_sector; i++) { + byte_mfm_add (fdi, 0x4e); + byte_mfm_add (fdi, 0x4e); + ibm_sector_header (fdi, 0, 0, fdi->current_track, 1); + ibm_data (fdi, p + i * 512, 0, 512); + bytes_mfm_add (fdi, 0x4e, gap3); + } + bytes_mfm_add (fdi, 0x4e, 600 - gap3); + fdi->track_src += fdi->track_len * 256; +} + +/* amiga dd */ +static void track_amiga_dd (struct fdi *fdi) +{ + uae_u8 *p = fdi->track_src; + track_amiga (fdi, fdi->track_len >> 4, 11); + fdi->track_src = p + (fdi->track_len & 15) * 512; +} +/* amiga hd */ +static void track_amiga_hd (struct fdi *fdi) +{ + uae_u8 *p = fdi->track_src; + track_amiga (fdi, 0, 22); + fdi->track_src = p + fdi->track_len * 256; +} +/* atari st 9 sector */ +static void track_atari_st_9 (struct fdi *fdi) +{ + track_atari_st (fdi, 9); +} +/* atari st 10 sector */ +static void track_atari_st_10 (struct fdi *fdi) +{ + track_atari_st (fdi, 10); +} +/* pc 8 sector */ +static void track_pc_8 (struct fdi *fdi) +{ + track_pc (fdi, 8); +} +/* pc 9 sector */ +static void track_pc_9 (struct fdi *fdi) +{ + track_pc (fdi, 9); +} +/* pc 15 sector */ +static void track_pc_15 (struct fdi *fdi) +{ + track_pc (fdi, 15); +} +/* pc 18 sector */ +static void track_pc_18 (struct fdi *fdi) +{ + track_pc (fdi, 18); +} +/* pc 36 sector */ +static void track_pc_36 (struct fdi *fdi) +{ + track_pc (fdi, 36); +} + +typedef void (*decode_normal_track_func)(FDI*); + +static decode_normal_track_func decode_normal_track[] = +{ + track_empty, /* 0 */ + track_amiga_dd, track_amiga_hd, /* 1-2 */ + track_atari_st_9, track_atari_st_10, /* 3-4 */ + track_pc_8, track_pc_9, track_pc_15, track_pc_18, track_pc_36, /* 5-9 */ + zxx,zxx,zxx,zxx,zxx /* A-F */ +}; + +static void fix_mfm_sync (FDI *fdi) +{ + int i, pos, off1, off2, off3, mask1, mask2, mask3; + + for (i = 0; i < fdi->mfmsync_offset; i++) { + pos = fdi->mfmsync_buffer[i]; + off1 = (pos - 1) >> 3; + off2 = (pos + 1) >> 3; + off3 = pos >> 3; + mask1 = 1 << (7 - ((pos - 1) & 7)); + mask2 = 1 << (7 - ((pos + 1) & 7)); + mask3 = 1 << (7 - (pos & 7)); + if (!(fdi->track_dst[off1] & mask1) && !(fdi->track_dst[off2] & mask2)) + fdi->track_dst[off3] |= mask3; + else + fdi->track_dst[off3] &= ~mask3; + } +} + +static int handle_sectors_described_track (FDI *fdi) +{ + int oldout; + uae_u8 *start_src = fdi->track_src ; + fdi->encoding_type = *fdi->track_src++; + fdi->index_offset = get_u32(fdi->track_src); + fdi->index_offset >>= 8; + fdi->track_src += 3; + outlog ("sectors_described, index offset: %d\n",fdi->index_offset); + + do { + fdi->track_type = *fdi->track_src++; + outlog ("%06.6X %06.6X %02.2X:",fdi->track_src - start_src + 0x200, fdi->out/8, fdi->track_type); + oldout = fdi->out; + decode_sectors_described_track[fdi->track_type](fdi); + outlog(" %d\n", fdi->out - oldout); + oldout = fdi->out; + if (fdi->out < 0 || fdi->err) { + outlog ("\nin %d bytes, out %d bits\n", fdi->track_src - fdi->track_src_buffer, fdi->out); + return -1; + } + if (fdi->track_src - fdi->track_src_buffer >= fdi->track_src_len) { + outlog ("source buffer overrun, previous type: %02.2X\n", fdi->track_type); + return -1; + } + } while (fdi->track_type != 0xff); + outlog("\n"); + fix_mfm_sync (fdi); + return fdi->out; +} + +static uae_u8 *fdi_decompress (int pulses, uae_u8 *sizep, uae_u8 *src, int *dofree) +{ + uae_u32 size = get_u24 (sizep); + uae_u32 *dst2; + int len = size & 0x3fffff; + uae_u8 *dst; + int mode = size >> 22, i; + + *dofree = 0; + if (mode == 0 && pulses * 2 > len) + mode = 1; + if (mode == 0) { + dst2 = (uae_u32*)src; + for (i = 0; i < pulses; i++) { + *dst2++ = get_u32 (src); + src += 4; + } + dst = src; + } else if (mode == 1) { + dst = fdi_malloc (pulses *4); + *dofree = 1; + fdi_decode (src, pulses, dst); + } else { + dst = 0; + } + return dst; +} + +static void dumpstream(int track, uae_u8 *stream, int len) +{ + char name[100]; + FILE *f; + + sprintf (name, "track_%d.raw", track); + f = fopen(name, "wb"); + fwrite (stream, 1, len * 4, f); + fclose (f); +} + +static int bitoffset; + +STATIC_INLINE void addbit (uae_u8 *p, int bit) +{ + int off1 = bitoffset / 8; + int off2 = bitoffset % 8; + p[off1] |= bit << (7 - off2); + bitoffset++; +} + + +struct pulse_sample { + unsigned long size; + int number_of_bits; +}; + +#define FDI_MAX_ARRAY 6 /* change this value as you want */ +static int pulse_limitval = 20; +static struct pulse_sample psarray[FDI_MAX_ARRAY]; +static int array_index; +static unsigned long total; +static int totaldiv; + +static void init_array(unsigned long standard_MFM_2_bit_cell_size) +{ + int i; + + for (i = 0; i < FDI_MAX_ARRAY; i++) { + psarray[i].size = standard_MFM_2_bit_cell_size; // That is (total track length / 50000) for Amiga double density + total += psarray[i].size; + psarray[i].number_of_bits = 2; + totaldiv += psarray[i].number_of_bits; + } + array_index = 0; +} + +static void fdi2_mfm_decode(FDI *fdi, unsigned long totalavg, uae_u32 *avgp, uae_u8 *idx, int idx_off1, int idx_off2, int idx_off3, int maxidx, int pulses) +{ + unsigned long adjust; + unsigned long adjusted_pulse; + unsigned long standard_MFM_2_bit_cell_size = totalavg / 50000; + int real_size, i, j; + uae_u8 *d = fdi->track_dst_buffer; + uae_u16 *pt = fdi->track_dst_buffer_timing; + + adjust = 0; + total = 0; + totaldiv = 0; + init_array(standard_MFM_2_bit_cell_size); + bitoffset = 0; + for (i = 0; i < pulses; i++) + { + if (idx[idx_off1] + idx[idx_off2] >= maxidx) { + uae_u32 pulse = avgp[i]; + uae_u32 avg_size = total / totaldiv; /* this is the new average size for one MFM bit */ + /* you can try tighter ranges than 25%, or wider ranges. I would probably go for tighter... */ + if ((avg_size < ((standard_MFM_2_bit_cell_size / 2) - (pulse_limitval * standard_MFM_2_bit_cell_size / 200))) || + (avg_size > ((standard_MFM_2_bit_cell_size / 2) + (pulse_limitval * standard_MFM_2_bit_cell_size /200)))) + init_array(standard_MFM_2_bit_cell_size); + /* this is to prevent the average value from going too far + * from the theoretical value, otherwise it could progressively go to (2 * + * real value), or (real value / 2), etc. */ + if ((pulse > adjust) && (adjust < avg_size)) + adjusted_pulse = pulse - adjust; + else + adjusted_pulse = pulse; + adjusted_pulse = pulse; + real_size = 1; + do { + addbit (d, 0); + real_size++; + } while (adjusted_pulse > avg_size * real_size + avg_size / 2); + addbit (d, 1); +#if 1 + for (j = 0; j < real_size; j++) + *pt++ = (uae_u16)(adjusted_pulse / real_size); +#endif + /* Note that you should also consider values above 4! Too lazy to do it here ;-) */ + adjust = (real_size * avg_size) - pulse; + /* function to transform the value in real_size to '01', '001' or '0001', and append this to the decoded MFM stream */ + total -= psarray[array_index].size; + totaldiv -= psarray[array_index].number_of_bits; + psarray[array_index].size = pulse; + psarray[array_index].number_of_bits = real_size; + total += pulse; + totaldiv += real_size; + array_index++; + if (array_index >= FDI_MAX_ARRAY) + array_index = 0; + } + idx += idx_off3; + } + fdi->out = bitoffset; + write_log ("result bits: %d\n", bitoffset); +} + +static void fdi2_celltiming (FDI *fdi, unsigned long totalavg, int bitoffset) +{ + uae_u16 *pt2, *pt; + double avg_bit_len; + int timed = 0; + int i; + + avg_bit_len = (double)totalavg / (double)bitoffset; + pt2 = pt = fdi->track_dst_buffer_timing; + for (i = 0; i < bitoffset / 8; i++) { + double v = (pt2[0] + pt2[1] + pt2[2] + pt2[3] + pt2[4] + pt2[5] + pt2[6] + pt2[7]) / 8.0; + uae_u16 vv; + v = 1000.0 * v / avg_bit_len; + vv = (uae_u16)v; + *pt++ = vv; + if (vv > 1030 || vv < 970) + timed = 1; + pt2 += 8; + if (vv > 1030 || vv < 970) + write_log ("%d ", vv); + } + *pt++ = fdi->track_dst_buffer_timing[0]; + *pt = fdi->track_dst_buffer_timing[0]; + if (!timed) + fdi->track_dst_buffer_timing[0] = 0; +} + +static int decode_lowlevel_track (FDI *fdi, int *indexoffsetp, int track) +{ + uae_u8 *p1, *d; + uae_u32 *p2; + uae_u32 *avgp, *minp = 0, *maxp = 0; + uae_u8 *idxp = 0; + uae_u32 maxidx, minidx, totalavg, weakbits; + int i, len, pulses, indexoffset; + int avg_free, min_free = 0, max_free = 0, idx_free; + int idx_off1, idx_off2, idx_off3; + + d = fdi->track_dst; + p1 = fdi->track_src; + pulses = get_u32 (p1); + if (!pulses) + return -1; + p1 += 4; + len = 12; + avgp = (uae_u32*)fdi_decompress (pulses, p1 + 0, p1 + len, &avg_free); + //dumpstream(track, (uae_u8*)avgp, pulses); + len += get_u24 (p1 + 0) & 0x3fffff; + if (!avgp) + return -1; + if (get_u24 (p1 + 3) && get_u24 (p1 + 6)) { +#if 0 + minp = (uae_u32*)fdi_decompress (pulses, p1 + 3, p1 + len, &min_free); +#endif + len += get_u24 (p1 + 3) & 0x3fffff; +#if 0 + maxp = (uae_u32*)fdi_decompress (pulses, p1 + 6, p1 + len, &max_free); +#endif + len += get_u24 (p1 + 6) & 0x3fffff; + } + if (get_u24 (p1 + 9)) { + idx_off1 = 0; + idx_off2 = 1; + idx_off3 = 2; + idxp = fdi_decompress (pulses, p1 + 9, p1 + len, &idx_free); + if (idx_free) { + if (idxp[0] == 0 && idxp[1] == 0) { + idx_off1 = 2; + idx_off2 = 3; + } else { + idx_off1 = 1; + idx_off2 = 0; + } + idx_off3 = 4; + } + } else { + idxp = fdi_malloc (pulses * 2); + idx_free = 1; + for (i = 0; i < pulses; i++) { + idxp[i * 2 + 0] = 2; + idxp[i * 2 + 1] = 0; + } + idxp[0] = 1; + idxp[1] = 1; + } + + maxidx = 0; + minidx = 255; + indexoffset = 0; + p1 = idxp; + for (i = 0; i < pulses; i++) { + if (p1[idx_off1] + p1[idx_off2] > maxidx) + maxidx = p1[idx_off1] + p1[idx_off2]; + if (abs (p1[idx_off1] - p1[idx_off2]) < minidx) { + minidx = abs (p1[idx_off1] - p1[idx_off2]); + indexoffset = i; + } + p1 += idx_off3; + } + p1 = idxp; + p2 = avgp; + totalavg = 0; + weakbits = 0; + for (i = 0; i < pulses; i++) { + if (p1[idx_off1] + p1[idx_off2] >= maxidx) { + totalavg += *p2; + } else { + weakbits++; + } + p2++; + p1 += idx_off3; + } + len = totalavg / 100000; + outlog("totalavg=%d index=%d maxidx=%d weakbits=%d len=%d\n", + totalavg, indexoffset, maxidx, weakbits, len); + fdi2_mfm_decode (fdi, totalavg, avgp, idxp, idx_off1, idx_off2, idx_off3, maxidx, pulses); + outlog("number of bits=%d avg len=%.2f\n", bitoffset, (double)totalavg / bitoffset); + fdi2_celltiming (fdi, totalavg, bitoffset); + + *indexoffsetp = indexoffset; + if (avg_free) + fdi_free (avgp); + if (min_free) + fdi_free (minp); + if (max_free) + fdi_free (maxp); + if (idx_free) + fdi_free (idxp); + return bitoffset; +} + +static unsigned char fdiid[]={"Formatted Disk Image file"}; +static int bit_rate_table[16] = { 125,150,250,300,500,1000 }; + +void fdi2raw_header_free (FDI *fdi) +{ + int i, j; + + fdi_free (fdi->mfmsync_buffer); + fdi_free (fdi->track_src_buffer); + fdi_free (fdi->track_dst_buffer); + fdi_free (fdi->track_dst_buffer_timing); + for (i = 0; i < MAX_TRACKS; i++) { + struct fdi_cache *c = &fdi->cache[i]; + for (j = 0; j < MAX_REVOLUTIONS; j++) + fdi_free (c->cache_buffer[j]); + fdi_free (c->cache_buffer_timing); + } + fdi_free (fdi); +#ifdef DEBUG + write_log ("FREE: memory allocated %d\n", fdi_allocated); +#endif +} + +int fdi2raw_get_last_track (FDI *fdi) +{ + return fdi->last_track; +} + +int fdi2raw_get_num_sector (FDI *fdi) +{ + if (fdi->header[152] == 0x02) + return 22; + return 11; +} + +int fdi2raw_get_last_head (FDI *fdi) +{ + return fdi->last_head; +} + +int fdi2raw_get_rotation (FDI *fdi) +{ + return fdi->rotation_speed; +} + +int fdi2raw_get_bit_rate (FDI *fdi) +{ + return fdi->bit_rate; +} + +int fdi2raw_get_type (FDI *fdi) +{ + return fdi->disk_type; +} + +int fdi2raw_get_write_protect (FDI *fdi) +{ + return fdi->write_protect; +} + +FDI *fdi2raw_header(struct zfile *f) +{ + int i, offset, oldseek; + uae_u8 type, size; + FDI *fdi; + +#ifdef DEBUG + write_log ("ALLOC: memory allocated %d\n", fdi_allocated); +#endif + fdi = fdi_malloc(sizeof(FDI)); + memset (fdi, 0, sizeof (FDI)); + fdi->file = f; + oldseek = zfile_ftell (fdi->file); + zfile_fseek (fdi->file, 0, SEEK_SET); + zfile_fread (fdi->header, 2048, 1, fdi->file); + zfile_fseek (fdi->file, oldseek, SEEK_SET); + if (memcmp (fdiid, fdi->header, strlen (fdiid)) ) { + fdi_free(fdi); + return NULL; + } + if ((fdi->header[140] != 1 && fdi->header[140] != 2) || fdi->header[141] != 0) { + fdi_free(fdi); + return NULL; + } + + fdi->mfmsync_buffer = fdi_malloc (MAX_MFM_SYNC_BUFFER * sizeof(int)); + fdi->track_src_buffer = fdi_malloc (MAX_SRC_BUFFER); + fdi->track_dst_buffer = fdi_malloc (MAX_DST_BUFFER); + fdi->track_dst_buffer_timing = fdi_malloc (MAX_TIMING_BUFFER); + + fdi->last_track = ((fdi->header[142] << 8) + fdi->header[143]) + 1; + fdi->last_track *= fdi->header[144] + 1; + if (fdi->last_track > MAX_TRACKS) + fdi->last_track = MAX_TRACKS; + fdi->last_head = fdi->header[144]; + fdi->disk_type = fdi->header[145]; + fdi->rotation_speed = fdi->header[146] + 128; + fdi->write_protect = fdi->header[147] & 1; + outlog ("FDI version %d.%d\n", fdi->header[140], fdi->header[141]); + outlog ("last_track=%d rotation_speed=%d\n",fdi->last_track,fdi->rotation_speed); + + offset = 512; + i = fdi->last_track; + if (i > 180) { + offset += 512; + i -= 180; + while (i > 256) { + offset += 512; + i -= 256; + } + } + for (i = 0; i < fdi->last_track; i++) { + fdi->track_offsets[i] = offset; + type = fdi->header[152 + i * 2]; + size = fdi->header[152 + i * 2 + 1]; + if (type == 1) + offset += (size & 15) * 512; + else if ((type & 0xc0) == 0x80) + offset += (((type & 0x3f) << 8) | size) * 256; + else + offset += size * 256; + } + fdi->track_offsets[i] = offset; + + return fdi; +} + + +int fdi2raw_loadrevolution (FDI *fdi, uae_u16 *mfmbuf, uae_u16 *tracktiming, int track, int *tracklength) +{ + return 0; +} + +int fdi2raw_loadtrack (FDI *fdi, uae_u16 *mfmbuf, uae_u16 *tracktiming, int track, int *tracklength, int *indexoffsetp, int *multirev) +{ + uae_u8 *p; + int outlen, i, j, indexoffset = 0; + struct fdi_cache *cache; + + cache = &fdi->cache[track]; + if (cache->cache_buffer[0]) { + *tracklength = cache->length[0]; + for (i = 0; i < (tracklength[0] + 15) / (2 * 8); i++) { + uae_u8 *data = cache->cache_buffer[0] + i * 2; + *mfmbuf++ = 256 * *data + *(data + 1); + } + if (cache->cache_buffer_timing) + memcpy (tracktiming, cache->cache_buffer_timing, (tracklength[0] + 7) / 8 * sizeof (uae_u16)); + *indexoffsetp = cache->indexoffset; + return 1; + } + + fdi->err = 0; + fdi->track_src_len = fdi->track_offsets[track + 1] - fdi->track_offsets[track]; + zfile_fseek (fdi->file, fdi->track_offsets[track], SEEK_SET); + zfile_fread (fdi->track_src_buffer, fdi->track_src_len, 1, fdi->file); + memset (fdi->track_dst_buffer, 0, MAX_DST_BUFFER); + fdi->track_dst_buffer_timing[0] = 0; + + fdi->current_track = track; + fdi->track_src = fdi->track_src_buffer; + fdi->track_dst = fdi->track_dst_buffer; + p = fdi->header + 152 + fdi->current_track * 2; + fdi->track_type = *p++; + fdi->track_len = *p++; + fdi->bit_rate = 0; + fdi->out = 0; + fdi->mfmsync_offset = 0; + + if ((fdi->track_type & 0xf0) == 0xf0 || (fdi->track_type & 0xf0) == 0xe0) + fdi->bit_rate = bit_rate_table[fdi->track_type & 0x0f]; + else + fdi->bit_rate = 250; + + outlog ("track %d: srclen: %d track_type: %02.2X, bitrate: %d\n", + fdi->current_track, fdi->track_src_len, fdi->track_type, fdi->bit_rate); + + if ((fdi->track_type & 0xc0) == 0x80) { + + outlen = decode_lowlevel_track (fdi, &indexoffset, track); + + } else if ((fdi->track_type & 0xf0) == 0xf0) { + + outlen = decode_raw_track (fdi); + + } else if ((fdi->track_type & 0xf0) == 0xe0) { + + outlen = handle_sectors_described_track (fdi); + + } else if ((fdi->track_type & 0xf0)) { + + zxx (fdi); + outlen = -1; + + } else if (fdi->track_type < 0x10) { + + decode_normal_track[fdi->track_type](fdi); + fix_mfm_sync (fdi); + outlen = fdi->out; + + } else { + + zxx (fdi); + outlen = -1; + + } + + if (fdi->err) + return 0; + + if (outlen > 0) { + for (j = 0; j < MAX_REVOLUTIONS; j++) { + fdi_free (cache->cache_buffer[j]); + cache->cache_buffer[j] = 0; + } + fdi_free (cache->cache_buffer_timing); + cache->cache_buffer_timing = 0; + cache->indexoffset = indexoffset; + cache->length[0] = outlen; + cache->cache_buffer[0] = fdi_malloc ((outlen + 7) / 8); + memcpy (cache->cache_buffer[0], fdi->track_dst_buffer, (outlen + 7) / 8); + if (fdi->track_dst_buffer_timing[0] > 0) { + cache->cache_buffer_timing = fdi_malloc ((outlen + 7) / 8 * sizeof (uae_u16)); + memcpy (cache->cache_buffer_timing, fdi->track_dst_buffer_timing, (outlen + 7) / 8 * sizeof (uae_u16)); + } + return fdi2raw_loadtrack (fdi, mfmbuf, tracktiming, track, tracklength, indexoffsetp, multirev); + } + return 0; +} + diff --git a/filesys.c b/filesys.c index 02e29015..9bd1df53 100755 --- a/filesys.c +++ b/filesys.c @@ -315,14 +315,13 @@ static char *set_filesys_unit_1 (struct uaedev_mount_info *mountinfo, int nr, ui->hf.readonly = readonly; if (ui->hf.handle == 0) return "Hardfile not found"; - - if ((blocksize & (blocksize - 1)) != 0) + if ((blocksize & (blocksize - 1)) != 0 || blocksize <= 0) return "Bad blocksize"; if ((secspertrack || surfaces || reserved) && (secspertrack < 1 || surfaces < 1 || surfaces > 1023 || reserved < 0 || reserved > 1023) != 0) - { return "Bad hardfile geometry"; - } + if (blocksize > ui->hf.size || ui->hf.size == 0) + return "Hardfile too small"; ui->hf.nrcyls = (int)(secspertrack * surfaces ? (ui->hf.size / blocksize) / (secspertrack * surfaces) : 0); } ui->self = 0; @@ -3367,7 +3366,7 @@ static int handle_packet (Unit *unit, dpacket pck) case ACTION_READ_LINK: case ACTION_FORMAT: default: - TRACE(("*** UNSUPPORTED PACKET %ld\n", type)); + write_log ("FILESYS: UNSUPPORTED PACKET %x\n", type); return 0; } return 1; @@ -3504,6 +3503,11 @@ void filesys_start_threads (void) } } +void filesys_cleanup (void) +{ + current_mountinfo = 0; +} + void filesys_reset (void) { Unit *u, *u1; @@ -3519,7 +3523,6 @@ void filesys_reset (void) } unit_num = 0; units = 0; - current_mountinfo = 0; } static void free_all_ainos (Unit *u, a_inode *parent) @@ -3537,10 +3540,13 @@ void filesys_flush_cache (void) void filesys_prepare_reset (void) { - UnitInfo *uip = current_mountinfo->ui; + UnitInfo *uip; Unit *u; int i; + if (!current_mountinfo) + return; + uip = current_mountinfo->ui; #ifdef UAE_FILESYS_THREADS for (i = 0; i < current_mountinfo->num_units; i++) { if (uip[i].unit_pipe != 0) { diff --git a/fpp.c b/fpp.c index 56190b9b..e67c3caf 100755 --- a/fpp.c +++ b/fpp.c @@ -301,6 +301,8 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src) case 4: ad = m68k_getpc (); m68k_setpc (ad + sz2[size]); + if (size == 6) + ad++; break; default: return 0; @@ -345,7 +347,7 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src) } break; case 6: - *src = (fptype) (uae_s8) get_byte (ad + 1); + *src = (fptype) (uae_s8) get_byte (ad); break; default: return 0; diff --git a/gencomp.c b/gencomp.c index 9d381336..884f83b3 100755 --- a/gencomp.c +++ b/gencomp.c @@ -3005,17 +3005,15 @@ generate_one_opcode (int rp, int noflags) comprintf ("}\n"); if (aborted) { - fprintf (stblfile, "{ NULL, 0x%08x, %ld }, /* %s */\n", flags, opcode, lookuptab[i].name); + fprintf (stblfile, "{ NULL, %ld, 0x%08x }, /* %s */\n", opcode, flags, lookuptab[i].name); com_discard(); - } - else { + } else { if (noflags) { - fprintf (stblfile, "{ op_%lx_%d_comp_nf, 0x%08x, %ld }, /* %s */\n", opcode, postfix, flags, opcode, lookuptab[i].name); + fprintf (stblfile, "{ op_%lx_%d_comp_nf, %ld, 0x%08x }, /* %s */\n", opcode, postfix, opcode, flags, lookuptab[i].name); fprintf (headerfile, "extern cpuop_func op_%lx_%d_comp_nf;\n", opcode, postfix); printf ("unsigned long REGPARAM2 op_%lx_%d_comp_nf(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, lookuptab[i].name); - } - else { - fprintf (stblfile, "{ op_%lx_%d_comp_ff, 0x%08x, %ld }, /* %s */\n", opcode, postfix, flags, opcode, lookuptab[i].name); + } else { + fprintf (stblfile, "{ op_%lx_%d_comp_ff, %ld, 0x%08x }, /* %s */\n", opcode, postfix, opcode, flags, lookuptab[i].name); fprintf (headerfile, "extern cpuop_func op_%lx_%d_comp_ff;\n", opcode, postfix); printf ("unsigned long REGPARAM2 op_%lx_%d_comp_ff(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, lookuptab[i].name); } @@ -3045,7 +3043,7 @@ generate_func (int noflags) /* sam: this is for people with low memory (eg. me :)) */ - !printf ("\n" + printf ("\n" "#if !defined(PART_1) && !defined(PART_2) && " "!defined(PART_3) && !defined(PART_4) && " "!defined(PART_5) && !defined(PART_6) && " @@ -3071,7 +3069,7 @@ generate_func (int noflags) printf ("#endif\n\n"); } - fprintf (stblfile, "{ 0, 0,65536 }};\n"); + fprintf (stblfile, "{ 0, 65536, 0 }};\n"); } } diff --git a/gencpu.c b/gencpu.c index 81f597d0..420a61fb 100755 --- a/gencpu.c +++ b/gencpu.c @@ -106,11 +106,7 @@ static void fpulimit (void) } static void cpulimit (void) { - if (limit_braces) - return; - printf ("\n#ifndef CPUEMU_68000_ONLY\n"); - limit_braces = n_braces; - n_braces = 0; + printf ("#ifndef CPUEMU_68000_ONLY\n"); } static void returncycles (char *s, int cycles) @@ -1125,9 +1121,6 @@ static void gen_opcode (unsigned long int opcode) insn_n_cycles = using_prefetch ? 0 : 4; start_brace (); -#if 0 - printf ("uae_u8 *m68k_pc = regs.pc_p;\n"); -#endif m68k_pc_offset = 2; switch (curi->plev) { case 0: /* not privileged */ @@ -1940,7 +1933,7 @@ static void gen_opcode (unsigned long int opcode) start_brace (); printf ("\tuae_u32 newv = (uae_u32)(uae_u16)dst * (uae_u32)(uae_u16)src;\n"); if (using_ce) - printf ("\tint cycles = 38 * %d - lostcycles, bits;\n", CYCLE_UNIT / 2); + printf ("\tint cycles = 36 * %d - lostcycles, bits;\n", CYCLE_UNIT / 2); genflags (flag_logical, sz_long, "newv", "", ""); if (using_ce) { printf ("\tfor(bits = 0; bits < 16 && src; bits++, src >>= 1)\n"); @@ -1958,7 +1951,7 @@ static void gen_opcode (unsigned long int opcode) start_brace (); printf ("\tuae_u32 newv = (uae_s32)(uae_s16)dst * (uae_s32)(uae_s16)src;\n"); if (using_ce) - printf ("\tint cycles = 38 * %d - lostcycles, bits;\n", CYCLE_UNIT / 2); + printf ("\tint cycles = 36 * %d - lostcycles, bits;\n", CYCLE_UNIT / 2); genflags (flag_logical, sz_long, "newv", "", ""); if (using_ce) { printf ("\tsrc <<= 1;\n"); @@ -1987,7 +1980,6 @@ static void gen_opcode (unsigned long int opcode) need_endlabel = 1; break; case i_CHK2: - cpulimit (); printf ("\tuaecptr oldpc = m68k_getpc();\n"); genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); genamode (curi->dmode, "dstreg", curi->size, "dst", 2, 0, 0); @@ -2427,7 +2419,6 @@ static void gen_opcode (unsigned long int opcode) genastore ("val", curi->smode, "srcreg", curi->size, "data"); break; case i_MOVEC2: - cpulimit (); genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); fill_prefetch_next (); start_brace (); @@ -2436,7 +2427,6 @@ static void gen_opcode (unsigned long int opcode) printf ("\tif (! m68k_movec2(src & 0xFFF, regp)) goto %s;\n", endlabelstr); break; case i_MOVE2C: - cpulimit (); genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); fill_prefetch_next (); start_brace (); @@ -2466,7 +2456,6 @@ static void gen_opcode (unsigned long int opcode) } break; case i_CAS2: - cpulimit (); genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); printf ("\tuae_u32 rn1 = regs.regs[(extra >> 28) & 15];\n"); printf ("\tuae_u32 rn2 = regs.regs[(extra >> 12) & 15];\n"); @@ -2505,7 +2494,6 @@ static void gen_opcode (unsigned long int opcode) case i_MOVES: /* ignore DFC and SFC because we have no MMU */ { int old_brace_level; - cpulimit (); genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); printf ("\tif (extra & 0x800)\n"); old_brace_level = n_braces; @@ -2531,22 +2519,18 @@ static void gen_opcode (unsigned long int opcode) } break; case i_BKPT: /* only needed for hardware emulators */ - cpulimit (); sync_m68k_pc (); printf ("\top_illg(opcode);\n"); break; case i_CALLM: /* not present in 68030 */ - cpulimit (); sync_m68k_pc (); printf ("\top_illg(opcode);\n"); break; case i_RTM: /* not present in 68030 */ - cpulimit (); sync_m68k_pc (); printf ("\top_illg(opcode);\n"); break; case i_TRAPcc: - cpulimit (); if (curi->smode != am_unknown && curi->smode != am_illg) genamode (curi->smode, "srcreg", curi->size, "dummy", 1, 0, 0); fill_prefetch_0 (); @@ -2554,7 +2538,6 @@ static void gen_opcode (unsigned long int opcode) need_endlabel = 1; break; case i_DIVL: - cpulimit (); sync_m68k_pc (); start_brace (); printf ("\tuaecptr oldpc = m68k_getpc();\n"); @@ -2564,7 +2547,6 @@ static void gen_opcode (unsigned long int opcode) printf ("\tm68k_divl(opcode, dst, extra, oldpc);\n"); break; case i_MULL: - cpulimit (); genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); sync_m68k_pc (); @@ -2578,7 +2560,6 @@ static void gen_opcode (unsigned long int opcode) case i_BFFFO: case i_BFSET: case i_BFINS: - cpulimit (); genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); genamode (curi->dmode, "dstreg", sz_long, "dst", 2, 0, 0); start_brace (); @@ -2741,37 +2722,30 @@ static void gen_opcode (unsigned long int opcode) break; case i_CINVL: - cpulimit (); printf ("\tif (opcode&0x80)\n" "\t\tflush_icache(31);\n"); break; case i_CINVP: - cpulimit (); printf ("\tif (opcode&0x80)\n" "\t\tflush_icache(32);\n"); break; case i_CINVA: - cpulimit (); printf ("\tif (opcode&0x80)\n" "\t\tflush_icache(33);\n"); break; case i_CPUSHL: - cpulimit (); printf ("\tif (opcode&0x80)\n" "\t\tflush_icache(41);\n"); break; case i_CPUSHP: - cpulimit (); printf ("\tif (opcode&0x80)\n" "\t\tflush_icache(42);\n"); break; case i_CPUSHA: - cpulimit (); printf ("\tif (opcode&0x80)\n" "\t\tflush_icache(43);\n"); break; case i_MOVE16: - cpulimit (); if ((opcode & 0xfff8) == 0xf620) { /* MOVE16 (Ax)+,(Ay)+ */ printf ("\tuaecptr mems = m68k_areg(regs, srcreg) & ~15, memd;\n"); @@ -2802,7 +2776,6 @@ static void gen_opcode (unsigned long int opcode) break; case i_MMUOP: - cpulimit (); genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); sync_m68k_pc (); printf ("\tmmu_op(opcode,extra);\n"); @@ -2954,6 +2927,7 @@ static void generate_one_opcode (int rp) int i; uae_u16 smsk, dmsk; long int opcode = opcode_map[rp]; + int i68000 = table68k[opcode].clev > 0; if (table68k[opcode].mnemo == i_ILLG || table68k[opcode].clev > cpu_level) @@ -2968,14 +2942,20 @@ static void generate_one_opcode (int rp) return; if (opcode_next_clev[rp] != cpu_level) { - fprintf (stblfile, "{ CPUFUNC(op_%04lx_%d), 0, %ld }, /* %s */\n", opcode, opcode_last_postfix[rp], + fprintf (stblfile, "{ CPUFUNC(op_%04lx_%d), %ld }, /* %s */\n", opcode, opcode_last_postfix[rp], opcode, lookuptab[i].name); return; } - fprintf (stblfile, "{ CPUFUNC(op_%04lx_%d), 0, %ld }, /* %s */\n", opcode, postfix, opcode, lookuptab[i].name); + if (i68000) + fprintf (stblfile, "#ifndef CPUEMU_68000_ONLY\n"); + fprintf (stblfile, "{ CPUFUNC(op_%04lx_%d), %ld }, /* %s */\n", opcode, postfix, opcode, lookuptab[i].name); + if (i68000) + fprintf (stblfile, "#endif\n"); fprintf (headerfile, "extern cpuop_func op_%04lx_%d_nf;\n", opcode, postfix); fprintf (headerfile, "extern cpuop_func op_%04lx_%d_ff;\n", opcode, postfix); printf ("/* %s */\n", outopcode (opcode)); + if (i68000) + printf("#ifndef CPUEMU_68000_ONLY\n"); printf ("unsigned long REGPARAM2 CPUFUNC(op_%04lx_%d)(uae_u32 opcode)\n{\n", opcode, postfix); switch (table68k[opcode].stype) { @@ -3032,11 +3012,6 @@ static void generate_one_opcode (int rp) printf ("\tuae_u32 dstreg = %d;\n", (int) table68k[opcode].dreg); } else { int pos = table68k[opcode].dpos; -#if 0 - /* Check that we can do the little endian optimization safely. */ - if (pos < 8 && (dmsk >> (8 - pos)) != 0) - abort (); -#endif if (pos) printf ("\tuae_u32 dstreg = (opcode >> %d) & %d;\n", pos, dmsk); @@ -3054,6 +3029,8 @@ static void generate_one_opcode (int rp) if (using_ce) printf ("return 0;\n"); printf ("}\n"); + if (i68000) + printf("#endif\n"); opcode_next_clev[rp] = next_cpu_level; opcode_last_postfix[rp] = postfix; } @@ -3080,20 +3057,20 @@ static void generate_func (void) "#endif\n\n"); rp = 0; - for(j=1;j<=8;++j) { - int k = (j*nr_cpuop_funcs)/8; + for(j = 1; j <= 8; ++j) { + int k = (j * nr_cpuop_funcs) / 8; printf ("#ifdef PART_%d\n",j); for (; rp < k; rp++) generate_one_opcode (rp); printf ("#endif\n\n"); } - fprintf (stblfile, "{ 0, 0, 0 }};\n"); + fprintf (stblfile, "{ 0, 0 }};\n"); } int main (int argc, char **argv) { - int i, rp; + int i, rp, postfix2; char fname[100]; read_table68k (); @@ -3118,12 +3095,12 @@ int main (int argc, char **argv) using_exception_3 = 1; using_ce = 0; + postfix2 = -1; for (i = 0; i < 7; i++) { postfix = i; if (i == 0 || i == 5 || i == 6) { - if (i > 0) - fprintf (stblfile,"#endif\n"); fprintf (stblfile, "#ifdef CPUEMU_%d\n", postfix); + postfix2 = postfix; sprintf (fname, "cpuemu_%d.c", postfix); freopen (fname, "wb", stdout); generate_includes (stdout); @@ -3137,10 +3114,16 @@ int main (int argc, char **argv) for (rp = 0; rp < nr_cpuop_funcs; rp++) opcode_next_clev[rp] = 0; } + if (i > 0 && i < 4) + fprintf (stblfile, "#ifndef CPUEMU_68000_ONLY\n"); fprintf (stblfile, "struct cputbl CPUFUNC(op_smalltbl_%d)[] = {\n", postfix); generate_func (); + if (i > 0 && i < 4) + fprintf (stblfile, "#endif /* CPUEMU_68000_ONLY */\n"); + if (postfix2 >= 0) + fprintf (stblfile, "#endif /* CPUEMU_%d */\n", postfix2); + postfix2 = -1; } - fprintf (stblfile,"#endif\n"); free (table68k); return 0; diff --git a/identify.c b/identify.c index 8d1bae6a..6d39ab97 100755 --- a/identify.c +++ b/identify.c @@ -7,6 +7,9 @@ #include "sysconfig.h" #include "sysdeps.h" + +#ifdef DEBUGGER + #include "memory.h" #include "identify.h" @@ -398,3 +401,4 @@ struct customData custd[] = #endif }; +#endif diff --git a/include/autoconf.h b/include/autoconf.h index 4c3040c4..11ac3dff 100755 --- a/include/autoconf.h +++ b/include/autoconf.h @@ -67,6 +67,7 @@ extern struct uaedev_mount_info *dup_mountinfo (struct uaedev_mount_info *); extern void free_mountinfo (struct uaedev_mount_info *); extern void filesys_reset (void); +extern void filesys_cleanup (void); extern void filesys_prepare_reset (void); extern void filesys_start_threads (void); extern void filesys_flush_cache (void); diff --git a/include/custom.h b/include/custom.h index 09a5dab9..c3133b03 100755 --- a/include/custom.h +++ b/include/custom.h @@ -108,15 +108,14 @@ extern unsigned long syncbase; #define DMA_MASTER 0x0200 #define DMA_BLITPRI 0x0400 -#define CYCLE_REFRESH 0x001 -#define CYCLE_DISK 0x002 -#define CYCLE_AUDIO 0x004 -#define CYCLE_SPRITE 0x008 -#define CYCLE_BITPLANE 0x010 -#define CYCLE_COPPER 0x020 -#define CYCLE_BLITTER 0x040 -#define CYCLE_BLITTER_F 0x080 -#define CYCLE_CPU 0x100 +#define CYCLE_REFRESH 0x01 +#define CYCLE_DISK 0x02 +#define CYCLE_AUDIO 0x04 +#define CYCLE_SPRITE 0x08 +#define CYCLE_BITPLANE 0x10 +#define CYCLE_COPPER 0x20 +#define CYCLE_BLITTER 0x40 +#define CYCLE_CPU 0x80 extern unsigned long frametime, timeframes; extern int plfstrt, plfstop, plffirstline, plflastline; diff --git a/include/fdi2raw.h b/include/fdi2raw.h index e5ffa0c3..ad99d84d 100755 --- a/include/fdi2raw.h +++ b/include/fdi2raw.h @@ -9,7 +9,8 @@ typedef struct fdi FDI; extern "C" { #endif -extern int fdi2raw_loadtrack (FDI*, uae_u16 *mfmbuf, uae_u16 **trackpointers, uae_u16 **tracktiming, int track, int *tracklengths, int *revolutions, int *indexoffset); +extern int fdi2raw_loadtrack (FDI*, uae_u16 *mfmbuf, uae_u16 *tracktiming, int track, int *tracklength, int *indexoffset, int *multirev, int mfm); +extern int fdi2raw_loadrevolution (FDI*, uae_u16 *mfmbuf, uae_u16 *tracktiming, int track, int *tracklength, int mfm); extern FDI *fdi2raw_header(struct zfile *f); extern void fdi2raw_header_free (FDI *); extern int fdi2raw_get_last_track(FDI *); diff --git a/include/memory.h b/include/memory.h index ffe4db1b..9acb70af 100755 --- a/include/memory.h +++ b/include/memory.h @@ -17,6 +17,12 @@ extern void *cache_alloc (int); extern void cache_free (void*); #endif +#ifdef ADDRESS_SPACE_24BIT +#define MEMORY_BANKS 256 +#else +#define MEMORY_BANKS 65536 +#endif + typedef uae_u32 (*mem_get_func)(uaecptr) REGPARAM; typedef void (*mem_put_func)(uaecptr, uae_u32) REGPARAM; typedef uae_u8 *(*xlate_func)(uaecptr) REGPARAM; @@ -49,8 +55,6 @@ extern void wait_cpu_cycle_write (uaecptr addr, int mode, uae_u32 v); #endif #endif -#define kickmem_size 0x080000 - #define chipmem_start 0x00000000 #define bogomem_start 0x00C00000 #define a3000mem_start 0x07000000 @@ -114,8 +118,8 @@ extern uae_u8 *default_xlate(uaecptr addr) REGPARAM; #define bankindex(addr) (((uaecptr)(addr)) >> 16) -extern addrbank *mem_banks[65536]; -extern uae_u8 *baseaddr[65536]; +extern addrbank *mem_banks[MEMORY_BANKS]; +extern uae_u8 *baseaddr[MEMORY_BANKS]; #define get_mem_bank(addr) (*mem_banks[bankindex(addr)]) #define put_mem_bank(addr, b, realstart) do { \ (mem_banks[bankindex(addr)] = (b)); \ @@ -208,6 +212,7 @@ extern void chipmem_bput (uaecptr, uae_u32) REGPARAM; extern uae_u32 chipmem_mask, kickmem_mask; extern uae_u8 *kickmemory; +extern int kickmem_size; extern addrbank dummy_bank; /* 68020+ Chip RAM DMA contention emulation */ diff --git a/include/moduleripper.h b/include/moduleripper.h new file mode 100755 index 00000000..7f836dc4 --- /dev/null +++ b/include/moduleripper.h @@ -0,0 +1,4 @@ +extern int prowizard_search (unsigned char *in_data, int in_size); +extern void moduleripper (void); +extern FILE *moduleripper_fopen(const char *, const char *); +extern FILE *moduleripper2_fopen(const char *, const char *, const char *); diff --git a/include/newcpu.h b/include/newcpu.h index 379b00f5..e0f4e3f6 100755 --- a/include/newcpu.h +++ b/include/newcpu.h @@ -53,8 +53,12 @@ typedef unsigned long cpuop_func (uae_u32) REGPARAM; struct cputbl { cpuop_func *handler; - int specific; +#ifndef JIT + uae_u16 opcode; +#else uae_u32 opcode; + int specific; +#endif }; extern unsigned long op_illg (uae_u32) REGPARAM; diff --git a/include/options.h b/include/options.h index b41ec086..75f9c017 100755 --- a/include/options.h +++ b/include/options.h @@ -9,7 +9,7 @@ #define UAEMAJOR 0 #define UAEMINOR 8 -#define UAESUBREV 26 +#define UAESUBREV 27 typedef enum { KBD_LANG_US, KBD_LANG_DK, KBD_LANG_DE, KBD_LANG_SE, KBD_LANG_FR, KBD_LANG_IT, KBD_LANG_ES } KbdLang; diff --git a/include/savestate.h b/include/savestate.h index c6560475..4a67e03a 100755 --- a/include/savestate.h +++ b/include/savestate.h @@ -109,7 +109,7 @@ extern void custom_prepare_savestate (void); #define STATE_DOREWIND 32 extern int savestate_state; -extern char savestate_fname[MAX_PATH]; +extern char savestate_fname[MAX_DPATH]; extern struct zfile *savestate_file; extern uae_u32 CRC32(uae_u32 crc, const uae_u8 *buf, int len); diff --git a/include/sysdeps.h b/include/sysdeps.h index b60b92e7..23bdcbff 100755 --- a/include/sysdeps.h +++ b/include/sysdeps.h @@ -458,6 +458,7 @@ extern void console_flush (void); extern int console_get (char *, int); extern void f_out (void *, const char *, ...); extern void gui_message (const char *,...); +extern int gui_message_multibutton (int flags, const char *format,...); #define write_log_err write_log #ifndef O_BINARY diff --git a/main.c b/main.c index 58dbb18b..5d1f73f5 100755 --- a/main.c +++ b/main.c @@ -90,6 +90,7 @@ void discard_prefs (struct uae_prefs *p, int type) free (s); } #ifdef FILESYS + filesys_cleanup (); free_mountinfo (p->mountinfo); p->mountinfo = alloc_mountinfo (); #endif @@ -327,10 +328,11 @@ void uae_quit (void) quit_program = -1; } +/* 0 = normal, 1 = nogui, -1 = disable nogui */ void uae_restart (int opengui, char *cfgfile) { uae_quit (); - restart_program = opengui ? 1 : 2; + restart_program = opengui > 0 ? 1 : (opengui == 0 ? 2 : 3); restart_config[0] = 0; if (cfgfile) strcpy (restart_config, cfgfile); @@ -514,6 +516,9 @@ void do_leave_program (void) #endif #ifdef AUTOCONFIG expansion_cleanup (); +#endif +#ifdef FILESYS + filesys_cleanup (); #endif savestate_free (); memory_cleanup (); @@ -581,6 +586,8 @@ static void real_main2 (int argc, char **argv) no_gui = ! currprefs.start_gui; if (restart_program == 2) no_gui = 1; + else if (restart_program == 3) + no_gui = 0; restart_program = 0; if (! no_gui) { int err = gui_init (); diff --git a/memory.c b/memory.c index 1218c73b..8075f377 100755 --- a/memory.c +++ b/memory.c @@ -53,7 +53,7 @@ static long chip_filepos; static long bogo_filepos; static long rom_filepos; -addrbank *mem_banks[65536]; +addrbank *mem_banks[MEMORY_BANKS]; /* This has two functions. It either holds a host address that, when added to the 68k address, gives the host address corresponding to that 68k @@ -61,7 +61,7 @@ addrbank *mem_banks[65536]; same value as mem_banks, for those banks that have baseaddr==0. In that case, bit 0 is set (the memory access routines will take care of it). */ -uae_u8 *baseaddr[65536]; +uae_u8 *baseaddr[MEMORY_BANKS]; #ifdef NO_INLINE_MEMORY_ACCESS __inline__ uae_u32 longget (uaecptr addr) @@ -592,6 +592,7 @@ uae_u8 REGPARAM2 *a3000mem_xlate (uaecptr addr) uae_u8 *kickmemory; uae_u16 kickstart_version; +int kickmem_size = 0x80000; /* * A1000 kickstart RAM handling @@ -1031,14 +1032,11 @@ static int read_kickstart (struct zfile *f, uae_u8 *mem, int size, int dochecksu } i = zfile_fread (mem, 1, size, f); - if (i == size/2) { - memcpy (mem + size/2, mem, i); - } else if ((i != 8192 && i != 65536) && i != size) { + zfile_fclose (f); + if ((i != 8192 && i != 65536) && i != 131072 && i != 262144 && i != 524288) { gui_message ("Error while reading Kickstart.\n"); - zfile_fclose (f); return 0; } - zfile_fclose (f); if (cr) decode_cloanto_rom (mem, size, i); @@ -1051,7 +1049,7 @@ static int read_kickstart (struct zfile *f, uae_u8 *mem, int size, int dochecksu kickstart_checksum (mem, size); if (cloanto_rom) *cloanto_rom = cr; - return 1; + return i; } static int load_extendedkickstart (void) @@ -1148,8 +1146,10 @@ static int load_kickstart (void) } if (f != NULL) { - if (!read_kickstart (f, kickmemory, kickmem_size, 1, &cloanto_rom)) + int size = read_kickstart (f, kickmemory, 0x80000, 1, &cloanto_rom); + if (size == 0) goto err; + kickmem_mask = size - 1; } #if defined(AMIGA) @@ -1308,7 +1308,7 @@ uae_u8 *mapped_malloc (size_t s, char *file) shmpiece *x; if (!canbang) - return malloc (s); + return xmalloc (s); id = shmget (IPC_PRIVATE, s, 0x1ff, file); if (id == -1) { @@ -1339,7 +1339,7 @@ uae_u8 *mapped_malloc (size_t s, char *file) static void init_mem_banks (void) { int i; - for (i = 0; i < 65536; i++) + for (i = 0; i < MEMORY_BANKS; i++) put_mem_bank (i << 16, &dummy_bank, 0); #ifdef NATMEM_OFFSET delete_shmmaps (0, 0xFFFF0000); @@ -1563,7 +1563,6 @@ void memory_init (void) kickmemory = mapped_malloc (kickmem_size, "kick"); memset (kickmemory, 0, kickmem_size); kickmem_bank.baseaddr = kickmemory; - kickmem_mask = kickmem_size - 1; currprefs.romfile[0] = 0; currprefs.keyfile[0] = 0; #ifdef AUTOCONFIG @@ -1632,6 +1631,7 @@ void map_banks (addrbank *bank, int start, int size, int realsize) abort (); } +#ifndef ADDRESS_SPACE_24BIT if (start >= 0x100) { int real_left = 0; for (bnr = start; bnr < start + size; bnr++) { @@ -1647,8 +1647,12 @@ void map_banks (addrbank *bank, int start, int size, int realsize) } return; } +#endif if (currprefs.address_space_24) endhioffs = 0x10000; +#ifdef ADDRESS_SPACE_24BIT + endhioffs = 0x100; +#endif for (hioffs = 0; hioffs < endhioffs; hioffs += 0x100) { int real_left = 0; for (bnr = start; bnr < start + size; bnr++) { diff --git a/missing.c b/missing.c index d0c7ddc8..27e62dcc 100755 --- a/missing.c +++ b/missing.c @@ -27,7 +27,7 @@ void *xmalloc (size_t n) { void *a = malloc (n); if (a == NULL) { - write_log ("virtual memory exhausted\n"); + write_log ("xmalloc(%d): virtual memory exhausted\n", n); abort (); } return a; @@ -37,7 +37,7 @@ void *xcalloc (size_t n, size_t size) { void *a = calloc (n, size); if (a == NULL) { - write_log ("virtual memory exhausted\n"); + write_log ("xcalloc(%d): virtual memory exhausted\n", n * size); abort (); } return a; diff --git a/moduleripper.c b/moduleripper.c new file mode 100755 index 00000000..954011b6 --- /dev/null +++ b/moduleripper.c @@ -0,0 +1,93 @@ + /* + * UAE - The Un*x Amiga Emulator + * + * Pro-Wizard glue code + * + * Copyright 2004 Toni Wilen + */ + +#include "sysconfig.h" +#include "sysdeps.h" + +#ifdef PROWIZARD + +#include "uae.h" +#include "config.h" +#include "options.h" +#include "memory.h" +#include "autoconf.h" +#include "moduleripper.h" + +static int got, canceled; + +static void mc (uae_u8 *d, uaecptr s, int size) +{ + int i; + + for (i = 0; i < size; i++) + d[i] = get_byte (s++); +} + +#ifdef _WIN32 +static LONG WINAPI ExceptionFilter( struct _EXCEPTION_POINTERS * pExceptionPointers, DWORD ec) +{ + return EXCEPTION_EXECUTE_HANDLER; +} +#endif + +void moduleripper (void) +{ + int size; + uae_u8 *buf, *p; + + size = currprefs.chipmem_size; + size += currprefs.fastmem_size; + size += currprefs.bogomem_size; + buf = p = xmalloc (size); + memcpy (p, chipmemory, currprefs.chipmem_size); + p += currprefs.chipmem_size; + mc (p, 0x200000, currprefs.fastmem_size); + p += currprefs.fastmem_size; + mc (p, 0xc00000, currprefs.bogomem_size); + + got = 0; + canceled = 0; +#ifdef _WIN32 + __try { +#endif + prowizard_search (buf, size); +#ifdef _WIN32 + } __except(ExceptionFilter(GetExceptionInformation(), GetExceptionCode())) { + write_log("prowizard scan crashed\n"); + } +#endif + if (!got) + gui_message("No modules or compressed data found"); + else if (!canceled) + gui_message("Search finished"); + free (buf); +} + +FILE *moduleripper_fopen (const char *name, const char *mode) +{ + return fopen (name, mode); +} + +FILE *moduleripper2_fopen (const char *name, const char *mode, const char *id) +{ + char msg[1000]; + int ret; + + if (canceled) + return NULL; + got++; + sprintf (msg, "Module/packer found\n%s\nDo you want to save it?", id); + ret = gui_message_multibutton (2, msg); + if (ret < 0) + canceled = 1; + if (ret < 0 || ret != 1) + return NULL; + return fopen (name, mode); +} + +#endif \ No newline at end of file diff --git a/native2amiga.c b/native2amiga.c index f73286a8..bb8ae200 100755 --- a/native2amiga.c +++ b/native2amiga.c @@ -25,6 +25,7 @@ #include "native2amiga.h" smp_comm_pipe native2amiga_pending; +static uae_sem_t n2asem; /* * to be called when setting up the hardware @@ -33,6 +34,7 @@ smp_comm_pipe native2amiga_pending; void native2amiga_install (void) { init_comm_pipe (&native2amiga_pending, 10, 2); + uae_sem_init (&n2asem, 0, 1); } /* @@ -46,47 +48,52 @@ void native2amiga_startup (void) void uae_Cause(uaecptr interrupt) { + uae_sem_wait (&n2asem); write_comm_pipe_int (&native2amiga_pending, 3, 0); write_comm_pipe_u32 (&native2amiga_pending, interrupt, 1); - uae_int_requested = 1; + uae_sem_post (&n2asem); } void uae_ReplyMsg(uaecptr msg) { + uae_sem_wait (&n2asem); write_comm_pipe_int (&native2amiga_pending, 2, 0); write_comm_pipe_u32 (&native2amiga_pending, msg, 1); - uae_int_requested = 1; + uae_sem_post (&n2asem); } void uae_PutMsg(uaecptr port, uaecptr msg) { uae_pt data; data.i = 1; + uae_sem_wait (&n2asem); write_comm_pipe_int (&native2amiga_pending, 1, 0); write_comm_pipe_u32 (&native2amiga_pending, port, 0); write_comm_pipe_u32 (&native2amiga_pending, msg, 1); - uae_int_requested = 1; + uae_sem_post (&n2asem); } void uae_Signal(uaecptr task, uae_u32 mask) { + uae_sem_wait (&n2asem); write_comm_pipe_int (&native2amiga_pending, 0, 0); write_comm_pipe_u32 (&native2amiga_pending, task, 0); write_comm_pipe_int (&native2amiga_pending, mask, 1); - uae_int_requested = 1; + uae_sem_post (&n2asem); } void uae_NotificationHack(uaecptr port, uaecptr nr) { + uae_sem_wait (&n2asem); write_comm_pipe_int (&native2amiga_pending, 4, 0); write_comm_pipe_int (&native2amiga_pending, port, 0); write_comm_pipe_int (&native2amiga_pending, nr, 1); - uae_int_requested = 1; + uae_sem_post (&n2asem); } #endif @@ -102,7 +109,6 @@ uaecptr uae_AllocMem (uae_u32 size, uae_u32 flags) { m68k_dreg (regs, 0) = size; m68k_dreg (regs, 1) = flags; - write_log ("allocmem(%d,%08.8X)\n", size, flags); return CallLib (get_long (4), -198); /* AllocMem */ } diff --git a/newcpu.c b/newcpu.c index b91e6663..a3b4002c 100755 --- a/newcpu.c +++ b/newcpu.c @@ -61,9 +61,11 @@ int movem_index1[256]; int movem_index2[256]; int movem_next[256]; +#ifdef FPUEMU int fpp_movem_index1[256]; int fpp_movem_index2[256]; int fpp_movem_next[256]; +#endif cpuop_func *cpufunctbl[65536]; @@ -134,13 +136,14 @@ static unsigned long REGPARAM2 op_illg_1 (uae_u32 opcode) static void build_cpufunctbl (void) { - int i; + int i, opcnt; unsigned long opcode; struct cputbl *tbl = 0; switch (currprefs.cpu_level) { #ifdef CPUEMU_0 +#ifndef CPUEMU_68000_ONLY case 4: case 6: tbl = op_smalltbl_0_ff; @@ -154,6 +157,7 @@ static void build_cpufunctbl (void) case 1: tbl = op_smalltbl_3_ff; break; +#endif #endif case 0: tbl = op_smalltbl_4_ff; @@ -172,17 +176,16 @@ static void build_cpufunctbl (void) write_log ("no CPU emulation cores available!"); abort (); } - write_log ("Building CPU function table (%d %d %d).\n", - currprefs.cpu_level, - currprefs.cpu_cycle_exact ? -1 : currprefs.cpu_compatible ? 1 : 0, - currprefs.address_space_24); for (opcode = 0; opcode < 65536; opcode++) cpufunctbl[opcode] = op_illg_1; for (i = 0; tbl[i].handler != NULL; i++) { - if (! tbl[i].specific) - cpufunctbl[tbl[i].opcode] = tbl[i].handler; +#ifdef JIT + tbl[i].specific = 0; +#endif + cpufunctbl[tbl[i].opcode] = tbl[i].handler; } + opcnt = 0; for (opcode = 0; opcode < 65536; opcode++) { cpuop_func *f; @@ -194,12 +197,13 @@ static void build_cpufunctbl (void) if (f == op_illg_1) abort(); cpufunctbl[opcode] = f; + opcnt++; } } - for (i = 0; tbl[i].handler != NULL; i++) { - if (tbl[i].specific) - cpufunctbl[tbl[i].opcode] = tbl[i].handler; - } + write_log ("Building CPU function table, %d opcodes (%d %d %d).\n", + opcnt, currprefs.cpu_level, + currprefs.cpu_cycle_exact ? -1 : currprefs.cpu_compatible ? 1 : 0, + currprefs.address_space_24); #ifdef JIT build_comp(); #endif @@ -272,6 +276,7 @@ void init_m68k (void) movem_index2[i] = 7-j; movem_next[i] = i & (~(1 << j)); } +#ifdef FPUEMU for (i = 0 ; i < 256 ; i++) { int j; for (j = 7 ; j >= 0 ; j--) { @@ -281,6 +286,7 @@ void init_m68k (void) fpp_movem_index2[i] = j; fpp_movem_next[i] = i & (~(1 << j)); } +#endif #if COUNT_INSTRS { FILE *f = fopen (icountfilename (), "r"); @@ -351,8 +357,6 @@ void init_m68k (void) void init_m68k_full (void) { init_m68k (); - build_cpufunctbl (); - update_68k_cycles (); } struct regstruct regs, lastint_regs; @@ -920,7 +924,10 @@ kludge_me_do: newpc = get_word_ce (4 * nr) << 16; newpc |= get_word_ce (4 * nr + 2); if (newpc & 1) { - exception3 (regs.ir, m68k_getpc(), newpc); + if (nr == 2 || nr == 3) + uae_reset (1); /* there is nothing else we can do.. */ + else + exception3 (regs.ir, m68k_getpc(), newpc); return; } m68k_setpc (newpc); @@ -1039,9 +1046,10 @@ static void Exception_normal (int nr, uaecptr oldpc) kludge_me_do: newpc = get_long (regs.vbr + 4*nr); if (newpc & 1) { - if ((nr == 2 || nr == 3) && currprefs.cpu_level >= 2) + if (nr == 2 || nr == 3) uae_reset (1); /* there is nothing else we can do.. */ - exception3 (regs.ir, m68k_getpc(), newpc); + else + exception3 (regs.ir, m68k_getpc(), newpc); return; } m68k_setpc (newpc); @@ -1052,6 +1060,11 @@ kludge_me_do: void Exception (int nr, uaecptr oldpc) { +#if 0 + if (1 || nr < 24) + write_log ("exception %d %08.8X %08.8X (%04.4X %04.4X)\n", + nr, oldpc, m68k_getpc(), intena, intreq); +#endif #ifdef CPUEMU_6 if (currprefs.cpu_cycle_exact && currprefs.cpu_level == 0) Exception_ce (nr, oldpc); @@ -1079,7 +1092,7 @@ void Interrupt (int nr) static uae_u32 caar, cacr, itt0, itt1, dtt0, dtt1, tc, mmusr, urp, srp, buscr, pcr; -#ifdef CPUEMU_0 +#ifndef CPUEMU_68000_ONLY static int movec_illg (int regno) { diff --git a/od-win32/avioutput.c b/od-win32/avioutput.c index dc27cf2a..20bcfa22 100755 --- a/od-win32/avioutput.c +++ b/od-win32/avioutput.c @@ -55,8 +55,8 @@ int avioutput_width = 320, avioutput_height = 256, avioutput_bits = 24; int avioutput_fps = VBLANK_HZ_PAL; int avioutput_framelimiter = 0; -char avioutput_filename[MAX_PATH] = "output.avi"; -static char avioutput_filename_tmp[MAX_PATH]; +char avioutput_filename[MAX_DPATH] = "output.avi"; +static char avioutput_filename_tmp[MAX_DPATH]; extern struct uae_prefs workprefs; extern char config_filename[256]; @@ -322,7 +322,7 @@ static void checkAVIsize (int force) int tmp_partcnt = partcnt + 1; int tmp_avioutput_video = avioutput_video; int tmp_avioutput_audio = avioutput_audio; - char fn[MAX_PATH]; + char fn[MAX_DPATH]; if (!force && total_avi_size < MAX_AVI_SIZE) return; diff --git a/od-win32/avioutput.h b/od-win32/avioutput.h index 9365eaf7..c2a8811d 100755 --- a/od-win32/avioutput.h +++ b/od-win32/avioutput.h @@ -11,7 +11,7 @@ extern int avioutput_video, avioutput_audio, avioutput_enabled, avioutput_reques extern int avioutput_width, avioutput_height, avioutput_bits; extern int avioutput_fps, avioutput_framelimiter; -extern char avioutput_filename[MAX_PATH]; +extern char avioutput_filename[MAX_DPATH]; extern void AVIOutput_WriteAudio(uae_u8 *sndbuffer, int sndbufsize); extern void AVIOutput_WriteVideo(void); @@ -42,7 +42,7 @@ extern int avioutput_init; extern int frame_count; -extern char avioutput_filename[MAX_PATH]; +extern char avioutput_filename[MAX_DPATH]; extern void AviOutputClearAudioCodec(HWND hwnd); extern void AviOutputClearVideoCodec(HWND hwnd); diff --git a/od-win32/bsdsock.c b/od-win32/bsdsock.c index 28f52618..e74e9c4e 100755 --- a/od-win32/bsdsock.c +++ b/od-win32/bsdsock.c @@ -114,8 +114,8 @@ static int mySockStartup( void ) if( lasterror == WSAVERNOTSUPPORTED ) { - char szMessage[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_WSOCK2NEEDED, szMessage, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_WSOCK2NEEDED, szMessage, MAX_DPATH ); gui_message( szMessage ); } else @@ -125,8 +125,8 @@ static int mySockStartup( void ) if (LOBYTE (wsbData.wVersion) != SOCKVER_MAJOR || HIBYTE (wsbData.wVersion) != SOCKVER_MINOR ) { - char szMessage[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_WSOCK2NEEDED, szMessage, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_WSOCK2NEEDED, szMessage, MAX_DPATH ); gui_message( szMessage ); return 0; diff --git a/od-win32/caps/CapsAPI.h b/od-win32/caps/CapsAPI.h index 528a5fef..5eaba9b2 100755 --- a/od-win32/caps/CapsAPI.h +++ b/od-win32/caps/CapsAPI.h @@ -12,6 +12,8 @@ // 4: generate density for unformatted cells // 5: generate unformatted data // 6: generate unformatted data, that changes each revolution +// 7: directly use source memory buffer supplied with LockImageMemory +// 8: flakey data is created on one revolution, updated with each lock #define DI_LOCK_INDEX DF_0 #define DI_LOCK_ALIGN DF_1 #define DI_LOCK_DENVAR DF_2 @@ -20,10 +22,14 @@ #define DI_LOCK_NOISE DF_5 #define DI_LOCK_NOISEREV DF_6 #define DI_LOCK_MEMREF DF_7 +#define DI_LOCK_UPDATEFD DF_8 #define CAPS_MAXPLATFORM 4 #define CAPS_MTRS 5 +#define CTIT_FLAG_FLAKEY DF_31 +#define CTIT_MASK_TYPE 0xff + #pragma pack(push, 1) // decoded caps date.time diff --git a/od-win32/caps/caps_win32.c b/od-win32/caps/caps_win32.c index 8b6c81f6..09fceffc 100755 --- a/od-win32/caps/caps_win32.c +++ b/od-win32/caps/caps_win32.c @@ -13,7 +13,7 @@ static SDWORD caps_cont[4]= {-1, -1, -1, -1}; static int caps_locked[4]; -static int caps_flags = DI_LOCK_DENVAR|DI_LOCK_DENNOISE|DI_LOCK_NOISE; +static int caps_flags = DI_LOCK_DENVAR|DI_LOCK_DENNOISE|DI_LOCK_NOISE|DI_LOCK_UPDATEFD; int caps_init (void) { @@ -58,8 +58,10 @@ void caps_unloadimage (int drv) int caps_loadimage (struct zfile *zf, int drv, int *num_tracks) { struct CapsImageInfo ci; - int len,ret ; + int len, ret; uae_u8 *buf; + char s1[100]; + struct CapsDateTimeExt *cdt; if (!caps_init ()) return 0; @@ -82,27 +84,49 @@ int caps_loadimage (struct zfile *zf, int drv, int *num_tracks) CAPSGetImageInfo(&ci, caps_cont[drv]); *num_tracks = (ci.maxcylinder - ci.mincylinder + 1) * (ci.maxhead - ci.minhead + 1); CAPSLoadImage(caps_cont[drv], caps_flags); + cdt = &ci.crdt; + sprintf (s1, "%d.%d.%d %d:%d:%d", cdt->day, cdt->month, cdt->year, cdt->hour, cdt->min, cdt->sec); + write_log ("caps: type:%d date:%s rel:%d rev:%d\n", + ci.type, s1, ci.release, ci.revision); return 1; } -int caps_loadtrack (uae_u16 *mfmbuf, uae_u16 **trackpointers, uae_u16 **tracktiming, int drv, int track, int *tracklengths, int *revolutions) +int caps_loadrevolution (uae_u16 *mfmbuf, int drv, int track, int *tracklength) { + static int revcnt; + int rev, len, i; + uae_u16 *mfm; + struct CapsTrackInfo ci; + + revcnt++; + CAPSLockTrack(&ci, caps_cont[drv], track / 2, track & 1, caps_flags); + rev = revcnt % ci.trackcnt; + len = ci.tracksize[rev]; + *tracklength = len * 8; + mfm = mfmbuf; + for (i = 0; i < (len + 1) / 2; i++) { + uae_u8 *data = ci.trackdata[rev]+ i * 2; + *mfm++ = 256 * *data + *(data + 1); + } + return 1; +} + +int caps_loadtrack (uae_u16 *mfmbuf, uae_u16 *tracktiming, int drv, int track, int *tracklength, int *multirev) +{ + int i, len, type; + uae_u16 *mfm; struct CapsTrackInfo ci; - int i, j, len; - uae_u16 *tt, *mfm; *tracktiming = 0; CAPSLockTrack(&ci, caps_cont[drv], track / 2, track & 1, caps_flags); mfm = mfmbuf; - *revolutions = ci.trackcnt; - for (j = 0; j < ci.trackcnt; j++) { - len = ci.tracksize[j]; - trackpointers[j] = mfm; - tracklengths[j] = len * 8; - for (i = 0; i < (len + 1) / 2; i++) { - uae_u8 *data = ci.trackdata[j]+ i * 2; - *mfm++ = 256 * *data + *(data + 1); - } + *multirev = (ci.type & CTIT_FLAG_FLAKEY) ? 1 : 0; + type = ci.type & CTIT_MASK_TYPE; + len = ci.tracksize[0]; + *tracklength = len * 8; + for (i = 0; i < (len + 1) / 2; i++) { + uae_u8 *data = ci.trackdata[0]+ i * 2; + *mfm++ = 256 * *data + *(data + 1); } #if 0 { @@ -112,16 +136,12 @@ int caps_loadtrack (uae_u16 *mfmbuf, uae_u16 **trackpointers, uae_u16 **tracktim } #endif if (ci.timelen > 0) { - tt = xmalloc (ci.timelen * sizeof (uae_u16)); for (i = 0; i < ci.timelen; i++) - tt[i] = (uae_u16)ci.timebuf[i]; - *tracktiming = tt; + tracktiming[i] = (uae_u16)ci.timebuf[i]; } #if 0 - write_log ("caps: drive: %d, track: %d, revolutions: %d, timing: %d\n", - drv, track, *revolutions, ci.timelen); - for (i = 0; i < *revolutions; i++) - write_log ("- %d: length: %d bits, %d bytes\n", i, tracklengths[i], tracklengths[i] / 8); + write_log ("caps: drive:%d track:%d flakey:%d multi:%d timing:%d type:%d\n", + drv, track, *multirev, ci.trackcnt, ci.timelen, type); #endif return 1; } diff --git a/od-win32/caps/caps_win32.h b/od-win32/caps/caps_win32.h index 7fd03649..695818cb 100755 --- a/od-win32/caps/caps_win32.h +++ b/od-win32/caps/caps_win32.h @@ -1,5 +1,6 @@ int caps_init (void); void caps_unloadimage (int drv); int caps_loadimage (struct zfile *zf, int drv, int *num_tracks); -int caps_loadtrack (uae_u16 *mfmbuf, uae_u16 **trackpointers, uae_u16 **tracktiming, int drv, int track, int *tracklengths, int *revolutions); +int caps_loadtrack (uae_u16 *mfmbuf, uae_u16 *tracktiming, int drv, int track, int *tracklength, int *multirev); +int caps_loadrevolution (uae_u16 *mfmbuf, int drv, int track, int *tracklength); diff --git a/od-win32/dinput.c b/od-win32/dinput.c index 7f0cfbb0..04b0ebfd 100755 --- a/od-win32/dinput.c +++ b/od-win32/dinput.c @@ -71,6 +71,7 @@ struct didata { }; #define DI_BUFFER 30 +#define DI_KBBUFFER 50 static struct didata di_mouse[MAX_INPUT_DEVICES]; static struct didata di_keyboard[MAX_INPUT_DEVICES]; @@ -1081,11 +1082,12 @@ static int init_kb (void) hr = IDirectInputDevice8_SetDataFormat(lpdi, &c_dfDIKeyboard); if (hr != DI_OK) write_log ("keyboard setdataformat failed, %s\n", DXError (hr)); + memset (&dipdw, 0, sizeof (dipdw)); dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; - dipdw.dwData = DI_BUFFER; + dipdw.dwData = DI_KBBUFFER; hr = IDirectInputDevice8_SetProperty (lpdi, DIPROP_BUFFERSIZE, &dipdw.diph); if (hr != DI_OK) write_log ("keyboard setpropertry failed, %s\n", DXError (hr)); @@ -1262,7 +1264,7 @@ static int keyhack (int scancode,int pressed, int num) static void read_kb (void) { - DIDEVICEOBJECTDATA didod[DI_BUFFER]; + DIDEVICEOBJECTDATA didod[DI_KBBUFFER]; DWORD elements; HRESULT hr; LPDIRECTINPUTDEVICE8 lpdi; @@ -1279,7 +1281,7 @@ static void read_kb (void) continue; kb_do_refresh &= ~(1 << i); } - elements = DI_BUFFER; + elements = DI_KBBUFFER; hr = IDirectInputDevice8_GetDeviceData(lpdi, sizeof(DIDEVICEOBJECTDATA), didod, &elements, 0); if (hr == DI_OK) { if (did->superdevice && (normalkb || rawkb)) diff --git a/od-win32/makeexe.bat b/od-win32/makeexe.bat index 875fef64..2119057f 100755 --- a/od-win32/makeexe.bat +++ b/od-win32/makeexe.bat @@ -1,18 +1,19 @@ del *.zip -copy d:\amiga\winuae.exe d:\projects\winuae\distribution +copy d:\amiga\winuae.exe c:\projects\winuae\distribution copy resourcedll\release\resourcedll.dll d:\amiga\WinUAE_default.dll makensis.exe winuae -cd d:\projects\winuae\distribution +cd c:\projects\winuae\distribution copy docs\windows\translation.txt d:\amiga -zip -9 -r d:\projects\winuae\src\od-win32\winuae.zip * -cd d:\projects\winuae\src\od-win32 +zip -9 -r c:\projects\winuae\src\od-win32\winuae.zip * +cd c:\projects\winuae\src\od-win32 copy installwinuae.exe d:\amiga\InstallWinUAE%1.exe copy winuae.zip d:\amiga\WinUAE%1.zip -cd d:\amiga +cdd d:\amiga zip -9 WinUAE%1_translation WinUAE_default.dll translation.txt del WinUAE_default.dll del translation.txt zip -9 WinUAEMini%1 winuae_mini.exe -cd d:\projects\winuae\src\od-win32 +cdd c:\projects\winuae\src\od-win32 +zip -9 winuaedebug%1 winuae_msvc\release\winuae.pdb +copy winuaedebug%1.zip d:\amiga\winuaepackets del *.zip - diff --git a/od-win32/midi.c b/od-win32/midi.c index e01ab2a0..2ffd18ad 100755 --- a/od-win32/midi.c +++ b/od-win32/midi.c @@ -501,12 +501,12 @@ int Midi_Parse( midi_direction_e direction, BYTE *dataptr ) */ static unsigned char midibuf[BUFFLEN]; -static long midi_inptr = 0,midi_inlast = 0; +static long midi_inptr = 0, midi_inlast = 0; static void add1byte(char w) //put 1 Byte to Midibuffer { if(midi_inlast >= BUFFLEN - 10) { - TRACE(("add1byte buffer full (%02.2X)\n", w)); + TRACE(("add1byte buffer full %d %d (%02.2X)\n", midi_inlast, midi_inptr, w)); return; } midibuf[midi_inlast++] = w; @@ -514,7 +514,7 @@ static void add1byte(char w) //put 1 Byte to Midibuffer static void add2byte(long w) //put 2 Byte to Midibuffer { if(midi_inlast >= BUFFLEN - 10) { - TRACE(("add2byte buffer full (%04.4X)\n", w)); + TRACE(("add2byte buffer full %d %d (%04.4X)\n", midi_inlast, midi_inptr, w)); return; } midibuf[midi_inlast++] = (uae_u8)w; @@ -524,7 +524,7 @@ static void add2byte(long w) //put 2 Byte to Midibuffer static void add3byte(long w) //put 3 Byte to Midibuffer { if(midi_inlast >= BUFFLEN - 10) { - TRACE(("add3byte buffer full (%08.8X)\n", w)); + TRACE(("add3byte buffer full %d %d (%08.8X)\n", midi_inlast, midi_inptr, w)); return; } midibuf[midi_inlast++] = (uae_u8)w; @@ -549,8 +549,8 @@ LONG getmidibyte(void) //return midibyte or -1 if none EnterCriticalSection (&cs_proc); if (overflow == 1) { - char szMessage[ MAX_PATH ]; - WIN32GUI_LoadUIString(IDS_MIDIOVERFLOW, szMessage, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + WIN32GUI_LoadUIString(IDS_MIDIOVERFLOW, szMessage, MAX_DPATH ); gui_message( szMessage ); overflow = 0; } @@ -573,15 +573,11 @@ LONG getmidibyte(void) //return midibyte or -1 if none } } } + rv = -1; if (midi_inptr < midi_inlast) - { rv = midibuf[midi_inptr++]; - } - else - { + if (midi_inptr >= midi_inlast) midi_inptr = midi_inlast = 0; - rv = -1; - } LeaveCriticalSection(&cs_proc); return rv; } @@ -597,9 +593,9 @@ static void CALLBACK MidiInProc(HMIDIIN hMidiIn,UINT wMsg,DWORD dwInstance,DWORD { LPMIDIHDR midiin = (LPMIDIHDR)dwParam1; static long synum; - TRACE(("MIM_LONGDATA %d\n", midiin->dwBytesRecorded)); + TRACE(("MIM_LONGDATA bytes=%d ts=%u\n", midiin->dwBytesRecorded, dwParam2)); if (exitin == 1) goto end; //for safeness midi want close - if ((midi_inlast+midiin->dwBytesRecorded) >= (BUFFLEN-6)) + if ((midi_inlast + midiin->dwBytesRecorded) >= (BUFFLEN-6)) { overflow = 1; TRACE(("MIDI overflow1\n")); @@ -621,10 +617,10 @@ static void CALLBACK MidiInProc(HMIDIIN hMidiIn,UINT wMsg,DWORD dwInstance,DWORD } - if(wMsg == MM_MIM_DATA) + if(wMsg == MM_MIM_DATA || wMsg == MM_MIM_MOREDATA) { BYTE state = (BYTE)dwParam1; - TRACE(("MM_MIM_DATA %08.8X\n", dwParam1)); + TRACE(("%s %08.8X\n", wMsg == MM_MIM_DATA ? "MM_MIM_DATA" : "MM_MIM_MOREDATA", dwParam1)); if(state == 254) goto end; if(state < 0xf0) state = state & 0xf0; //else {add1byte(state); goto end;} diff --git a/od-win32/opengl.c b/od-win32/opengl.c index 94baaf63..43e16bf7 100755 --- a/od-win32/opengl.c +++ b/od-win32/opengl.c @@ -23,9 +23,11 @@ #include #include +#include typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC, const int *, const FLOAT *, UINT, int *, UINT *); /* not defined in MSVC's opengl.h */ #ifndef GL_UNSIGNED_SHORT_5_5_5_1_EXT @@ -74,6 +76,103 @@ static int exact_log2 (int v) return l; } +static int arbMultisampleSupported; +static int arbMultisampleFormat; +#if 0 + +// WGLisExtensionSupported: This Is A Form Of The Extension For WGL +static int WGLisExtensionSupported(const char *extension) +{ + const size_t extlen = strlen(extension); + const char *supported = NULL; + const char *p; + + // Try To Use wglGetExtensionStringARB On Current DC, If Possible + PROC wglGetExtString = wglGetProcAddress("wglGetExtensionsStringARB"); + + if (wglGetExtString) + supported = ((char*(__stdcall*)(HDC))wglGetExtString)(wglGetCurrentDC()); + + // If That Failed, Try Standard Opengl Extensions String + if (supported == NULL) + supported = (char*)glGetString(GL_EXTENSIONS); + + // If That Failed Too, Must Be No Extensions Supported + if (supported == NULL) + return 0; + + // Begin Examination At Start Of String, Increment By 1 On False Match + for (p = supported; ; p++) + { + // Advance p Up To The Next Possible Match + p = strstr(p, extension); + + if (p == NULL) + return 0; // No Match + + // Make Sure That Match Is At The Start Of The String Or That + // The Previous Char Is A Space, Or Else We Could Accidentally + // Match "wglFunkywglExtension" With "wglExtension" + + // Also, Make Sure That The Following Character Is Space Or NULL + // Or Else "wglExtensionTwo" Might Match "wglExtension" + if ((p==supported || p[-1]==' ') && (p[extlen]=='\0' || p[extlen]==' ')) + return 1; // Match + } + return 0; +} + +// InitMultisample: Used To Query The Multisample Frequencies +static int InitMultisample(HDC hDC, PIXELFORMATDESCRIPTOR *pfd, int depth) +{ + PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB; + int pixelFormat; + int valid, i; + UINT numFormats; + float fAttributes[] = {0,0}; + // These Attributes Are The Bits We Want To Test For In Our Sample + // Everything Is Pretty Standard, The Only One We Want To + // Really Focus On Is The SAMPLE BUFFERS ARB And WGL SAMPLES + // These Two Are Going To Do The Main Testing For Whether Or Not + // We Support Multisampling On This Hardware. + int iAttributes[] = { + WGL_DRAW_TO_WINDOW_ARB,GL_TRUE, + WGL_SUPPORT_OPENGL_ARB,GL_TRUE, + WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB, + WGL_COLOR_BITS_ARB,pfd.cDepthBits, + WGL_ALPHA_BITS_ARB,0, + WGL_DEPTH_BITS_ARB,0, + WGL_STENCIL_BITS_ARB,0, + WGL_DOUBLE_BUFFER_ARB,GL_TRUE, + WGL_SAMPLE_BUFFERS_ARB,GL_TRUE, + WGL_SAMPLES_ARB,0, + 0,0 + }; + + // See If The String Exists In WGL! + if (!WGLisExtensionSupported("WGL_ARB_multisample")) + return 0; + + // Get Our Pixel Format + wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); + if (!wglChoosePixelFormatARB) + return 0; + + for (i = 8; i >= 2; i -= 2) { + iAttributes[19] = i; + valid = wglChoosePixelFormatARB(hDC,iAttributes,fAttributes,1,&pixelFormat,&numFormats); + // If We Returned True, And Our Format Count Is Greater Than 1 + if (valid && numFormats >= 1) { + arbMultisampleSupported = i; + arbMultisampleFormat = pixelFormat; + return arbMultisampleSupported; + } + } + // Return The Valid Format + return arbMultisampleSupported; +} +#endif + const char *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth) { int PixelFormat; @@ -92,16 +191,7 @@ const char *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth) t_width = t_w; t_height = t_h; - memset (&pfd, 0, sizeof (pfd)); - pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; - pfd.cColorBits = depth; - pfd.cDepthBits = 0; - pfd.iLayerType = PFD_MAIN_PLANE; - hwnd = ahwnd; - openglhdc = GetDC (hwnd); total_textures = 2; if (currprefs.gfx_afullscreen && WIN32GFX_GetDepth (TRUE) < 15) { @@ -109,27 +199,53 @@ const char *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth) return errmsg; } - if (!(PixelFormat = ChoosePixelFormat (openglhdc, &pfd))) { - strcpy (errmsg, "OPENGL: can't find suitable pixelformat"); - return errmsg; - } - - if (!SetPixelFormat (openglhdc, PixelFormat, &pfd)) { - strcpy (errmsg, "OPENGL: can't set pixelformat"); - return errmsg; - } - - if (!(hrc = wglCreateContext (openglhdc))) { - strcpy (errmsg, "OPENGL: can't create gl rendering context"); - return errmsg; - } - - if (!wglMakeCurrent (openglhdc, hrc)) { - strcpy (errmsg, "OPENGL: can't activate gl rendering context"); - return errmsg; + memset (&pfd, 0, sizeof (pfd)); + pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_TYPE_RGBA; + pfd.cColorBits = depth; + pfd.iLayerType = PFD_MAIN_PLANE; + + for (;;) { + + openglhdc = GetDC (hwnd); + + if(!arbMultisampleSupported) { + PixelFormat = ChoosePixelFormat (openglhdc, &pfd); // Find A Compatible Pixel Format + if (PixelFormat == 0) { // Did We Find A Compatible Format? + strcpy (errmsg, "OPENGL: can't find suitable pixelformat"); + return errmsg; + } + } else { + PixelFormat = arbMultisampleFormat; + } + + if (!SetPixelFormat (openglhdc, PixelFormat, &pfd)) { + sprintf (errmsg, "OPENGL: can't set pixelformat %x", PixelFormat); + return errmsg; + } + + if (!(hrc = wglCreateContext (openglhdc))) { + strcpy (errmsg, "OPENGL: can't create gl rendering context"); + return errmsg; + } + + if (!wglMakeCurrent (openglhdc, hrc)) { + strcpy (errmsg, "OPENGL: can't activate gl rendering context"); + return errmsg; + } +#if 0 + if(!arbMultisampleSupported) { + if(InitMultisample(openglhdc, &pfd)) { + OGL_free (); + continue; + } + } +#endif + break; } - - glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_texture_size); + + glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_texture_size); required_texture_size = 2 << exact_log2 (t_width > t_height ? t_width : t_height); if (max_texture_size < t_width || max_texture_size < t_height) { sprintf (errmsg, "OPENGL: %d * %d or bigger texture support required\nYour card's maximum texture size is only %d * %d", diff --git a/od-win32/resources/resource.h b/od-win32/resources/resource.h index 72279d53..90e0ddbf 100755 --- a/od-win32/resources/resource.h +++ b/od-win32/resources/resource.h @@ -189,7 +189,6 @@ #define IDS_TREEVIEW_MISC 234 #define IDS_TREEVIEW_SETTINGS 235 #define IDS_WINUAETITLE_MMB 236 -#define IDS_IDS_WINUAETITLE_NORMAL 237 #define IDS_WINUAETITLE_NORMAL 237 #define IDC_RESOLUTION 1021 #define IDC_SERIAL 1022 @@ -317,6 +316,7 @@ #define IDC_SNAPSHOT 1285 #define IDC_DOSAVESTATE 1286 #define IDC_DOLOADSTATE 1287 +#define IDC_PROWIZARD 1288 #define IDC_PORT0_JOY0 1300 #define IDC_PORT0_JOY1 1301 #define IDC_PORT0_MOUSE 1302 diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index 4da9f16a..4f950970 100755 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -506,18 +506,18 @@ BEGIN HIDC_CREATELOGFILE CONTROL "Illegal mem accesses",IDC_ILLEGAL,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,189,109,80,10 - GROUPBOX "State files:",IDC_STATIC,98,126,195,76 - PUSHBUTTON "Load state...",IDC_DOLOADSTATE,105,143,49,14 - PUSHBUTTON "Save state...",IDC_DOSAVESTATE,106,169,49,14 + GROUPBOX "State files:",IDC_STATIC,98,126,195,83 + PUSHBUTTON "Load state...",IDC_DOLOADSTATE,105,145,49,14 + PUSHBUTTON "Save state...",IDC_DOSAVESTATE,106,171,49,14 CONTROL "Enable state recording",IDC_STATE_CAPTURE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,188,142,88,10 - RTEXT "Recording rate (seconds)",IDC_STATE_RATE_TEXT,157,160, + BS_AUTOCHECKBOX | WS_TABSTOP,188,144,88,10 + RTEXT "Recording rate (seconds)",IDC_STATE_RATE_TEXT,157,162, 86,10,SS_CENTERIMAGE | WS_TABSTOP - COMBOBOX IDC_STATE_RATE,248,158,38,65,CBS_DROPDOWN | WS_VSCROLL | + COMBOBOX IDC_STATE_RATE,248,160,38,65,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP RTEXT "Recording buffer (MB)",IDC_STATE_BUFFERSIZE_TEXT,157, - 180,83,10,SS_CENTERIMAGE | WS_TABSTOP - COMBOBOX IDC_STATE_BUFFERSIZE,248,178,38,65,CBS_DROPDOWN | + 182,83,10,SS_CENTERIMAGE | WS_TABSTOP + COMBOBOX IDC_STATE_BUFFERSIZE,248,180,38,65,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP CONTROL "Disable UAEFSDB-support",IDC_NOUAEFSDB,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,29,76,115,10 @@ -635,7 +635,7 @@ BEGIN BS_AUTORADIOBUTTON | WS_TABSTOP,39,197,95,10 END -IDD_AVIOUTPUT DIALOGEX 0, 0, 198, 188 +IDD_AVIOUTPUT DIALOGEX 0, 0, 197, 210 STYLE DS_SETFONT | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN @@ -655,17 +655,19 @@ BEGIN IDC_AVIOUTPUT_FRAMELIMITER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,28,68,142,10 CONTROL "AVIOutput enabled",IDC_AVIOUTPUT_ACTIVATED,"Button", - BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,26,83,142,12 + BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,26,83,142,14 GROUPBOX "Playback Rate:",IDC_STATIC,5,107,184,50 CONTROL "PAL",IDC_AVIOUTPUT_PAL,"Button",BS_AUTORADIOBUTTON | - BS_PUSHLIKE | BS_FLAT,24,124,66,8 + BS_PUSHLIKE | BS_FLAT,24,121,66,12 CONTROL "NTSC",IDC_AVIOUTPUT_NTSC,"Button",BS_AUTORADIOBUTTON | - BS_PUSHLIKE | BS_FLAT,95,124,66,8 + BS_PUSHLIKE | BS_FLAT,102,121,66,12 CONTROL "Slider1",IDC_AVIOUTPUT_FPS,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_ENABLESELRANGE | WS_TABSTOP,21,137,120, 11 - LTEXT "fps",IDC_AVIOUTPUT_FPS_STATIC,141,136,23,8 - PUSHBUTTON "Save Screenshot",IDC_SCREENSHOT,46,167,95,12 + LTEXT "fps",IDC_AVIOUTPUT_FPS_STATIC,148,138,23,8 + PUSHBUTTON "Save Screenshot",IDC_SCREENSHOT,15,176,95,14 + GROUPBOX "Ripper",IDC_STATIC,5,160,184,41 + PUSHBUTTON "Pro Wizard",IDC_PROWIZARD,127,176,49,14,WS_DISABLED END IDD_INPUT DIALOGEX 0, 0, 300, 242 @@ -806,11 +808,11 @@ BEGIN END IDD_PANEL DIALOGEX 0, 0, 420, 278 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES | WS_EX_CONTROLPARENT CAPTION "WinUAE Properties" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN CONTROL "",IDC_PANELTREE,"SysTreeView32",TVS_HASLINES | TVS_SHOWSELALWAYS | TVS_NOSCROLL | WS_BORDER | @@ -973,12 +975,6 @@ BEGIN BOTTOMMARGIN, 215 END - IDD_AVIOUTPUT, DIALOG - BEGIN - RIGHTMARGIN, 164 - BOTTOMMARGIN, 187 - END - IDD_INPUT, DIALOG BEGIN BOTTOMMARGIN, 187 @@ -1117,7 +1113,7 @@ BEGIN IDS_SELECTFILESYSROOT "Please select your file-system root directory..." IDS_DEFAULTMIDIOUT "Default MIDI-Out Device" IDS_CONTRIBUTORS1 "Bernd Schmidt - The Grand-Master\nSam Jordan - Custom-chip, floppy-DMA, etc.\nMathias Ortmann - Original WinUAE Main Guy, BSD Socket support\nBrian King - Picasso96 Support, Integrated GUI for WinUAE, previous WinUAE Main Guy\nToni Wilen - Core updates, WinUAE Main Guy\nGustavo Goedert/Peter Remmers/Michael Sontheimer/Tomi Hakala/Tim Gunn/Nemo Pohle - DOS Port Stuff\nSamuel Devulder/Olaf Barthel/Sam Jordan - Amiga Ports\nKrister Bergman - XFree86 and OS/2 Port\nA. Blanchard/Ernesto Corvi - MacOS Port\nChristian Bauer - BeOS Port\nIan Stephenson - NextStep Port\nPeter Teichmann - Acorn/RiscOS Port\nStefan Reinauer - ZorroII/III AutoConfig, Serial Support\nChristian Schmitt/Chris Hames - Serial Support\nHerman ten Brugge - 68020/68881 Emulation Code\nTauno Taipaleenmaki - Various UAE-Control/UAE-Library Support\nBrett Eden/Tim Gunn/Paolo Besser/Nemo Pohle - Various Docs and Web-Sites\nGeorg Veichtlbauer - Help File coordinator, German GUI\nFulvio Leonardi - Italian translator for WinUAE\n" - IDS_CONTRIBUTORS2 "Special thanks to Alexander Kneer and Tobias Abt (The Picasso96 Team)\n" + IDS_CONTRIBUTORS2 "Bill Panagouleas - Hardware support\nSpecial thanks to Alexander Kneer and Tobias Abt (The Picasso96 Team)\n" IDS_INVALIDPRTPORT "The printer you have in this configuration is not valid on this machine.\n" IDS_RESTOREUSS "Restore a UAE Snap-Shot File" IDS_USS "UAE Snap-Shot Files" diff --git a/od-win32/resources/winuae_minimal.rc b/od-win32/resources/winuae_minimal.rc index 73b1b104..372839d1 100755 --- a/od-win32/resources/winuae_minimal.rc +++ b/od-win32/resources/winuae_minimal.rc @@ -32,7 +32,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // IDD_KICKSTART DIALOGEX 0, 0, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_CAPTION +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD EXSTYLE WS_EX_CONTEXTHELP FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN @@ -46,6 +46,8 @@ BEGIN RTEXT "Extended ROM File:",IDC_ROMFILE2TEXT,10,68,75,10 EDITTEXT IDC_ROMFILE2,90,63,185,15,ES_AUTOHSCROLL PUSHBUTTON "...",IDC_ROMCHOOSER2,280,63,10,15 + CONTROL "MAPROM emulation",IDC_MAPROM,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,104,86,80,10 CONTROL "ShapeShifter support",IDC_KICKSHIFTER,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,196,86,80,10 GROUPBOX "Misc settings:",-1,5,105,290,59 @@ -55,70 +57,67 @@ BEGIN RTEXT "Cartridge ROM File:",IDC_FLASHTEXT2,8,140,75,10 EDITTEXT IDC_CARTFILE,89,137,185,15,ES_AUTOHSCROLL PUSHBUTTON "...",IDC_CARTCHOOSER,279,137,10,15 - CONTROL "MAPROM emulation",IDC_MAPROM,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,104,86,80,10 END -IDD_DISPLAY DIALOGEX 0, 0, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_CAPTION +IDD_DISPLAY DIALOGEX 0, 0, 300, 194 +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - GROUPBOX "Amiga screen resolution",IDC_SCREENRESTEXT,24,0,185,67, - BS_LEFT - RTEXT "Fullscreen",IDC_SELECTRESTEXT,27,17,34,15, + GROUPBOX "Screen",IDC_SCREENRESTEXT,12,0,199,67,BS_LEFT + RTEXT "Fullscreen",IDC_SELECTRESTEXT,22,17,34,15, SS_CENTERIMAGE - COMBOBOX IDC_RESOLUTION,66,27,72,150,CBS_DROPDOWNLIST | + COMBOBOX IDC_DISPLAYSELECT,61,10,143,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_REFRESHRATE,142,27,60,150,CBS_DROPDOWNLIST | + COMBOBOX IDC_RESOLUTION,61,27,77,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP - RTEXT "Windowed",IDC_WINDOWEDTEXT,27,51,35,8 - EDITTEXT IDC_XSIZE,66,48,30,12,ES_NUMBER - EDITTEXT IDC_YSIZE,108,48,30,12,ES_NUMBER + COMBOBOX IDC_REFRESHRATE,143,27,61,150,CBS_DROPDOWNLIST | + CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP + RTEXT "Windowed",IDC_WINDOWEDTEXT,22,51,35,8 + EDITTEXT IDC_XSIZE,61,48,35,12,ES_NUMBER + EDITTEXT IDC_YSIZE,103,48,35,12,ES_NUMBER CONTROL "VSync",IDC_VSYNC,"Button",BS_AUTOCHECKBOX | BS_LEFT | - WS_TABSTOP,146,48,54,10 - GROUPBOX "Settings",IDC_SETTINGSTEXT,24,72,186,73 + WS_TABSTOP,145,49,54,10 + GROUPBOX "Settings",IDC_SETTINGSTEXT,12,77,199,73 CONTROL "Full Screen",IDC_AFULLSCREEN,"Button",BS_AUTOCHECKBOX | - BS_LEFT | WS_TABSTOP,35,84,90,10 + BS_LEFT | WS_TABSTOP,35,89,90,10 CONTROL "Correct aspect ratio",IDC_ASPECT,"Button", - BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,35,101,90,10 + BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,35,106,90,10 CONTROL "Full Screen RTG",IDC_PFULLSCREEN,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,131,84,70,10,0, + BS_AUTOCHECKBOX | WS_TABSTOP,131,89,70,10,0, HIDC_PFULLSCREEN - LTEXT "Refresh:",IDC_REFRESHTEXT,34,124,28,8 + CONTROL "Lo-res",IDC_LORES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, + 131,106,70,10,0,HIDC_LORES + LTEXT "Refresh:",IDC_REFRESHTEXT,34,129,28,8 CONTROL "Slider1",IDC_FRAMERATE,"msctls_trackbar32", - TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,64,119,75,20 - CTEXT "",IDC_RATETEXT,144,119,50,20,SS_SUNKEN | WS_BORDER - GROUPBOX "Centering",IDC_STATIC,217,0,58,67 + TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,64,124,75,20 + CTEXT "",IDC_RATETEXT,144,124,50,20,SS_SUNKEN | WS_BORDER + GROUPBOX "Centering",IDC_STATIC,221,0,61,67 CONTROL "Horizontal",IDC_XCENTER,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,225,16,45,10 + WS_TABSTOP,229,16,45,10 CONTROL "Vertical",IDC_YCENTER,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,225,32,39,10 - GROUPBOX "Line mode",IDC_LINEMODE,217,72,58,74 + WS_TABSTOP,229,32,39,10 + GROUPBOX "Line mode",IDC_LINEMODE,222,77,61,74 CONTROL "Normal",IDC_LM_NORMAL,"Button",BS_AUTORADIOBUTTON | - BS_LEFT | WS_GROUP | WS_TABSTOP,225,84,38,10 + BS_LEFT | WS_GROUP | WS_TABSTOP,233,89,38,10 CONTROL "Doubled",IDC_LM_DOUBLED,"Button",BS_AUTORADIOBUTTON | - BS_LEFT | WS_TABSTOP,225,100,43,10 + BS_LEFT | WS_TABSTOP,233,105,41,10 CONTROL "Scanline",IDC_LM_SCANLINES,"Button",BS_AUTORADIOBUTTON | - BS_LEFT | WS_TABSTOP,225,116,40,10 - COMBOBOX IDC_DA_MODE,35,151,58,150,CBS_DROPDOWNLIST | + BS_LEFT | WS_TABSTOP,233,121,40,10 + COMBOBOX IDC_DA_MODE,35,163,58,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP CONTROL "",IDC_DA_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | - TBS_TOP | NOT WS_VISIBLE | WS_TABSTOP,97,147,101,20 - PUSHBUTTON "Detect pixel format",IDC_TEST16BIT,211,151,64,14,0,0, + TBS_TOP | NOT WS_VISIBLE | WS_TABSTOP,97,159,101,20 + PUSHBUTTON "Detect pixel format",IDC_TEST16BIT,221,163,67,14,0,0, HIDC_TEST16BIT - COMBOBOX IDC_DISPLAYSELECT,66,10,136,150,CBS_DROPDOWNLIST | - CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP - CONTROL "Lo-res",IDC_LORES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - 131,101,70,10,0,HIDC_LORES END IDD_MEMORY DIALOGEX 0, 0, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_CAPTION +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD EXSTYLE WS_EX_CONTEXTHELP FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - GROUPBOX "Memory Settings:",-1,19,40,260,93 + GROUPBOX "Memory Settings:",-1,14,40,274,93 RTEXT "Chip:",-1,24,60,20,10,SS_CENTERIMAGE CONTROL "Slider1",IDC_CHIPMEM,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,54,55,50,20 @@ -148,7 +147,7 @@ BEGIN END IDD_CPU DIALOGEX 0, 0, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_CAPTION +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN GROUPBOX "CPU Type:",IDC_STATIC,5,5,80,134,BS_LEFT @@ -212,155 +211,166 @@ BEGIN WS_TABSTOP,230,154,64,10 END -IDD_FLOPPY DIALOGEX 0, 0, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION +IDD_FLOPPY DIALOGEX 0, 0, 300, 230 +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - RTEXT "DF0:",IDC_STATIC,3,16,20,15,SS_CENTERIMAGE - COMBOBOX IDC_DF0TYPE,28,16,41,50,CBS_DROPDOWNLIST | WS_VSCROLL | + RTEXT "DF0:",IDC_STATIC,16,6,20,10,SS_CENTERIMAGE + COMBOBOX IDC_DF0TEXT,2,22,296,75,CBS_DROPDOWN | CBS_AUTOHSCROLL | + WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_DF0TYPE,54,5,41,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_DF0TEXT,74,15,130,15,ES_AUTOHSCROLL - PUSHBUTTON "...",IDC_DF0,208,15,10,15 - PUSHBUTTON "Eject",IDC_EJECT0,222,15,30,15 - CONTROL "Write protect",IDC_DF0WP,"Button",BS_AUTOCHECKBOX | - BS_MULTILINE | WS_TABSTOP,256,16,39,15 - RTEXT "DF1:",IDC_STATIC,3,41,20,15,SS_CENTERIMAGE - COMBOBOX IDC_DF1TYPE,28,41,41,50,CBS_DROPDOWNLIST | WS_VSCROLL | + RTEXT "Write Protected",IDC_STATIC,174,8,59,10,SS_CENTERIMAGE + CONTROL "",IDC_DF0WP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | + WS_TABSTOP,238,4,10,15 + PUSHBUTTON "Eject",IDC_EJECT0,253,4,30,15 + PUSHBUTTON "...",IDC_DF0,287,4,10,15 + RTEXT "DF1:",IDC_STATIC,16,41,20,10,SS_CENTERIMAGE + COMBOBOX IDC_DF1TEXT,2,58,296,75,CBS_DROPDOWN | CBS_AUTOHSCROLL | + WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_DF1TYPE,54,40,41,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_DF1TEXT,74,40,130,15,ES_AUTOHSCROLL - PUSHBUTTON "...",IDC_DF1,208,40,10,15 - PUSHBUTTON "Eject",IDC_EJECT1,222,40,30,15 - CONTROL "Write protect",IDC_DF1WP,"Button",BS_AUTOCHECKBOX | - BS_MULTILINE | WS_TABSTOP,256,40,39,15 - RTEXT "DF2:",IDC_STATIC,3,66,20,15,SS_CENTERIMAGE - COMBOBOX IDC_DF2TYPE,28,66,41,50,CBS_DROPDOWNLIST | WS_VSCROLL | + RTEXT "Write Protected",IDC_STATIC,174,42,59,10,SS_CENTERIMAGE + CONTROL "",IDC_DF1WP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | + WS_TABSTOP,238,39,10,15 + PUSHBUTTON "Eject",IDC_EJECT1,253,39,30,15 + PUSHBUTTON "...",IDC_DF1,287,39,10,15 + RTEXT "DF2:",IDC_STATIC,16,77,20,10,SS_CENTERIMAGE + COMBOBOX IDC_DF2TEXT,2,93,296,75,CBS_DROPDOWN | CBS_AUTOHSCROLL | + WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_DF2TYPE,54,76,41,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_DF2TEXT,74,65,130,15,ES_AUTOHSCROLL - PUSHBUTTON "...",IDC_DF2,208,65,10,15 - PUSHBUTTON "Eject",IDC_EJECT2,222,65,30,15 - CONTROL "Write protect",IDC_DF2WP,"Button",BS_AUTOCHECKBOX | - BS_MULTILINE | WS_TABSTOP,256,65,39,15 - RTEXT "DF3:",IDC_STATIC,3,90,20,15,SS_CENTERIMAGE - COMBOBOX IDC_DF3TYPE,28,91,41,50,CBS_DROPDOWNLIST | WS_VSCROLL | + RTEXT "Write Protected",IDC_STATIC,174,77,59,10,SS_CENTERIMAGE + CONTROL "",IDC_DF2WP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | + WS_TABSTOP,238,75,9,15 + PUSHBUTTON "Eject",IDC_EJECT2,253,75,30,15 + PUSHBUTTON "...",IDC_DF2,287,75,10,15 + RTEXT "DF3:",IDC_STATIC,16,113,20,9,SS_CENTERIMAGE + COMBOBOX IDC_DF3TEXT,2,130,296,75,CBS_DROPDOWN | CBS_AUTOHSCROLL | + WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_DF3TYPE,54,112,41,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_DF3TEXT,74,90,130,15,ES_AUTOHSCROLL - PUSHBUTTON "...",IDC_DF3,208,90,10,15 - PUSHBUTTON "Eject",IDC_EJECT3,222,90,30,15 - CONTROL "Write protect",IDC_DF3WP,"Button",BS_AUTOCHECKBOX | - BS_MULTILINE | WS_TABSTOP,256,90,39,15 - COMBOBOX IDC_FLOPPYTYPE,28,118,41,50,CBS_DROPDOWNLIST | + RTEXT "Write Protected",IDC_STATIC,174,113,59,10, + SS_CENTERIMAGE + CONTROL "",IDC_DF3WP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | + WS_TABSTOP,238,111,9,15 + PUSHBUTTON "Eject",IDC_EJECT3,253,111,30,15 + PUSHBUTTON "...",IDC_DF3,287,111,10,15 + GROUPBOX "New disk image",IDC_SETTINGSTEXT,5,152,289,35 + COMBOBOX IDC_FLOPPYTYPE,16,165,51,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Create Standard ""Floppy""",IDC_CREATE,74,118,97,15 - PUSHBUTTON "Create Custom ""Floppy""",IDC_CREATE_RAW,182,118,87,15 - RTEXT "Floppy Speed:",IDC_FLOPPYSPD_TEXT,9,149,45,10, - SS_CENTERIMAGE | WS_TABSTOP + PUSHBUTTON "Create Standard ""Floppy""",IDC_CREATE,76,165,97,15 + PUSHBUTTON "Create Custom ""Floppy""",IDC_CREATE_RAW,183,165,101,15 + GROUPBOX "Floppy drive emulation speed",IDC_SETTINGSTEXT2,5,188, + 289,35 CONTROL "",IDC_FLOPPYSPD,"msctls_trackbar32",TBS_AUTOTICKS | - TBS_TOP | WS_TABSTOP,56,145,120,20 - EDITTEXT IDC_FLOPPYSPDTEXT,177,148,68,12,ES_CENTER | ES_READONLY + TBS_TOP | WS_TABSTOP,32,198,116,20 + EDITTEXT IDC_FLOPPYSPDTEXT,169,201,107,12,ES_CENTER | ES_READONLY END -IDD_HARDDISK DIALOGEX 0, 0, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_CAPTION +IDD_HARDDISK DIALOGEX 0, 0, 300, 242 +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD EXSTYLE WS_EX_CONTEXTHELP FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN CONTROL "List1",IDC_VOLUMELIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | - LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,5,260,125 - PUSHBUTTON "",IDC_UP,270,25,25,15,BS_ICON - PUSHBUTTON "",IDC_DOWN,270,105,25,15,BS_ICON - PUSHBUTTON "Add &Directory...",IDC_NEW_FS,5,135,60,15 - PUSHBUTTON "Add &Hardfile...",IDC_NEW_HF,70,135,60,15 - PUSHBUTTON "Add Ha&rddrive",IDC_NEW_HD,135,135,60,15 + LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,5,260,191 + PUSHBUTTON "",IDC_UP,270,52,25,15,BS_ICON + PUSHBUTTON "",IDC_DOWN,270,132,25,15,BS_ICON + PUSHBUTTON "Add &Directory...",IDC_NEW_FS,5,202,60,15 + PUSHBUTTON "Add &Hardfile...",IDC_NEW_HF,70,202,60,15 + PUSHBUTTON "Add Ha&rddrive",IDC_NEW_HD,135,202,60,15 CONTROL "Add PC Drives at Startup",IDC_MAPDRIVES,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,5,155,105,10,0, + BS_AUTOCHECKBOX | WS_TABSTOP,5,222,105,10,0, HIDC_MAPDRIVES - PUSHBUTTON "Remove",IDC_REMOVE,135,153,60,15 - PUSHBUTTON "&Properties",IDC_EDIT,200,153,60,15 + PUSHBUTTON "Remove",IDC_REMOVE,135,220,60,15 + PUSHBUTTON "&Properties",IDC_EDIT,200,220,60,15 END -IDD_SOUND DIALOGEX 0, 0, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_CAPTION +IDD_SOUND DIALOGEX 0, 0, 300, 208 +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - RTEXT "Sound Card:",IDC_SOUNDCARD,11,9,41,13,SS_CENTERIMAGE - COMBOBOX IDC_SOUNDCARDLIST,60,9,221,50,CBS_DROPDOWNLIST | + RTEXT "Sound device:",IDC_SOUNDCARD,8,9,51,13,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDCARDLIST,64,9,229,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Sound Emulation",IDC_SOUNDSETTINGS,7,25,120,58 + GROUPBOX "Sound Emulation",IDC_SOUNDSETTINGS,7,30,120,68 CONTROL "Disabled",IDC_SOUND0,"Button",BS_AUTORADIOBUTTON | - WS_GROUP | WS_TABSTOP,15,35,43,10 + WS_GROUP | WS_TABSTOP,15,45,43,10 CONTROL "Disabled, but emulated",IDC_SOUND1,"Button", - BS_AUTORADIOBUTTON | BS_LEFT | WS_TABSTOP,15,47,88,10 + BS_AUTORADIOBUTTON | WS_TABSTOP,15,57,88,10 CONTROL "Enabled",IDC_SOUND2,"Button",BS_AUTORADIOBUTTON | - BS_LEFT | WS_TABSTOP,15,59,42,10 + WS_TABSTOP,15,69,42,10 CONTROL "Enabled, 100% accurate",IDC_SOUND3,"Button", - BS_AUTORADIOBUTTON | BS_LEFT | WS_TABSTOP,15,71,93,10 - GROUPBOX "Settings",IDC_SOUNDINTERPOLATION2,133,25,160,58 - RTEXT "Frequency:",IDC_SOUNDFREQTXT,138,33,37,8,SS_CENTERIMAGE - COMBOBOX IDC_SOUNDFREQ,140,42,67,75,CBS_DROPDOWN | WS_VSCROLL | + BS_AUTORADIOBUTTON | WS_TABSTOP,15,81,93,10 + GROUPBOX "Settings",IDC_SOUNDINTERPOLATION2,133,30,160,68 + RTEXT "Frequency:",IDC_SOUNDFREQTXT,138,40,37,8,SS_CENTERIMAGE + COMBOBOX IDC_SOUNDFREQ,140,49,67,75,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - RTEXT "Audio filter:",IDC_SOUNDFILTERTXT,140,58,36,8, + RTEXT "Audio filter:",IDC_SOUNDFILTERTXT,140,65,36,8, SS_CENTERIMAGE - COMBOBOX IDC_SOUNDFILTER,140,67,67,75,CBS_DROPDOWNLIST | + COMBOBOX IDC_SOUNDFILTER,140,74,67,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Sound buffer size",IDC_STATIC,7,108,120,29 + RTEXT "Stereo mode:",IDC_SOUNDSTEREOTXT,223,40,41,8, + SS_CENTERIMAGE + COMBOBOX IDC_SOUNDSTEREO,220,49,67,75,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + RTEXT "Interpolation:",IDC_SOUNDINTERPOLATIONTXT,222,65,41,8, + SS_CENTERIMAGE + COMBOBOX IDC_SOUNDINTERPOLATION,220,74,67,75,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + GROUPBOX "Disk Drive Sound Emulation",IDC_STATIC,8,102,285,29 + COMBOBOX IDC_SOUNDDRIVE,15,113,32,75,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SOUNDDRIVESELECT,55,113,120,75,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + CONTROL "",IDC_SOUNDDRIVEVOLUME,"msctls_trackbar32", + TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,183,109,107,19 + GROUPBOX "Sound buffer size",IDC_STATIC,7,136,120,29 CONTROL "Slider1",IDC_SOUNDBUFFERRAM,"msctls_trackbar32", - TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,14,116,106,19 - CTEXT "",IDC_SOUNDBUFFERMEM,134,116,40,16,SS_CENTERIMAGE | + TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,14,144,106,19 + CTEXT "",IDC_SOUNDBUFFERMEM,134,144,40,16,SS_CENTERIMAGE | SS_SUNKEN | WS_BORDER | WS_TABSTOP - GROUPBOX "Sound driver lag compensation",IDC_STATIC,7,139,120,28 + GROUPBOX "Sound driver lag compensation",IDC_STATIC,7,170,120,28 CONTROL "Slider1",IDC_SOUNDADJUST,"msctls_trackbar32", - TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,14,147,107,19 - CTEXT "",IDC_SOUNDADJUSTNUM,134,152,40,16,SS_CENTERIMAGE | + TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,14,178,107,19 + PUSHBUTTON "Calibrate",IDC_SOUNDCALIBRATE,183,178,40,14 + CTEXT "",IDC_SOUNDADJUSTNUM,134,178,40,16,SS_CENTERIMAGE | SS_SUNKEN | WS_BORDER | WS_TABSTOP - PUSHBUTTON "Calibrate",IDC_SOUNDCALIBRATE,134,135,40,14 - COMBOBOX IDC_SOUNDSTEREO,220,42,67,75,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_SOUNDINTERPOLATION,220,67,67,75,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - RTEXT "Stereo mode:",IDC_SOUNDSTEREOTXT,223,33,41,8, - SS_CENTERIMAGE - RTEXT "Interpolation:",IDC_SOUNDINTERPOLATIONTXT,222,58,41,8, - SS_CENTERIMAGE - GROUPBOX "Volume",IDC_STATIC,181,108,112,29 + GROUPBOX "Volume",IDC_STATIC,181,136,112,29 CONTROL "",IDC_SOUNDVOLUME,"msctls_trackbar32",TBS_AUTOTICKS | - TBS_TOP | WS_TABSTOP,183,116,107,19 - COMBOBOX IDC_SOUNDDRIVE,15,92,32,75,CBS_DROPDOWNLIST | WS_VSCROLL | - WS_TABSTOP - COMBOBOX IDC_SOUNDDRIVESELECT,55,92,120,75,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - GROUPBOX "Disk Drive Sound Emulation",IDC_STATIC,8,83,285,25 - CONTROL "",IDC_SOUNDDRIVEVOLUME,"msctls_trackbar32", - TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,183,88,107,19 + TBS_TOP | WS_TABSTOP,183,144,107,19 END -IDD_LOADSAVE DIALOGEX 0, 0, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_BORDER +IDD_LOADSAVE DIALOGEX 0, 0, 302, 240 +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - CONTROL "List1",IDC_CONFIGLIST,"SysListView32",LVS_REPORT | - LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | - LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | - WS_TABSTOP,5,5,290,105,0,HIDC_CONFIGLIST - RTEXT "Name:",IDC_STATIC,20,115,25,15,SS_CENTERIMAGE - EDITTEXT IDC_EDITNAME,50,115,155,15,ES_AUTOHSCROLL,0, + CONTROL "",IDC_CONFIGTREE,"SysTreeView32",TVS_HASLINES | + TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_BORDER | + WS_TABSTOP,6,4,289,155,WS_EX_CLIENTEDGE + RTEXT "Name:",IDC_STATIC,5,202,40,15,SS_CENTERIMAGE + EDITTEXT IDC_EDITNAME,50,202,155,15,ES_AUTOHSCROLL,0, HIDC_EDITNAME - RTEXT "Description:",IDC_STATIC,5,135,40,15,SS_CENTERIMAGE - EDITTEXT IDC_EDITDESCRIPTION,50,135,155,15,ES_AUTOHSCROLL,0, + RTEXT "Path:",IDC_STATIC,5,184,39,15,SS_CENTERIMAGE + EDITTEXT IDC_EDITPATH,50,184,155,15,ES_AUTOHSCROLL | WS_DISABLED, + 0,HIDC_EDITPATH + RTEXT "Description:",IDC_STATIC,5,163,40,15,SS_CENTERIMAGE + EDITTEXT IDC_EDITDESCRIPTION,50,163,245,15,ES_AUTOHSCROLL,0, HIDC_EDITDESCRIPTION - GROUPBOX "Extra Info",IDC_STATIC,210,115,85,35 - PUSHBUTTON "View",IDC_VIEWINFO,215,130,35,15 - PUSHBUTTON "Set",IDC_SETINFO,255,130,35,15 - PUSHBUTTON "Load",IDC_QUICKLOAD,5,155,40,15 - PUSHBUTTON "Save",IDC_QUICKSAVE,50,155,40,15 - PUSHBUTTON "Load From...",IDC_LOAD,100,155,45,15 - PUSHBUTTON "Save As...",IDC_SAVE,150,155,40,15 - PUSHBUTTON "Delete",IDC_DELETE,200,155,40,15 - PUSHBUTTON "Exit",IDC_EXIT,250,155,40,15 + GROUPBOX "Extra Info",IDC_STATIC,210,179,85,38 + PUSHBUTTON "View",IDC_VIEWINFO,215,195,35,15 + PUSHBUTTON "Set",IDC_SETINFO,255,194,35,15 + PUSHBUTTON "Load",IDC_QUICKLOAD,5,222,40,15 + PUSHBUTTON "Save",IDC_QUICKSAVE,50,222,40,15 + PUSHBUTTON "Load From...",IDC_LOAD,125,222,45,15 + PUSHBUTTON "Save As...",IDC_SAVE,175,222,40,15 + PUSHBUTTON "Delete",IDC_DELETE,255,222,40,15 END -IDD_PORTS DIALOGEX 0, 0, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_BORDER +IDD_PORTS DIALOGEX 0, 0, 300, 202 +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN RTEXT "Serial:",IDC_STATIC,20,15,25,15,SS_CENTERIMAGE @@ -375,56 +385,58 @@ BEGIN RTEXT "Printer:",IDC_STATIC,155,15,25,15,SS_CENTERIMAGE COMBOBOX IDC_PRINTERLIST,185,15,95,134,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - RTEXT "MIDI Out:",IDC_MIDI,10,47,34,15,SS_CENTERIMAGE - COMBOBOX IDC_MIDIOUTLIST,50,47,95,130,CBS_DROPDOWNLIST | + RTEXT "Out:",IDC_MIDI,10,64,34,15,SS_CENTERIMAGE + COMBOBOX IDC_MIDIOUTLIST,50,64,95,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - RTEXT "MIDI In:",IDC_MIDI2,150,47,29,15,SS_CENTERIMAGE - COMBOBOX IDC_MIDIINLIST,185,47,95,134,CBS_DROPDOWNLIST | + RTEXT "In:",IDC_MIDI2,150,64,29,15,SS_CENTERIMAGE + COMBOBOX IDC_MIDIINLIST,185,64,95,134,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Amiga Mouse Port 0",IDC_PORT0,20,65,105,100 + GROUPBOX "Amiga Mouse Port 0",IDC_PORT0,7,92,116,100 CONTROL "PC Joystick 0",IDC_PORT0_JOY0,"Button", - BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,30,75,90,10 + BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,20,102,90,10 CONTROL "PC Joystick 1",IDC_PORT0_JOY1,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,30,89,90,10 + BS_AUTORADIOBUTTON | WS_TABSTOP,20,116,90,10 CONTROL "PC Mouse",IDC_PORT0_MOUSE,"Button",BS_AUTORADIOBUTTON | - WS_TABSTOP,30,104,90,11 + WS_TABSTOP,20,131,90,11 CONTROL "Keyboard Layout ""A""",IDC_PORT0_KBDA,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,30,120,90,10 + BS_AUTORADIOBUTTON | WS_TABSTOP,20,147,90,10 CONTROL "Keyboard Layout ""B""",IDC_PORT0_KBDB,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,30,135,90,10 + BS_AUTORADIOBUTTON | WS_TABSTOP,20,162,90,10 CONTROL "Keyboard Layout ""C""",IDC_PORT0_KBDC,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,30,150,90,10 - GROUPBOX "Amiga Mouse Port 1",IDC_PORT1,175,65,105,100 + BS_AUTORADIOBUTTON | WS_TABSTOP,20,177,90,10 + GROUPBOX "Amiga Mouse Port 1",IDC_PORT1,175,92,115,100 CONTROL "PC Joystick 0",IDC_PORT1_JOY0,"Button", - BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,185,75,90,10 + BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,190,102,90,10 CONTROL "PC Joystick 1",IDC_PORT1_JOY1,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,185,89,90,10 + BS_AUTORADIOBUTTON | WS_TABSTOP,190,116,90,10 CONTROL "PC Mouse",IDC_PORT1_MOUSE,"Button",BS_AUTORADIOBUTTON | - WS_TABSTOP,185,104,90,11 + WS_TABSTOP,190,131,90,11 CONTROL "Keyboard Layout ""A""",IDC_PORT1_KBDA,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,185,120,90,10 + BS_AUTORADIOBUTTON | WS_TABSTOP,190,147,90,10 CONTROL "Keyboard Layout ""B""",IDC_PORT1_KBDB,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,185,135,90,10 + BS_AUTORADIOBUTTON | WS_TABSTOP,190,162,90,10 CONTROL "Keyboard Layout ""C""",IDC_PORT1_KBDC,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,185,150,90,10 - PUSHBUTTON "<-swap->",IDC_SWAP,130,105,40,14 + BS_AUTORADIOBUTTON | WS_TABSTOP,190,177,90,10 + PUSHBUTTON "<-swap->",IDC_SWAP,130,132,40,14 + GROUPBOX "MIDI",IDC_MIDIFRAME,7,51,284,36 + GROUPBOX "Serial and Parallel",IDC_SERPARFRAME,7,3,284,45 END -IDD_CONTRIBUTORS DIALOG 0, 0, 300, 175 +IDD_CONTRIBUTORS DIALOGEX 0, 0, 411, 242 STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION CAPTION "UAE Authors and Contributors..." -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - DEFPUSHBUTTON "OK",ID_OK,135,155,29,14 + DEFPUSHBUTTON "Ok",ID_OK,177,219,53,14 CONTROL "",IDC_CONTRIBUTORS,"RICHEDIT",TCS_HOTTRACK | TCS_VERTICAL | TCS_RAGGEDRIGHT | TCS_OWNERDRAWFIXED | TCS_MULTISELECT | WS_BORDER | WS_VSCROLL | WS_HSCROLL | - WS_TABSTOP,5,5,290,145 + WS_TABSTOP,4,5,404,206 END IDD_ABOUT DIALOGEX 0, 0, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_BORDER +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN CONTROL "",IDC_RICHEDIT1,"RICHEDIT",TCS_SCROLLOPPOSITE | @@ -460,42 +472,55 @@ BEGIN 110,15 END -IDD_MISC1 DIALOGEX 0, 0, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_CAPTION +IDD_MISC1 DIALOGEX 0, 0, 300, 223 +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - GROUPBOX "Advanced:",IDC_STATIC,20,4,260,73 + GROUPBOX "Advanced:",IDC_STATIC,8,4,285,90 CONTROL "Middle-Mouse-Button --> ALT-TAB",IDC_JULIAN,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,26,15,120,10 + BS_AUTOCHECKBOX | WS_TABSTOP,29,15,120,10 CONTROL "Show GUI on startup",IDC_SHOWGUI,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,26,30,120,10 + BS_AUTOCHECKBOX | WS_TABSTOP,29,30,120,10 CONTROL "On-Screen LEDs",IDC_SHOWLEDS,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,26,45,115,10 + WS_TABSTOP,29,45,115,10 CONTROL "UAEscsi.device",IDC_SCSIDEVICE,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,26,60,66,10 + WS_TABSTOP,29,60,117,10 CONTROL "BSDsocket.library emulation",IDC_SOCKETS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,156,15,120,10 + BS_AUTOCHECKBOX | WS_TABSTOP,159,15,120,10 CONTROL "Use CTRL-F11 to quit",IDC_CTRLF11,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,156,30,120,10 + BS_AUTOCHECKBOX | WS_TABSTOP,159,30,120,10 CONTROL "Don't use RGB overlays",IDC_NOOVERLAY,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,156,45,120,10 + BS_AUTOCHECKBOX | WS_TABSTOP,159,45,120,10 CONTROL "Use ASPI SCSI layer",IDC_ASPI,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,156,60,115,10 - GROUPBOX "Keyboard LEDs:",IDC_STATIC,20,82,68,73 - COMBOBOX IDC_KBLED1,26,95,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP,159,60,115,10 + GROUPBOX "Keyboard LEDs:",IDC_STATIC,7,99,85,73 + COMBOBOX IDC_KBLED1,22,112,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_KBLED2,26,114,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | + COMBOBOX IDC_KBLED2,22,131,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_KBLED3,26,134,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | + COMBOBOX IDC_KBLED3,22,151,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Logging:",IDC_STATIC,97,82,183,25 + GROUPBOX "Logging:",IDC_STATIC,97,99,195,25 CONTROL "Create log file",IDC_CREATELOGFILE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,107,92,72,10,0, + BS_AUTOCHECKBOX | WS_TABSTOP,107,109,72,10,0, HIDC_CREATELOGFILE CONTROL "Illegal mem accesses",IDC_ILLEGAL,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,189,92,80,10 - PUSHBUTTON "Reset Amiga",IDC_RESETAMIGA,129,127,49,14 - PUSHBUTTON "Quit",IDC_QUITEMU,199,126,49,14 + BS_AUTOCHECKBOX | WS_TABSTOP,189,109,80,10 + GROUPBOX "State files:",IDC_STATIC,98,126,195,83 + PUSHBUTTON "Load state...",IDC_DOLOADSTATE,105,145,49,14 + PUSHBUTTON "Save state...",IDC_DOSAVESTATE,106,171,49,14 + CONTROL "Enable state recording",IDC_STATE_CAPTURE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,188,144,88,10 + RTEXT "Recording rate (seconds)",IDC_STATE_RATE_TEXT,157,162, + 86,10,SS_CENTERIMAGE | WS_TABSTOP + COMBOBOX IDC_STATE_RATE,248,160,38,65,CBS_DROPDOWN | WS_VSCROLL | + WS_TABSTOP + RTEXT "Recording buffer (MB)",IDC_STATE_BUFFERSIZE_TEXT,157, + 182,83,10,SS_CENTERIMAGE | WS_TABSTOP + COMBOBOX IDC_STATE_BUFFERSIZE,248,180,38,65,CBS_DROPDOWN | + WS_VSCROLL | WS_TABSTOP + CONTROL "Disable UAEFSDB-support",IDC_NOUAEFSDB,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,29,76,115,10 END IDD_HARDFILE DIALOGEX 0, 0, 229, 164 @@ -504,33 +529,33 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | CAPTION "Volume Settings" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN + GROUPBOX "Hard File Settings",IDC_STATIC,10,5,210,90 RTEXT "Path:",IDC_HARDFILE_DIR_TEXT,19,21,22,10 EDITTEXT IDC_PATH_NAME,44,15,151,15,ES_AUTOHSCROLL PUSHBUTTON "...",IDC_SELECTOR,200,15,11,15 - RTEXT "Sectors:",IDC_SECTORS_TEXT,80,80,30,10 - EDITTEXT IDC_SECTORS,115,75,27,15,ES_NUMBER + RTEXT "FileSys:",IDC_HARDFILE_FILESYS_TEXT,16,36,26,10 + EDITTEXT IDC_PATH_FILESYS,44,34,89,15,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_FILESYS_SELECTOR,139,34,11,15 + CONTROL "Read/Write",IDC_RW,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,160,37,50,10 + RTEXT "Device:",IDC_HARDFILE_DEVICE_TEXT,16,58,25,10 + EDITTEXT IDC_HARDFILE_DEVICE,44,54,32,15,ES_AUTOHSCROLL RTEXT "Surfaces:",IDC_SURFACES_TEXT,75,58,35,10 EDITTEXT IDC_HEADS,115,54,27,15,ES_NUMBER RTEXT "Reserved:",IDC_RESERVED_TEXT,145,58,35,10 EDITTEXT IDC_RESERVED,185,54,27,15,ES_NUMBER - CONTROL "Read/Write",IDC_RW,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,160,37,50,10 - PUSHBUTTON "OK",IDOK,115,143,50,14 - PUSHBUTTON "Cancel",IDCANCEL,171,143,50,14 - PUSHBUTTON "Create",IDC_CREATEHF,20,115,85,14 + RTEXT "BootPri:",IDC_HARDFILE_BOOTPRI_TEXT,11,80,30,8 + EDITTEXT IDC_HARDFILE_BOOTPRI,44,75,32,15 + RTEXT "Sectors:",IDC_SECTORS_TEXT,80,80,30,10 + EDITTEXT IDC_SECTORS,115,75,27,15,ES_NUMBER + RTEXT "Block-Size:",IDC_BLOCKSIZE_TEXT,145,80,35,10 + EDITTEXT IDC_BLOCKSIZE,185,75,27,15,ES_NUMBER GROUPBOX "New Hard File",IDC_STATIC,10,100,210,35 + PUSHBUTTON "Create",IDC_CREATEHF,20,115,85,14 EDITTEXT IDC_HFSIZE,110,115,60,15,ES_NUMBER LTEXT "MB",IDC_RESERVED_TEXT2,174,118,39,9,NOT WS_GROUP - GROUPBOX "Hard File Settings",IDC_STATIC,10,5,210,90 - RTEXT "Block-Size:",IDC_BLOCKSIZE_TEXT,145,80,35,10 - EDITTEXT IDC_BLOCKSIZE,185,75,27,15,ES_NUMBER - RTEXT "BootPri:",IDC_HARDFILE_BOOTPRI_TEXT,11,80,30,8 - EDITTEXT IDC_HARDFILE_BOOTPRI,44,75,32,15 - RTEXT "Device:",IDC_HARDFILE_DEVICE_TEXT,16,58,25,10 - EDITTEXT IDC_HARDFILE_DEVICE,44,54,32,15,ES_AUTOHSCROLL - RTEXT "FileSys:",IDC_HARDFILE_FILESYS_TEXT,16,36,26,10 - EDITTEXT IDC_PATH_FILESYS,44,34,89,15,ES_AUTOHSCROLL - PUSHBUTTON "...",IDC_FILESYS_SELECTOR,139,34,11,15 + PUSHBUTTON "OK",IDOK,115,143,50,14 + PUSHBUTTON "Cancel",IDCANCEL,171,143,50,14 END IDD_FILESYS DIALOGEX 15, 25, 229, 111 @@ -554,11 +579,11 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,175,91,48,15 END -IDD_SETINFO DIALOG 0, 0, 229, 85 +IDD_SETINFO DIALOGEX 0, 0, 229, 85 STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Info Settings" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN RTEXT "Path:",-1,5,20,24,15,SS_CENTERIMAGE EDITTEXT IDC_PATH_NAME,35,20,169,15,ES_AUTOHSCROLL @@ -567,89 +592,86 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,175,65,48,15 END -IDD_CHIPSET DIALOG 0, 65490, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_CAPTION -FONT 8, "MS Sans Serif" +IDD_CHIPSET DIALOGEX 0, 65490, 300, 229 +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - GROUPBOX "Chipset type",-1,22,11,142,82 + GROUPBOX "Chipset type",IDC_STATIC,14,11,145,82 CONTROL "OCS",IDC_OCS,"Button",BS_AUTORADIOBUTTON | WS_GROUP | - WS_TABSTOP,41,31,30,10 + WS_TABSTOP,38,31,30,10 CONTROL "ECS Agnus",IDC_ECS_AGNUS,"Button",BS_AUTORADIOBUTTON | - WS_TABSTOP,41,47,50,10 + WS_TABSTOP,38,47,50,10 CONTROL "ECS Denise",IDC_ECS_DENISE,"Button",BS_AUTORADIOBUTTON | - WS_TABSTOP,41,63,50,10 + WS_TABSTOP,38,63,50,10 CONTROL "Full ECS",IDC_ECS,"Button",BS_AUTORADIOBUTTON | - WS_TABSTOP,105,31,42,10 + WS_TABSTOP,102,31,42,10 CONTROL "AGA",IDC_AGA,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP, - 105,47,30,10 + 102,47,30,10 CONTROL "NTSC",IDC_NTSC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - 105,64,35,10 - GROUPBOX "Misc chipset options",-1,171,11,111,82 + 102,64,35,10 + GROUPBOX "Misc chipset options",IDC_STATIC,168,11,114,82 CONTROL "Fast Copper",IDC_FASTCOPPER,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,178,31,53,10 + WS_TABSTOP,174,31,53,10 CONTROL "Immediate Blitter",IDC_BLITIMM,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,178,47,75,10 + WS_TABSTOP,174,47,75,10 CONTROL "Cycle exact CPU and Blitter",IDC_CYCLEEXACT,"Button", - BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,178,64, + BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,174,64, 100,10 - GROUPBOX "Collision level",-1,22,95,261,48 + GROUPBOX "Collision level",IDC_STATIC,14,97,267,48 CONTROL "None",IDC_COLLISION0,"Button",BS_AUTORADIOBUTTON | - WS_GROUP | WS_TABSTOP,40,111,50,10 + WS_GROUP | WS_TABSTOP,40,113,50,10 CONTROL "Sprites only",IDC_COLLISION1,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,40,127,50,10 + BS_AUTORADIOBUTTON | WS_TABSTOP,39,129,50,10 CONTROL "Sprites and Sprites vs. Playfield",IDC_COLLISION2, - "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,104,111,114,10 + "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,104,113,114,10 CONTROL "Full",IDC_COLLISION3,"Button",BS_AUTORADIOBUTTON | - WS_TABSTOP,104,127,27,10 + WS_TABSTOP,104,129,27,10 + GROUPBOX "Sound emulation",IDC_STATIC,13,150,268,65 + CONTROL "Disabled",IDC_CS_SOUND0,"Button",BS_AUTORADIOBUTTON | + WS_GROUP | WS_TABSTOP,39,167,102,10 + CONTROL "Emulated",IDC_CS_SOUND1,"Button",BS_AUTORADIOBUTTON | + WS_TABSTOP,39,182,91,10 + CONTROL "Emulated, 100% accurate",IDC_CS_SOUND2,"Button", + BS_AUTORADIOBUTTON | WS_TABSTOP,39,197,95,10 END -IDD_AVIOUTPUT DIALOGEX 0, 0, 300, 167 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +IDD_AVIOUTPUT DIALOGEX 0, 0, 197, 210 +STYLE DS_SETFONT | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - GROUPBOX "Output Properties:",IDC_STATIC,5,8,152,91 - EDITTEXT IDC_AVIOUTPUT_FILETEXT,10,18,120,12,ES_AUTOHSCROLL | + GROUPBOX "Output Properties:",IDC_STATIC,5,8,184,96 + EDITTEXT IDC_AVIOUTPUT_FILETEXT,26,21,120,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER,WS_EX_CLIENTEDGE - PUSHBUTTON "...",IDC_AVIOUTPUT_FILE,132,18,19,12 + PUSHBUTTON "...",IDC_AVIOUTPUT_FILE,148,21,19,12 CONTROL "Audio",IDC_AVIOUTPUT_AUDIO,"Button",BS_AUTOCHECKBOX | - BS_PUSHLIKE | BS_FLAT | WS_TABSTOP,10,33,32,11 + BS_PUSHLIKE | BS_FLAT | WS_TABSTOP,26,36,32,11 CONTROL "",IDC_AVIOUTPUT_AUDIO_STATIC,"Static",SS_LEFTNOWORDWRAP | - SS_CENTERIMAGE | SS_SUNKEN | WS_GROUP,44,33,107,11 + SS_CENTERIMAGE | SS_SUNKEN | WS_GROUP,60,36,107,11 CONTROL "Video",IDC_AVIOUTPUT_VIDEO,"Button",BS_AUTOCHECKBOX | - BS_PUSHLIKE | BS_FLAT | WS_TABSTOP,10,47,32,11 + BS_PUSHLIKE | BS_FLAT | WS_TABSTOP,26,50,32,11 CONTROL "",IDC_AVIOUTPUT_VIDEO_STATIC,"Static",SS_LEFTNOWORDWRAP | - SS_CENTERIMAGE | SS_SUNKEN | WS_GROUP,44,47,107,11 + SS_CENTERIMAGE | SS_SUNKEN | WS_GROUP,60,50,107,11 CONTROL "Disable frame rate limit while recording", IDC_AVIOUTPUT_FRAMELIMITER,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,12,65,142,10 + WS_TABSTOP,28,68,142,10 CONTROL "AVIOutput enabled",IDC_AVIOUTPUT_ACTIVATED,"Button", - BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,10,80,142,12 - GROUPBOX "Playback Rate:",IDC_STATIC,5,100,152,33 + BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_FLAT,26,83,142,14 + GROUPBOX "Playback Rate:",IDC_STATIC,5,107,184,50 CONTROL "PAL",IDC_AVIOUTPUT_PAL,"Button",BS_AUTORADIOBUTTON | - BS_PUSHLIKE | BS_FLAT,10,110,66,8 + BS_PUSHLIKE | BS_FLAT,24,121,66,12 CONTROL "NTSC",IDC_AVIOUTPUT_NTSC,"Button",BS_AUTORADIOBUTTON | - BS_PUSHLIKE | BS_FLAT,81,110,66,8 + BS_PUSHLIKE | BS_FLAT,102,121,66,12 CONTROL "Slider1",IDC_AVIOUTPUT_FPS,"msctls_trackbar32",TBS_BOTH | - TBS_NOTICKS | TBS_ENABLESELRANGE | WS_TABSTOP,7,120,120, + TBS_NOTICKS | TBS_ENABLESELRANGE | WS_TABSTOP,21,137,120, 11 - LTEXT "fps",IDC_AVIOUTPUT_FPS_STATIC,127,120,23,8 - GROUPBOX "Frame / Video Dimensions:",IDC_STATIC,161,8,133,143,NOT - WS_VISIBLE - LTEXT "Width:",IDC_STATIC,169,24,22,8,NOT WS_VISIBLE - EDITTEXT IDC_AVIOUTPUT_WIDTH,193,22,30,12,ES_NUMBER | NOT - WS_VISIBLE - LTEXT "Height:",IDC_STATIC,230,24,25,8,NOT WS_VISIBLE - EDITTEXT IDC_AVIOUTPUT_HEIGHT,256,22,30,12,ES_NUMBER | NOT - WS_VISIBLE - CTEXT "Actual:",IDC_AVIOUTPUT_DIMENSIONS_STATIC,170,38,116,9, - NOT WS_VISIBLE - CONTROL "",IDC_AVIOUTPUT_FRAME,"Static",SS_BLACKFRAME | NOT - WS_VISIBLE,170,50,116,80 - PUSHBUTTON "Save Screenshot",IDC_SCREENSHOT,25,143,95,12 + LTEXT "fps",IDC_AVIOUTPUT_FPS_STATIC,148,138,23,8 + PUSHBUTTON "Save Screenshot",IDC_SCREENSHOT,15,176,95,14 + GROUPBOX "Ripper",IDC_STATIC,5,160,184,41 + PUSHBUTTON "Pro Wizard",IDC_PROWIZARD,127,176,49,14,WS_DISABLED END -IDD_INPUT DIALOGEX 0, 0, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_CAPTION +IDD_INPUT DIALOGEX 0, 0, 300, 242 +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN COMBOBOX IDC_INPUTTYPE,5,5,98,150,CBS_DROPDOWNLIST | @@ -660,73 +682,71 @@ BEGIN WS_TABSTOP,282,7,9,8 CONTROL "List1",IDC_INPUTLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | - LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,22,290,81 - COMBOBOX IDC_INPUTAMIGACNT,5,109,24,150,CBS_DROPDOWNLIST | + LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,22,290,146 + COMBOBOX IDC_INPUTAMIGACNT,5,174,24,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_INPUTAMIGA,33,109,219,150,CBS_DROPDOWNLIST | + COMBOBOX IDC_INPUTAMIGA,33,174,262,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP - CONTROL "Autofire",IDC_INPUTAUTOFIRE,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,257,111,37,10 - RTEXT "Joystick dead zone (%):",-1,8,128,76,10,SS_CENTERIMAGE - EDITTEXT IDC_INPUTDEADZONE,89,127,25,12,ES_NUMBER - RTEXT "Autofire rate (frames):",-1,9,144,68,10,SS_CENTERIMAGE - EDITTEXT IDC_INPUTAUTOFIRERATE,89,142,25,12,ES_NUMBER - RTEXT "Digital joy-mouse speed:",-1,121,128,76,10, + RTEXT "Joystick dead zone (%):",-1,8,196,76,10,SS_CENTERIMAGE + EDITTEXT IDC_INPUTDEADZONE,89,195,25,12,ES_NUMBER + RTEXT "Autofire rate (frames):",-1,9,212,68,10,SS_CENTERIMAGE + EDITTEXT IDC_INPUTAUTOFIRERATE,89,210,25,12,ES_NUMBER + RTEXT "Digital joy-mouse speed:",-1,121,196,76,10, SS_CENTERIMAGE - EDITTEXT IDC_INPUTSPEEDD,207,127,25,12,ES_NUMBER - RTEXT "Analog joy-mouse speed:",-1,120,144,80,10, + EDITTEXT IDC_INPUTSPEEDD,207,195,25,12,ES_NUMBER + RTEXT "Analog joy-mouse speed:",-1,120,212,80,10, SS_CENTERIMAGE - EDITTEXT IDC_INPUTSPEEDA,207,143,25,12,ES_NUMBER - RTEXT "Mouse speed:",-1,132,160,68,10,SS_CENTERIMAGE - EDITTEXT IDC_INPUTSPEEDM,207,159,25,12,ES_NUMBER - PUSHBUTTON "Copy from:",IDC_INPUTCOPY,249,127,45,14 - COMBOBOX IDC_INPUTCOPYFROM,249,143,45,150,CBS_DROPDOWNLIST | + EDITTEXT IDC_INPUTSPEEDA,207,211,25,12,ES_NUMBER + RTEXT "Mouse speed:",-1,132,228,68,10,SS_CENTERIMAGE + EDITTEXT IDC_INPUTSPEEDM,207,227,25,12,ES_NUMBER + PUSHBUTTON "Copy from:",IDC_INPUTCOPY,249,195,45,14 + COMBOBOX IDC_INPUTCOPYFROM,249,211,45,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Swap 1<>2",IDC_INPUTSWAP,249,158,45,14 + PUSHBUTTON "Swap 1<>2",IDC_INPUTSWAP,249,226,45,14 END -IDD_OPENGL DIALOGEX 0, 0, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_CAPTION +IDD_OPENGL DIALOGEX 0, 0, 300, 193 +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - GROUPBOX "Filter settings:",-1,19,12,260,151 + GROUPBOX "Filter settings:",-1,8,5,285,180 CONTROL "Enable",IDC_OPENGLENABLE,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,26,27,38,10 - COMBOBOX IDC_OPENGLMODE,67,25,56,150,CBS_DROPDOWNLIST | + WS_TABSTOP,26,23,38,10 + COMBOBOX IDC_OPENGLMODE,67,21,56,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_OPENGLFILTER,128,25,65,150,CBS_DROPDOWNLIST | + COMBOBOX IDC_OPENGLFILTER,128,21,65,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Reset to defaults",IDC_OPENGLDEFAULT,197,25,73,14 - RTEXT "Horizontal Size",-1,25,49,57,10,SS_CENTERIMAGE + PUSHBUTTON "Reset to defaults",IDC_OPENGLDEFAULT,197,21,73,14 + RTEXT "Horizontal Size",-1,25,52,57,10,SS_CENTERIMAGE CONTROL "Slider1",IDC_OPENGLHZ,"msctls_trackbar32",TBS_AUTOTICKS | - TBS_TOP | WS_TABSTOP,89,42,158,19 - CTEXT "",IDC_OPENGLHZV,249,44,21,16,SS_CENTERIMAGE | SS_SUNKEN | + TBS_TOP | WS_TABSTOP,89,45,158,19 + CTEXT "",IDC_OPENGLHZV,249,47,21,16,SS_CENTERIMAGE | SS_SUNKEN | WS_BORDER | WS_TABSTOP - RTEXT "Vertical Size",-1,26,69,57,10,SS_CENTERIMAGE + RTEXT "Vertical Size",-1,26,72,57,10,SS_CENTERIMAGE CONTROL "Slider1",IDC_OPENGLVZ,"msctls_trackbar32",TBS_AUTOTICKS | - TBS_TOP | WS_TABSTOP,89,62,157,19 - CTEXT "",IDC_OPENGLVZV,249,64,21,16,SS_CENTERIMAGE | SS_SUNKEN | + TBS_TOP | WS_TABSTOP,89,65,157,19 + CTEXT "",IDC_OPENGLVZV,249,67,21,16,SS_CENTERIMAGE | SS_SUNKEN | WS_BORDER | WS_TABSTOP - RTEXT "Horizontal Position",-1,26,89,57,10,SS_CENTERIMAGE + RTEXT "Horizontal Position",-1,26,92,57,10,SS_CENTERIMAGE CONTROL "Slider1",IDC_OPENGLHO,"msctls_trackbar32",TBS_AUTOTICKS | - TBS_TOP | WS_TABSTOP,89,82,157,19 - CTEXT "",IDC_OPENGLHOV,249,84,21,16,SS_CENTERIMAGE | SS_SUNKEN | + TBS_TOP | WS_TABSTOP,89,85,157,19 + CTEXT "",IDC_OPENGLHOV,249,87,21,16,SS_CENTERIMAGE | SS_SUNKEN | WS_BORDER | WS_TABSTOP - RTEXT "Vertical Position",-1,26,108,57,10,SS_CENTERIMAGE + RTEXT "Vertical Position",-1,26,111,57,10,SS_CENTERIMAGE CONTROL "Slider1",IDC_OPENGLVO,"msctls_trackbar32",TBS_AUTOTICKS | - TBS_TOP | WS_TABSTOP,89,102,157,19 - CTEXT "",IDC_OPENGLVOV,249,104,21,16,SS_CENTERIMAGE | + TBS_TOP | WS_TABSTOP,89,105,157,19 + CTEXT "",IDC_OPENGLVOV,249,107,21,16,SS_CENTERIMAGE | SS_SUNKEN | WS_BORDER | WS_TABSTOP - RTEXT "Scanlines",-1,27,130,57,10,SS_CENTERIMAGE + RTEXT "Scanlines",-1,27,141,57,10,SS_CENTERIMAGE CONTROL "Slider1",IDC_OPENGLSL,"msctls_trackbar32",TBS_AUTOTICKS | - TBS_TOP | WS_TABSTOP,89,123,157,19 - CTEXT "",IDC_OPENGLSLV,249,124,21,16,SS_CENTERIMAGE | + TBS_TOP | WS_TABSTOP,89,134,157,19 + CTEXT "",IDC_OPENGLSLV,249,135,21,16,SS_CENTERIMAGE | SS_SUNKEN | WS_BORDER | WS_TABSTOP - COMBOBOX IDC_OPENGLSLR,56,143,27,150,CBS_DROPDOWNLIST | + COMBOBOX IDC_OPENGLSLR,56,154,27,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP CONTROL "Slider1",IDC_OPENGLSL2,"msctls_trackbar32", - TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,89,143,157,19 - CTEXT "",IDC_OPENGLSL2V,249,143,21,16,SS_CENTERIMAGE | + TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,89,154,157,19 + CTEXT "",IDC_OPENGLSL2V,249,154,21,16,SS_CENTERIMAGE | SS_SUNKEN | WS_BORDER | WS_TABSTOP END @@ -745,8 +765,8 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,172,47,50,14 END -IDD_MISC2 DIALOGEX 0, 0, 300, 175 -STYLE DS_SETFONT | DS_3DLOOK | WS_CHILD | WS_VISIBLE | WS_CAPTION +IDD_MISC2 DIALOGEX 0, 0, 300, 92 +STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN GROUPBOX "When Active:",IDC_STATIC,8,7,88,73 @@ -772,104 +792,39 @@ BEGIN BS_AUTOCHECKBOX | WS_TABSTOP,207,50,69,10 CONTROL "Disable sound output",IDC_MINIMIZED_NOSOUND,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,207,63,79,10 - GROUPBOX "State files:",IDC_STATIC,10,92,281,63 - PUSHBUTTON "Load state...",IDC_DOLOADSTATE,21,108,49,14 - PUSHBUTTON "Save state...",IDC_DOSAVESTATE,21,132,49,14 - CONTROL "Enable state recording",IDC_STATE_CAPTURE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,160,103,88,10 - RTEXT "Recording rate (seconds)",IDC_STATE_RATE_TEXT,153,118, - 86,10,SS_CENTERIMAGE | WS_TABSTOP - COMBOBOX IDC_STATE_RATE,244,116,38,65,CBS_DROPDOWN | WS_VSCROLL | - WS_TABSTOP - RTEXT "Recording buffer (MB)",IDC_STATE_BUFFERSIZE_TEXT,153, - 138,83,10,SS_CENTERIMAGE | WS_TABSTOP - COMBOBOX IDC_STATE_BUFFERSIZE,244,136,38,65,CBS_DROPDOWN | - WS_VSCROLL | WS_TABSTOP END - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO +IDD_DISK DIALOGEX 0, 0, 300, 242 +STYLE DS_SETFONT | DS_SETFOREGROUND | DS_3DLOOK | DS_CONTROL | DS_CENTER | + DS_CENTERMOUSE | WS_CHILD +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - IDD_KICKSTART, DIALOG - BEGIN - BOTTOMMARGIN, 174 - END - - IDD_SOUND, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 293 - TOPMARGIN, 7 - BOTTOMMARGIN, 168 - END - - IDD_LOADSAVE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 293 - TOPMARGIN, 7 - BOTTOMMARGIN, 168 - END - - IDD_PORTS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 293 - TOPMARGIN, 7 - BOTTOMMARGIN, 168 - END - - IDD_CONTRIBUTORS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 293 - TOPMARGIN, 7 - BOTTOMMARGIN, 168 - END - - IDD_ABOUT, DIALOG - BEGIN - RIGHTMARGIN, 299 - BOTTOMMARGIN, 174 - END - - IDD_MISC1, DIALOG - BEGIN - BOTTOMMARGIN, 174 - HORZGUIDE, 91 - END - - IDD_HARDFILE, DIALOG - BEGIN - BOTTOMMARGIN, 146 - END - - IDD_FILESYS, DIALOG - BEGIN - BOTTOMMARGIN, 85 - END - - IDD_OPENGL, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 293 - TOPMARGIN, 7 - BOTTOMMARGIN, 168 - END + CONTROL "",IDC_DISKLIST,"SysListView32",LVS_REPORT | + LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | + LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,4,6,262,211 + PUSHBUTTON "Remove disk image",IDC_DISKLISTREMOVE,94,222,93,15 + PUSHBUTTON "",IDC_UP,270,66,25,15,BS_ICON + PUSHBUTTON "",IDC_DOWN,270,146,25,15,BS_ICON +END - IDD_MISC2, DIALOG - BEGIN - BOTTOMMARGIN, 173 - HORZGUIDE, 91 - END +IDD_PANEL DIALOGEX 0, 0, 420, 278 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | + WS_SYSMENU +EXSTYLE WS_EX_ACCEPTFILES | WS_EX_CONTROLPARENT +CAPTION "WinUAE Properties" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "",IDC_PANELTREE,"SysTreeView32",TVS_HASLINES | + TVS_SHOWSELALWAYS | TVS_NOSCROLL | WS_BORDER | + WS_TABSTOP,5,5,101,248,WS_EX_CLIENTEDGE + GROUPBOX "",IDC_PANEL_FRAME_OUTER,110,2,307,251 + DEFPUSHBUTTON "OK",IDOK,260,259,50,14 + PUSHBUTTON "Cancel",IDCANCEL,313,259,50,14 + PUSHBUTTON "Help",IDHELP,366,259,50,14,WS_DISABLED + PUSHBUTTON "Reset",IDC_RESETAMIGA,6,259,47,14 + PUSHBUTTON "Quit",IDC_QUITEMU,57,259,47,14 + GROUPBOX "",IDC_PANEL_FRAME,112,4,303,247,NOT WS_VISIBLE END -#endif // APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED @@ -909,21 +864,22 @@ END IDI_APPICON ICON "winuae.ico" IDI_FLOPPY ICON "35floppy.ico" IDI_ABOUT ICON "amigainfo.ico" -IDI_CDROM ICON "Cddrive.ico" IDI_HARDDISK ICON "Drive.ico" -IDI_SOUND ICON "Volume01.ico" -IDI_DISPLAY ICON "Monitr01.ico" -IDI_OPENGL ICON "Monitr01.ico" IDI_CPU ICON "cpu.ico" -IDI_LOADSAVE ICON "35floppy.ico" IDI_PORTS ICON "joystick.ico" IDI_INPUT ICON "joystick.ico" -IDI_MEMORY ICON "Mycomp.ico" IDI_MISC1 ICON "misc.ico" IDI_MISC2 ICON "misc.ico" IDI_MOVE_UP ICON "move_up.ico" IDI_MOVE_DOWN ICON "move_dow.ico" IDI_AVIOUTPUT ICON "avioutput.ico" +IDI_DISK ICON "Drive.ico" +IDI_CONFIGFILE ICON "file.ico" +IDI_FOLDER ICON "folder.ico" +IDI_SOUND ICON "sound.ico" +IDI_DISPLAY ICON "screen.ico" +IDI_ROOT ICON "root.ico" +IDI_MEMORY ICON "chip.ico" ///////////////////////////////////////////////////////////////////////////// // @@ -931,8 +887,8 @@ IDI_AVIOUTPUT ICON "avioutput.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,8,25,0 - PRODUCTVERSION 0,8,25,0 + FILEVERSION 0,8,26,0 + PRODUCTVERSION 0,8,26,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -948,12 +904,12 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "WinUAE" - VALUE "FileVersion", "0.8.25" + VALUE "FileVersion", "0.8.26" VALUE "InternalName", "WinUAE" VALUE "LegalCopyright", "© 1996-2004 under the GNU Public License (GPL)" VALUE "OriginalFilename", "WinUAE.exe" VALUE "ProductName", "WinUAE" - VALUE "ProductVersion", "0.8.25" + VALUE "ProductVersion", "0.8.26" END END BLOCK "VarFileInfo" @@ -970,6 +926,112 @@ END IDC_MYHAND CURSOR "H_arrow.cur" +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_DISPLAY, DIALOG + BEGIN + BOTTOMMARGIN, 175 + END + + IDD_FLOPPY, DIALOG + BEGIN + BOTTOMMARGIN, 175 + END + + IDD_HARDDISK, DIALOG + BEGIN + BOTTOMMARGIN, 175 + END + + IDD_SOUND, DIALOG + BEGIN + BOTTOMMARGIN, 206 + END + + IDD_PORTS, DIALOG + BEGIN + BOTTOMMARGIN, 175 + END + + IDD_CONTRIBUTORS, DIALOG + BEGIN + RIGHTMARGIN, 370 + BOTTOMMARGIN, 212 + END + + IDD_MISC1, DIALOG + BEGIN + BOTTOMMARGIN, 215 + END + + IDD_CHIPSET, DIALOG + BEGIN + BOTTOMMARGIN, 215 + END + + IDD_INPUT, DIALOG + BEGIN + BOTTOMMARGIN, 187 + END + + IDD_OPENGL, DIALOG + BEGIN + BOTTOMMARGIN, 175 + END + + IDD_DISK, DIALOG + BEGIN + BOTTOMMARGIN, 193 + END + + IDD_PANEL, DIALOG + BEGIN + LEFTMARGIN, 7 + TOPMARGIN, 7 + HORZGUIDE, 241 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDM_SYSTRAY MENU +BEGIN + POPUP "Menu" + BEGIN + MENUITEM "Configuration", ID_ST_CONFIGURATION + POPUP "Floppy Drives" + BEGIN + MENUITEM "Eject all drives", ID_ST_EJECTALL + MENUITEM "DF0:", 40014 + MENUITEM "DF1:", ID_ST_DF1 + MENUITEM "DF2:", ID_ST_DF2 + MENUITEM "DF3:", ID_ST_DF3 + END + MENUITEM "Reset", ID_ST_RESET + MENUITEM "Help", ID_ST_HELP + MENUITEM "Quit WinUAE", ID_ST_QUIT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// RT_MANIFEST +// + +1 RT_MANIFEST "winuae.exe.manifest" + ///////////////////////////////////////////////////////////////////////////// // // String Table @@ -978,13 +1040,14 @@ IDC_MYHAND CURSOR "H_arrow.cur" STRINGTABLE BEGIN IDS_KICKSTART "ROM" + IDS_DISK "Disk Swapper" IDS_DISPLAY "Display" IDS_HARDDISK "Hard Drives" - IDS_FLOPPY "Floppies" + IDS_FLOPPY "Disk Drives" IDS_ABOUT "About" IDS_LOADSAVE "Configurations" IDS_AVIOUTPUT "Output" - IDS_PORTS "Game and I/O Ports" + IDS_PORTS "Game & I/O Ports" IDS_MISC1 "Misc" IDS_MEMORY "RAM" IDS_CPU "CPU" @@ -995,7 +1058,7 @@ END STRINGTABLE BEGIN - IDS_MISC2 "Priority and state files" + IDS_MISC2 "Priority" END STRINGTABLE @@ -1039,7 +1102,7 @@ BEGIN IDS_SELECTFILESYSROOT "Please select your file-system root directory..." IDS_DEFAULTMIDIOUT "Default MIDI-Out Device" IDS_CONTRIBUTORS1 "Bernd Schmidt - The Grand-Master\nSam Jordan - Custom-chip, floppy-DMA, etc.\nMathias Ortmann - Original WinUAE Main Guy, BSD Socket support\nBrian King - Picasso96 Support, Integrated GUI for WinUAE, previous WinUAE Main Guy\nToni Wilen - Core updates, WinUAE Main Guy\nGustavo Goedert/Peter Remmers/Michael Sontheimer/Tomi Hakala/Tim Gunn/Nemo Pohle - DOS Port Stuff\nSamuel Devulder/Olaf Barthel/Sam Jordan - Amiga Ports\nKrister Bergman - XFree86 and OS/2 Port\nA. Blanchard/Ernesto Corvi - MacOS Port\nChristian Bauer - BeOS Port\nIan Stephenson - NextStep Port\nPeter Teichmann - Acorn/RiscOS Port\nStefan Reinauer - ZorroII/III AutoConfig, Serial Support\nChristian Schmitt/Chris Hames - Serial Support\nHerman ten Brugge - 68020/68881 Emulation Code\nTauno Taipaleenmaki - Various UAE-Control/UAE-Library Support\nBrett Eden/Tim Gunn/Paolo Besser/Nemo Pohle - Various Docs and Web-Sites\nGeorg Veichtlbauer - Help File coordinator, German GUI\nFulvio Leonardi - Italian translator for WinUAE\n" - IDS_CONTRIBUTORS2 "Special thanks to Alexander Kneer and Tobias Abt (The Picasso96 Team)\n" + IDS_CONTRIBUTORS2 "Bill Panagouleas - Hardware support\nSpecial thanks to Alexander Kneer and Tobias Abt (The Picasso96 Team)\n" IDS_INVALIDPRTPORT "The printer you have in this configuration is not valid on this machine.\n" IDS_RESTOREUSS "Restore a UAE Snap-Shot File" IDS_USS "UAE Snap-Shot Files" @@ -1085,7 +1148,6 @@ BEGIN IDS_WSOCK2NEEDED "Please upgrade to Winsock2.\n" IDS_UNSUPPORTEDPIXELFORMAT "Error: Unsupported pixel format - use a different screen mode\n" - IDS_WAVEOUTOPENFAILURE "Could not open WAVEOUT sound device!\n" IDS_MUSTENTERNAME "You must select a configuration or enter a name before selecting Save...\n" IDS_MUSTSELECTCONFIGFORDELETE "You must select a configuration or enter a name before selecting Delete...\n" @@ -1122,15 +1184,55 @@ BEGIN IDS_INPUT_CUSTOM "Configuration #%d" IDS_INPUT_COPY_DEFAULT "Default" IDS_INPUT_COPY_CUSTOM "Config #%d" - IDS_3D_NO_FILTER "No filter (%d-bit)" + IDS_3D_NO_FILTER "Point (%d-bit)" IDS_3D_BILINEAR "Bilinear (%d-bit)" IDS_VSYNC_DEFAULT "Default" IDS_DRIVESOUND_NONE "No sound" IDS_DRIVESOUND_DEFAULT_A500 "A500 (WinUAE built-in)" IDS_AVIOUTPUT_NOCODEC "no codec selected" + IDS_DISK_IMAGENAME "Disk image" + IDS_DISK_DRIVENAME "Drive" + IDS_AGA8BIT "AGA emulation requires 16 bit or higher display depth\nSwitching from 8-bit to 16-bit" + IDS_UNSUPPORTEDSCREENMODE + "The selected screen mode can't be displayed in a window, because %s\nSwitching to full-screen display." + IDS_UNSUPPORTEDSCREENMODE_1 + "the desktop is running in an unknown color mode." +END + +STRINGTABLE +BEGIN + IDS_UNSUPPORTEDSCREENMODE_2 + "the desktop is running in 8 bit color depth, which UAE can't use in windowed mode." + IDS_UNSUPPORTEDSCREENMODE_3 + "the desktop is too small for the specified window size" + IDS_UNSUPPORTEDSCREENMODE_4 + "you selected a Picasso96 display with a color depth different from that of the desktop and an overlay was unavailable." + IDS_FLOPPYTYPE35DD "3.5"" DD" + IDS_FLOPPYTYPE35HD "3.5"" HD" + IDS_FLOPPYTYPE525SD "5.25"" SD" + IDS_FLOPPYTYPEDISABLED "Disabled" + IDS_STMENUNOFLOPPY "No disk inserted" + IDS_TREEVIEW_HARDWARE "Hardware" + IDS_TREEVIEW_HOST "Host" + IDS_TREEVIEW_MISC "Misc" + IDS_TREEVIEW_SETTINGS "Settings" + IDS_WINUAETITLE_MMB "[Mouse active - press Alt-Tab or middle-button to cancel]" + IDS_WINUAETITLE_NORMAL "[Mouse active - press Alt-Tab to cancel]" END #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/od-win32/screenshot.c b/od-win32/screenshot.c index a12b8790..4df98ea7 100755 --- a/od-win32/screenshot.c +++ b/od-win32/screenshot.c @@ -115,9 +115,9 @@ void screenshot(int mode) if (mode == 0) { toclipboard (&bi, lpvBits); } else { - char filename[MAX_PATH]; + char filename[MAX_DPATH]; char extension[] = "bmp"; - char tmpstr[MAX_PATH]; + char tmpstr[MAX_DPATH]; int number = 0; tmpstr[0] = 0; diff --git a/od-win32/srcrelease.bat b/od-win32/srcrelease.bat index 462f81f4..c0b0e3aa 100755 --- a/od-win32/srcrelease.bat +++ b/od-win32/srcrelease.bat @@ -82,6 +82,8 @@ cd .. zip -9 -r winuaesrc * +copy winuaesrc.zip d:\amiga\winuaepackets\winuaesrc%1.zip move winuaesrc.zip d:\amiga cd c:\projects\winuae\src\od-win32 - +zip -9 winuaedebug%1 winuae_msvc\release\winuae.pdb +move winuaedebug%1.zip d:\amiga\winuaepackets\ diff --git a/od-win32/sysconfig.h b/od-win32/sysconfig.h index fabbbbeb..49f1fea5 100755 --- a/od-win32/sysconfig.h +++ b/od-win32/sysconfig.h @@ -4,9 +4,11 @@ #define DIRECTINPUT_VERSION 0x0800 #define DIRECT3D_VERSION 0x0900 #define SUPPORT_THREADS +#define MAX_DPATH 1000 #define DRIVESOUND #define GFXFILTER +#define DEBUGGER #ifndef UAE_MINI @@ -39,7 +41,9 @@ #define PICASSO96 /* Picasso96 display card emulation */ #define BSDSOCKET /* bsdsocket.library emulation */ #define CAPS /* CAPS-image support */ +#define FDI2RAW /* FDI 1.0 and 2.0 image support */ #define AVIOUTPUT /* Avioutput support */ +#define PROWIZARD /* Pro-Wizard module ripper */ #else @@ -48,6 +52,7 @@ #define CUSTOM_SIMPLE /* simplified custom chipset emulation */ #define CPUEMU_0 #define CPUEMU_68000_ONLY /* drop 68010+ commands from CPUEMU_0 */ +#define ADDRESS_SPACE_24BIT #ifndef UAE_NOGUI #define D3D #define OPENGL diff --git a/od-win32/win32.c b/od-win32/win32.c index cd9d7950..be0215ad 100755 --- a/od-win32/win32.c +++ b/od-win32/win32.c @@ -106,7 +106,7 @@ static int timermode, timeon; static HANDLE timehandle; char *start_path; -char help_file[ MAX_PATH ]; +char help_file[ MAX_DPATH ]; extern int harddrive_dangerous, do_rdbdump, aspi_allow_all, dsound_hardware_mixing, no_rawinput; int log_scsi; @@ -411,12 +411,9 @@ static int avioutput_video = 0; void setpriority (int pri) { - static int priwarn; + if (pri >= 2) + pri = 1; SetThreadPriority ( GetCurrentThread(), pri); - if (pri == 2 && priwarn == 0) { - priwarn = 1; - gui_message("Priority = 2!"); - } write_log ("priority set to %d\n", pri); } @@ -1059,21 +1056,11 @@ int WIN32_InitHtmlHelp( void ) return result; } -#if 0 -#define TESTING_LANGUAGES -#define TEST_LANGID LANG_GERMAN -//#define TEST_LANGID LANG_FRENCH -//#define TEST_LANGID LANG_TURKISH -#endif - static HMODULE LoadGUI( void ) { HMODULE result = NULL; LPCTSTR dllname = NULL; LANGID language = GetUserDefaultLangID() & 0x3FF; // low 9-bits form the primary-language ID -#ifdef TESTING_LANGUAGES - language = TEST_LANGID; -#endif switch( language ) { @@ -1285,12 +1272,12 @@ static HMODULE LoadGUI( void ) if( dllname ) { - TCHAR szFilename[ MAX_PATH ]; + TCHAR szFilename[ MAX_DPATH ]; DWORD dwVersionHandle, dwFileVersionInfoSize; LPVOID lpFileVersionData = NULL; BOOL success = FALSE; result = LoadLibrary( dllname ); - if( result && GetModuleFileName( result, (LPTSTR)&szFilename, MAX_PATH ) ) + if( result && GetModuleFileName( result, (LPTSTR)&szFilename, MAX_DPATH ) ) { dwFileVersionInfoSize = GetFileVersionInfoSize( szFilename, &dwVersionHandle ); if( dwFileVersionInfoSize ) @@ -1304,18 +1291,17 @@ static HMODULE LoadGUI( void ) if( VerQueryValue( lpFileVersionData, TEXT("\\"), (void **)&vsFileInfo, &uLen ) ) { if( vsFileInfo && - ( HIWORD(vsFileInfo->dwProductVersionMS) == UAEMAJOR ) - && ( LOWORD(vsFileInfo->dwProductVersionMS) == UAEMINOR ) - && ( HIWORD(vsFileInfo->dwProductVersionLS) == UAESUBREV ) -// Change this to an #if 1 when the WinUAE Release version (as opposed to UAE-core version) -// requires a GUI-DLL change... -#if 0 - && ( LOWORD(vsFileInfo->dwProductVersionLS) == WINUAERELEASE) -#endif - ) + HIWORD(vsFileInfo->dwProductVersionMS) == UAEMAJOR + && LOWORD(vsFileInfo->dwProductVersionMS) == UAEMINOR + && HIWORD(vsFileInfo->dwProductVersionLS) == UAESUBREV) { success = TRUE; write_log ("Translation DLL '%s' loaded and used\n", dllname); + } else { + write_log ("Translation DLL '%s' version mismatch (%d.%d.%d)\n", dllname, + HIWORD(vsFileInfo->dwProductVersionMS), + LOWORD(vsFileInfo->dwProductVersionMS), + HIWORD(vsFileInfo->dwProductVersionLS)); } } } @@ -1370,7 +1356,7 @@ void logging_init( void ) { static int started; static int first; - char debugfilename[MAX_PATH]; + char debugfilename[MAX_DPATH]; if (first > 1) { write_log ("** RESTART **\n"); @@ -1496,19 +1482,19 @@ int target_parse_option (struct uae_prefs *p, char *option, char *value) || cfgfile_intval (option, value, "cpu_idle", &p->cpu_idle, 1)); if (cfgfile_intval (option, value, "active_priority", &v, 1)) { - p->win32_active_priority = fetchpri (v, 1); + p->win32_active_priority = fetchpri (v, 0); return 1; } if (cfgfile_intval (option, value, "activepriority", &v, 1)) { - p->win32_active_priority = fetchpri (v, 1); + p->win32_active_priority = fetchpri (v, 0); return 1; } if (cfgfile_intval (option, value, "inactive_priority", &v, 1)) { - p->win32_inactive_priority = fetchpri (v, 2); + p->win32_inactive_priority = fetchpri (v, 1); return 1; } if (cfgfile_intval (option, value, "iconified_priority", &v, 1)) { - p->win32_iconified_priority = fetchpri (v, 3); + p->win32_iconified_priority = fetchpri (v, 2); return 1; } @@ -1541,8 +1527,9 @@ static void WIN32_HandleRegistryStuff( void ) DWORD dwType = REG_DWORD; DWORD dwDisplayInfoSize = sizeof( colortype ); DWORD disposition; - char path[MAX_PATH] = ""; + char path[MAX_DPATH] = ""; HKEY hWinUAEKeyLocal = NULL; + HKEY fkey; /* Create/Open the hWinUAEKey which points to our config-info */ if( RegCreateKeyEx( HKEY_CLASSES_ROOT, ".uae", 0, "", REG_OPTION_NON_VOLATILE, @@ -1598,9 +1585,9 @@ static void WIN32_HandleRegistryStuff( void ) if( colortype == 0 ) /* No color information stored in the registry yet */ { char szMessage[ 4096 ]; - char szTitle[ MAX_PATH ]; + char szTitle[ MAX_DPATH ]; WIN32GUI_LoadUIString( IDS_GFXCARDCHECK, szMessage, 4096 ); - WIN32GUI_LoadUIString( IDS_GFXCARDTITLE, szTitle, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_GFXCARDTITLE, szTitle, MAX_DPATH ); if( MessageBox( NULL, szMessage, szTitle, MB_YESNO | MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND ) == IDYES ) @@ -1616,6 +1603,9 @@ static void WIN32_HandleRegistryStuff( void ) WIN32GFX_FigurePixelFormats( colortype ); } } + fkey = read_disk_history (); + if (fkey) + RegCloseKey (fkey); } static void betamessage (void) @@ -1637,12 +1627,12 @@ static int dxdetect (void) { /* believe or not but this is MS supported way of detecting DX8+ */ HMODULE h = LoadLibrary("D3D8.DLL"); - char szWrongDXVersion[ MAX_PATH ]; + char szWrongDXVersion[ MAX_DPATH ]; if (h) { FreeLibrary (h); return 1; } - WIN32GUI_LoadUIString( IDS_WRONGDXVERSION, szWrongDXVersion, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_WRONGDXVERSION, szWrongDXVersion, MAX_DPATH ); pre_gui_message( szWrongDXVersion ); return 0; } @@ -1670,8 +1660,8 @@ static int osdetect (void) ( osVersion.dwMajorVersion <= 4 ) ) { /* WinUAE not supported on this version of Windows... */ - char szWrongOSVersion[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_WRONGOSVERSION, szWrongOSVersion, MAX_PATH ); + char szWrongOSVersion[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_WRONGOSVERSION, szWrongOSVersion, MAX_DPATH ); pre_gui_message( szWrongOSVersion ); return FALSE; } @@ -1736,7 +1726,8 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR char **argv; int argc; int i; - char tmp[2000]; + int multi_display = 1; + char tmp[MAX_DPATH]; #ifdef __GNUC__ __asm__ ("leal -2300*1024(%%esp),%0" : "=r" (win32_stackbase) :); @@ -1787,15 +1778,16 @@ __asm{ if (!strcmp (arg, "-forcerdtsc")) no_rdtsc = -1; if (!strcmp (arg, "-norawinput")) no_rawinput = 1; if (!strcmp (arg, "-scsilog")) log_scsi = 1; + if (!strcmp (arg, "-nomultidisplay")) multi_display = 0; } #if 0 argv = 0; argv[0] = 0; #endif /* Get our executable's root-path */ - if( ( start_path = xmalloc( MAX_PATH ) ) ) + if( ( start_path = xmalloc( MAX_DPATH ) ) ) { - GetModuleFileName( NULL, start_path, MAX_PATH ); + GetModuleFileName( NULL, start_path, MAX_DPATH ); if((posn = strrchr (start_path, '\\'))) posn[1] = 0; sprintf (help_file, "%sWinUAE.chm", start_path ); @@ -1824,7 +1816,7 @@ __asm{ DirectDraw_Release (); write_log ("Enumerating display devices.. \n"); - DirectDraw_EnumDisplays (displaysCallback); + enumeratedisplays (multi_display); write_log ("Sorting devices and modes..\n"); sortdisplays (); write_log ("done\n"); @@ -1898,7 +1890,6 @@ int execute_command (char *cmd) } struct threadpriorities priorities[] = { - { "Highest", THREAD_PRIORITY_HIGHEST }, { "Above Normal", THREAD_PRIORITY_ABOVE_NORMAL }, { "Normal", THREAD_PRIORITY_NORMAL }, { "Below Normal", THREAD_PRIORITY_BELOW_NORMAL }, @@ -1989,8 +1980,8 @@ static LONG WINAPI ExceptionFilter( struct _EXCEPTION_POINTERS * pExceptionPoint } #ifndef _DEBUG if (lRet == EXCEPTION_CONTINUE_SEARCH) { - char path[_MAX_PATH]; - char path2[_MAX_PATH]; + char path[MAX_DPATH]; + char path2[MAX_DPATH]; char msg[1024]; char *p; HMODULE dll = NULL; @@ -1999,7 +1990,7 @@ static LONG WINAPI ExceptionFilter( struct _EXCEPTION_POINTERS * pExceptionPoint _time64(&now); when = *_localtime64(&now); - if (GetModuleFileName(NULL, path, _MAX_PATH)) { + if (GetModuleFileName(NULL, path, MAX_DPATH)) { char *slash = strrchr (path, '\\'); strcpy (path2, path); if (slash) { @@ -2088,7 +2079,7 @@ void systraymenu (HWND hwnd) EnableMenuItem (menu2, ID_ST_HELP, pHtmlHelp ? MF_ENABLED : MF_GRAYED); i = 0; while (drvs[i] >= 0) { - char s[MAX_PATH]; + char s[MAX_DPATH]; if (currprefs.df[i][0]) sprintf (s, "DF%d: [%s]", i, currprefs.df[i]); else diff --git a/od-win32/win32.h b/od-win32/win32.h index a35201b6..7891a308 100755 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -21,7 +21,7 @@ extern int manual_painting_needed; extern int manual_palette_refresh_needed; extern int mouseactive, focus; #define WINUAEBETA 1 -#define WINUAEBETASTR " Beta 4" +#define WINUAEBETASTR " Beta 1" extern void my_kbd_handler (int, int, int); extern void clearallkeys(void); diff --git a/od-win32/win32_filesys.c b/od-win32/win32_filesys.c index 765e81e8..615a0bbd 100755 --- a/od-win32/win32_filesys.c +++ b/od-win32/win32_filesys.c @@ -3,7 +3,7 @@ /* Determines if this drive-letter currently has a disk inserted */ static int CheckRM( char *DriveName ) { - char filename[ MAX_PATH ]; + char filename[ MAX_DPATH ]; DWORD dwHold; BOOL result = FALSE; @@ -97,7 +97,7 @@ void filesys_init( void ) { int drive, drivetype; UINT errormode = SetErrorMode( SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX ); - char volumename[MAX_PATH]=""; + char volumename[MAX_DPATH]=""; char volumepath[6]; DWORD dwDriveMask; char *result = NULL; @@ -117,7 +117,7 @@ void filesys_init( void ) drivetype = GetDriveType( volumepath ); if (drivetype != DRIVE_CDROM) { - get_volume_name( currprefs.mountinfo, volumepath, volumename, MAX_PATH, inserted, drivetype, 1 ); + get_volume_name( currprefs.mountinfo, volumepath, volumename, MAX_DPATH, inserted, drivetype, 1 ); if( drivetype == DRIVE_REMOTE ) strcat( volumepath, "." ); else diff --git a/od-win32/win32_nogui.c b/od-win32/win32_nogui.c index 219b655c..f5d0f276 100755 --- a/od-win32/win32_nogui.c +++ b/od-win32/win32_nogui.c @@ -393,7 +393,7 @@ void logging_init( void ) { static int started; static int first; - char debugfilename[MAX_PATH]; + char debugfilename[MAX_DPATH]; if (first > 1) { write_log ("** RESTART **\n"); @@ -469,8 +469,8 @@ int _stdcall WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmd, int show) hInst = hInstance; argc = __argc; argv = __argv; - start_path = xmalloc( MAX_PATH ); - GetModuleFileName( NULL, start_path, MAX_PATH ); + start_path = xmalloc( MAX_DPATH ); + GetModuleFileName( NULL, start_path, MAX_DPATH ); if( ( posn = strrchr( start_path, '\\' ) ) ) *posn = 0; real_main (argc, argv); diff --git a/od-win32/win32gfx.c b/od-win32/win32gfx.c index cc1a8b23..9aef00f8 100755 --- a/od-win32/win32gfx.c +++ b/od-win32/win32gfx.c @@ -93,10 +93,10 @@ extern int console_logging; #define SM_WINDOW_OVERLAY 1 #define SM_FULLSCREEN_DX 2 #define SM_OPENGL_WINDOW 3 -#define SM_OPENGL_FULLSCREEN_W 4 -#define SM_OPENGL_FULLSCREEN_DX 5 -#define SM_D3D_WINDOW 6 -#define SM_D3D_FULLSCREEN_DX 7 +//#define SM_OPENGL_FULLSCREEN_W 4 +#define SM_OPENGL_FULLSCREEN_DX 4 +#define SM_D3D_WINDOW 5 +#define SM_D3D_FULLSCREEN_DX 6 #define SM_NONE 7 static struct winuae_modes wmodes[] = @@ -122,15 +122,17 @@ static struct winuae_modes wmodes[] = 0 }, { - 3, "Fullscreen OpenGL", - DM_OPENGL | DM_W_FULLSCREEN | DM_DC, + 3, "DirectDraw Fullscreen OpenGL", + DM_OPENGL | DM_DX_FULLSCREEN | DM_DC, 0 }, +#if 0 { 3, "DirectDraw Fullscreen OpenGL", DM_OPENGL | DM_DX_FULLSCREEN | DM_DC, 0 }, +#endif { 0, "Windowed Direct3D", DM_D3D, @@ -266,6 +268,7 @@ static int rgbformat_bits (RGBFTYPE t) : 0); } +#if 0 static DEVMODE dmScreenSettings; static volatile cdsthread_ret; @@ -299,7 +302,7 @@ static int do_changedisplaysettings (int width, int height, int bits, int freq) Sleep (10); return cdsthread_ret; } - +#endif static int set_ddraw (void) { @@ -339,9 +342,11 @@ static int set_ddraw (void) write_log( "set_ddraw: Couldn't GetDisplayMode()\n" ); goto oops; } +#if 0 } else if (wfullscreen) { if (!do_changedisplaysettings (width, height, bits, currentmode->frequency)) goto oops2; +#endif } if (dd) { @@ -518,6 +523,18 @@ BOOL CALLBACK displaysCallback (GUID *guid, LPSTR desc, LPSTR name, LPVOID ctx, write_log ("'%s' '%s' %s\n", desc, name, outGUID(guid)); return 1; } + +void enumeratedisplays (int multi) +{ + if (multi) { + DirectDraw_EnumDisplays (displaysCallback); + } else { + Displays[0].primary = 1; + Displays[0].name = "Display"; + Displays[0].disabled = 0; + } +} + void sortdisplays (void) { struct MultiDisplay *md1, *md2, tmp; @@ -867,14 +884,6 @@ void gfx_unlock_picasso (void) } } -void restore_desktop (void) -{ - if (currentmode->flags & DM_W_FULLSCREEN) { - ChangeDisplaySettings (NULL, 0); - ShowWindow (hAmigaWnd, SW_HIDE); - } -} - static void close_hwnds( void ) { #ifdef AVIOUTPUT @@ -894,9 +903,11 @@ static void close_hwnds( void ) #ifdef D3D D3D_free (); #endif +#if 0 if (currentmode->flags & DM_W_FULLSCREEN) ChangeDisplaySettings (NULL, 0); - ShowWindow (hAmigaWnd, SW_HIDE); +#endif + ShowWindow (hAmigaWnd, SW_HIDE); DestroyWindow (hAmigaWnd); if (hAmigaWnd == hMainWnd) hMainWnd = 0; @@ -912,7 +923,6 @@ static void close_hwnds( void ) static int open_windows (void) { - int need_fs = 0; int ret, i; in_sizemove = 0; @@ -922,29 +932,31 @@ static int open_windows (void) return 0; write_log ("DirectDraw GUID=%s\n", outGUID (displayGUID)); + ret = -2; + do { + if (ret < -1) { #ifdef PICASSO96 - if (screen_is_picasso) { - currentmode->current_width = picasso_vidinfo.width; - currentmode->current_height = picasso_vidinfo.height; - currentmode->current_depth = rgbformat_bits (picasso_vidinfo.selected_rgbformat); - currentmode->frequency = currprefs.gfx_refreshrate > default_freq ? currprefs.gfx_refreshrate : default_freq; - } else { + if (screen_is_picasso) { + currentmode->current_width = picasso_vidinfo.width; + currentmode->current_height = picasso_vidinfo.height; + currentmode->current_depth = rgbformat_bits (picasso_vidinfo.selected_rgbformat); + currentmode->frequency = currprefs.gfx_refreshrate > default_freq ? currprefs.gfx_refreshrate : default_freq; + } else { #endif - currentmode->current_width = currprefs.gfx_width; - currentmode->current_height = currprefs.gfx_height; - currentmode->current_depth = (currprefs.color_mode == 0 ? 8 - : currprefs.color_mode == 1 ? 15 - : currprefs.color_mode == 2 ? 16 - : currprefs.color_mode == 3 ? 8 - : currprefs.color_mode == 4 ? 8 : 32); - currentmode->frequency = currprefs.gfx_refreshrate; + currentmode->current_width = currprefs.gfx_width; + currentmode->current_height = currprefs.gfx_height; + currentmode->current_depth = (currprefs.color_mode == 0 ? 8 + : currprefs.color_mode == 1 ? 15 + : currprefs.color_mode == 2 ? 16 + : currprefs.color_mode == 3 ? 8 + : currprefs.color_mode == 4 ? 8 : 32); + currentmode->frequency = currprefs.gfx_refreshrate; #ifdef PICASSO96 - } + } #endif - currentmode->amiga_width = currentmode->current_width; - currentmode->amiga_height = currentmode->current_height; - - do { + currentmode->amiga_width = currentmode->current_width; + currentmode->amiga_height = currentmode->current_height; + } ret = doInit (); } while (ret < 0); @@ -1526,7 +1538,7 @@ static void gfxmode_reset (void) #ifdef OPENGL if (usedfilter && usedfilter->type == UAE_FILTER_OPENGL) { currentmode->amode[0] = &wmodes[SM_OPENGL_WINDOW]; - currentmode->amode[1] = &wmodes[SM_OPENGL_FULLSCREEN_W]; + currentmode->amode[1] = &wmodes[SM_OPENGL_FULLSCREEN_DX]; } #endif #ifdef D3D @@ -1637,8 +1649,10 @@ static int create_windows (void) rc.right - rc.left + 1, rc.bottom - rc.top + 1, NULL, NULL, 0, NULL); - if (! hMainWnd) + if (! hMainWnd) { + write_log ("main window creation failed\n"); return 0; + } hStatusWnd = CreateStatusWindow (WS_CHILD | WS_VISIBLE, "", hMainWnd, 1); if (hStatusWnd) { @@ -1680,8 +1694,8 @@ static int create_windows (void) currentmode->current_width, currentmode->current_height, hMainWnd, NULL, 0, NULL); - if (! hAmigaWnd) - { + if (! hAmigaWnd) { + write_log ("creation of amiga window failed\n"); close_hwnds(); return 0; } @@ -1796,7 +1810,6 @@ static BOOL doInit (void) int fs_warning = -1; char tmpstr[300]; RGBFTYPE colortype; - int need_fs = 0; int tmp_depth; int ret = 0; int mult = 0; @@ -1815,9 +1828,9 @@ static BOOL doInit (void) if (currentmode->current_depth < 15 && (currprefs.chipset_mask & CSMASK_AGA) && isfullscreen () && !WIN32GFX_IsPicassoScreen()) { static int warned; if (!warned) { - char szMessage[ MAX_PATH ]; + char szMessage[ MAX_DPATH ]; currentmode->current_depth = 16; - WIN32GUI_LoadUIString( IDS_AGA8BIT, szMessage, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_AGA8BIT, szMessage, MAX_DPATH ); gui_message(szMessage); } warned = 1; @@ -1854,12 +1867,12 @@ static BOOL doInit (void) #endif } if (fs_warning >= 0 && !isfullscreen ()) { - char szMessage[MAX_PATH], szMessage2[MAX_PATH]; - WIN32GUI_LoadUIString( IDS_UNSUPPORTEDSCREENMODE, szMessage, MAX_PATH ); - WIN32GUI_LoadUIString( fs_warning, szMessage2, MAX_PATH ); + char szMessage[MAX_DPATH], szMessage2[MAX_DPATH]; + WIN32GUI_LoadUIString( IDS_UNSUPPORTEDSCREENMODE, szMessage, MAX_DPATH ); + WIN32GUI_LoadUIString( fs_warning, szMessage2, MAX_DPATH ); // Temporarily drop the DirectDraw stuff DirectDraw_Release(); - sprintf (tmpstr, szMessage, fs_warning); + sprintf (tmpstr, szMessage, szMessage2); gui_message (tmpstr); DirectDraw_Start(displayGUID); if (screen_is_picasso) @@ -1870,13 +1883,13 @@ static BOOL doInit (void) updatewinfsmode (&changed_prefs); currentmode->current_depth = tmp_depth; updatemodes (); + ret = -2; + goto oops; } if (! create_windows ()) goto oops; #ifdef PICASSO96 if (screen_is_picasso) { - if (need_fs) - currprefs.gfx_pfullscreen = 1; currentmode->pal = (LPPALETTEENTRY) & picasso96_state.CLUT; if (! set_ddraw ()) { if (!modefallback (0)) @@ -1891,10 +1904,6 @@ static BOOL doInit (void) break; } else { #endif - if (need_fs) { - currprefs.gfx_afullscreen = 1; - updatewinfsmode (&currprefs); - } currentmode->pal = colors256; if (! set_ddraw ()) { if (!modefallback (0)) @@ -1954,8 +1963,8 @@ static BOOL doInit (void) write_log( "%s mode (bits: %d, pixbytes: %d)\n", currentmode->flags & DM_DX_FULLSCREEN ? "Full screen" : "Window", DirectDraw_GetSurfaceBitCount(), currentmode->current_depth >> 3 ); } else { - char szMessage[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_UNSUPPORTEDPIXELFORMAT, szMessage, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_UNSUPPORTEDPIXELFORMAT, szMessage, MAX_DPATH ); gui_message( szMessage); goto oops; } diff --git a/od-win32/win32gfx.h b/od-win32/win32gfx.h index 2a9bb09b..99c89714 100755 --- a/od-win32/win32gfx.h +++ b/od-win32/win32gfx.h @@ -3,8 +3,8 @@ #include -BOOL CALLBACK displaysCallback (GUID *guid, LPSTR desc, LPSTR name, LPVOID ctx, HMONITOR hm); extern void sortdisplays (void); +extern void enumeratedisplays (int); int WIN32GFX_IsPicassoScreen( void ); int WIN32GFX_GetWidth( void ); diff --git a/od-win32/win32gui.c b/od-win32/win32gui.c index c7f5942d..6b3ce57b 100755 --- a/od-win32/win32gui.c +++ b/od-win32/win32gui.c @@ -59,6 +59,9 @@ #include "akiko.h" #include "gfxfilter.h" #include "driveclick.h" +#ifdef PROWIZARD +#include "moduleripper.h" +#endif #define DISK_FORMAT_STRING "(*.adf;*.adz;*.gz;*.dms;*.fdi;*.ipf;*.zip;*.exe)\0*.adf;*.adz;*.gz;*.dms;*.fdi;*.ipf;*.zip;*.exe\0" #define ROM_FORMAT_STRING "(*.rom;*.zip;*.roz)\0*.rom;*.zip;*.roz\0" @@ -78,16 +81,15 @@ extern HWND (WINAPI *pHtmlHelp)(HWND, LPCSTR, UINT, LPDWORD ); #define HH_DISPLAY_TOPIC 0 #endif #define HtmlHelp(a,b,c,d) if( pHtmlHelp ) (*pHtmlHelp)(a,b,c,(LPDWORD)d); else \ -{ char szMessage[MAX_PATH]; WIN32GUI_LoadUIString( IDS_NOHELP, szMessage, MAX_PATH ); gui_message( szMessage ); } +{ char szMessage[MAX_DPATH]; WIN32GUI_LoadUIString( IDS_NOHELP, szMessage, MAX_DPATH ); gui_message( szMessage ); } extern HWND hAmigaWnd; -extern char help_file[ MAX_PATH ]; +extern char help_file[ MAX_DPATH ]; extern int mouseactive; extern char *start_path; -extern char configname[256]; -static char config_filename[ MAX_PATH ] = ""; +static char config_filename[ MAX_DPATH ] = ""; static drive_specs blankdrive = {"", "", 1, 32, 1, 2, 0, 0}; @@ -138,7 +140,7 @@ static HWND cachedlist = NULL; #define MIN_SOUND_MEM 0 #define MAX_SOUND_MEM 6 -static char szNone[ MAX_PATH ] = "None"; +static char szNone[ MAX_DPATH ] = "None"; static int cfgfile_doload (struct uae_prefs *p, const char *filename, int type) { @@ -155,6 +157,8 @@ static int cfgfile_doload (struct uae_prefs *p, const char *filename, int type) return cfgfile_load (p, filename, 0); } +static int gui_width = 640, gui_height = 480; + /* if drive is -1, show the full GUI, otherwise file-requester for DF[drive] */ void gui_display( int shortcut ) { @@ -176,9 +180,9 @@ void gui_display( int shortcut ) pause_sound (); setmouseactive (0); - if( ( !WIN32GFX_IsPicassoScreen() && currprefs.gfx_afullscreen && ( currprefs.gfx_width < 640 || currprefs.gfx_height < 480 ) ) + if( ( !WIN32GFX_IsPicassoScreen() && currprefs.gfx_afullscreen && ( currprefs.gfx_width < gui_width || currprefs.gfx_height < gui_height ) ) #ifdef PICASSO96 - || ( WIN32GFX_IsPicassoScreen() && currprefs.gfx_pfullscreen && ( picasso96_state.Width < 640 || picasso96_state.Height < 480 ) ) + || ( WIN32GFX_IsPicassoScreen() && currprefs.gfx_pfullscreen && ( picasso96_state.Width < gui_width || picasso96_state.Height < gui_height ) ) #endif ) { flipflop = 1; @@ -187,8 +191,9 @@ void gui_display( int shortcut ) manual_painting_needed++; /* So that WM_PAINT will refresh the display */ hr = DirectDraw_FlipToGDISurface(); - if (hr != DD_OK) + if (hr != DD_OK) { write_log ("FlipToGDISurface failed, %s\n", DXError (hr)); + } if( shortcut == -1 ) { int ret; @@ -201,7 +206,9 @@ void gui_display( int shortcut ) savestate_state = 0; } } else if (shortcut >= 0 && shortcut < 4) { + write_log("1\n"); DiskSelection( hAmigaWnd, IDC_DF0+shortcut, 0, &changed_prefs, 0 ); + write_log("2\n"); } else if (shortcut == 5) { if (DiskSelection( hAmigaWnd, IDC_DOSAVESTATE, 9, &changed_prefs, 0 )) save_state (savestate_fname, "Description!"); @@ -230,6 +237,10 @@ void gui_display( int shortcut ) AVIOutput_Begin (); #endif fpscounter_reset (); + WIN32GFX_SetPalette(); +#ifdef PICASSO96 + DX_SetPalette (0, 256); +#endif gui_active = 0; } @@ -271,26 +282,26 @@ static void gui_to_prefs (void) int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, char *path_out) { OPENFILENAME openFileName; - char regfloppypath[MAX_PATH] = ""; - char regrompath[MAX_PATH] = ""; - char reghdfpath[MAX_PATH] = ""; + char regfloppypath[MAX_DPATH] = ""; + char regrompath[MAX_DPATH] = ""; + char reghdfpath[MAX_DPATH] = ""; DWORD dwType = REG_SZ; - DWORD dwRFPsize = MAX_PATH; - DWORD dwRRPsize = MAX_PATH; - DWORD dwRHPsize = MAX_PATH; + DWORD dwRFPsize = MAX_DPATH; + DWORD dwRRPsize = MAX_DPATH; + DWORD dwRHPsize = MAX_DPATH; - char full_path[MAX_PATH] = ""; - char file_name[MAX_PATH] = ""; - char init_path[MAX_PATH] = ""; + char full_path[MAX_DPATH] = ""; + char file_name[MAX_DPATH] = ""; + char init_path[MAX_DPATH] = ""; BOOL result = FALSE; char *amiga_path = NULL; char description[ CFG_DESCRIPTION_LENGTH ] = ""; char *p; int all = 1; - char szTitle[ MAX_PATH ]; - char szFormat[ MAX_PATH ]; - char szFilter[ MAX_PATH ] = { 0 }; + char szTitle[ MAX_DPATH ]; + char szFormat[ MAX_DPATH ]; + char szFilter[ MAX_DPATH ] = { 0 }; memset (&openFileName, 0, sizeof (OPENFILENAME)); if( hWinUAEKey ) @@ -300,39 +311,39 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, RegQueryValueEx( hWinUAEKey, "hdfPath", 0, &dwType, (LPBYTE)reghdfpath, &dwRHPsize ); } - strncpy( init_path, start_path, MAX_PATH ); + strncpy( init_path, start_path, MAX_DPATH ); switch( flag ) { case 0: case 1: if( regfloppypath[0] ) - strncpy( init_path, regfloppypath, MAX_PATH ); + strncpy( init_path, regfloppypath, MAX_DPATH ); else - strncat( init_path, "..\\shared\\adf\\", MAX_PATH ); + strncat( init_path, "..\\shared\\adf\\", MAX_DPATH ); break; case 2: case 3: if( reghdfpath[0] ) - strncpy( init_path, reghdfpath, MAX_PATH ); + strncpy( init_path, reghdfpath, MAX_DPATH ); else - strncat( init_path, "..\\shared\\hdf\\", MAX_PATH ); + strncat( init_path, "..\\shared\\hdf\\", MAX_DPATH ); break; case 6: case 7: case 11: if( regrompath[0] ) - strncpy( init_path, regrompath, MAX_PATH ); + strncpy( init_path, regrompath, MAX_DPATH ); else - strncat( init_path, "..\\shared\\rom\\", MAX_PATH ); + strncat( init_path, "..\\shared\\rom\\", MAX_DPATH ); break; case 4: case 5: case 8: - strncat( init_path, "Configurations\\", MAX_PATH ); + strncat( init_path, "Configurations\\", MAX_DPATH ); break; case 9: case 10: - strncat( init_path, "SaveStates\\", MAX_PATH ); + strncat( init_path, "SaveStates\\", MAX_DPATH ); break; } @@ -343,8 +354,8 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, switch (flag) { case 0: - WIN32GUI_LoadUIString( IDS_SELECTADF, szTitle, MAX_PATH ); - WIN32GUI_LoadUIString( IDS_ADF, szFormat, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_SELECTADF, szTitle, MAX_DPATH ); + WIN32GUI_LoadUIString( IDS_ADF, szFormat, MAX_DPATH ); sprintf( szFilter, "%s ", szFormat ); memcpy( szFilter + strlen( szFilter ), DISK_FORMAT_STRING, sizeof( DISK_FORMAT_STRING ) + 1 ); @@ -353,8 +364,8 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, openFileName.lpstrFilter = szFilter; break; case 1: - WIN32GUI_LoadUIString( IDS_CHOOSEBLANK, szTitle, MAX_PATH ); - WIN32GUI_LoadUIString( IDS_ADF, szFormat, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_CHOOSEBLANK, szTitle, MAX_DPATH ); + WIN32GUI_LoadUIString( IDS_ADF, szFormat, MAX_DPATH ); sprintf( szFilter, "%s ", szFormat ); memcpy( szFilter + strlen( szFilter ), "(*.adf)\0*.adf\0", 15 ); @@ -364,8 +375,8 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, break; case 2: case 3: - WIN32GUI_LoadUIString( IDS_SELECTHDF, szTitle, MAX_PATH ); - WIN32GUI_LoadUIString( IDS_HDF, szFormat, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_SELECTHDF, szTitle, MAX_DPATH ); + WIN32GUI_LoadUIString( IDS_HDF, szFormat, MAX_DPATH ); sprintf( szFilter, "%s ", szFormat ); memcpy( szFilter + strlen( szFilter ), "(*.hdf;*.rdf)\0*.hdf;*.rdf\0", 26 ); @@ -375,8 +386,8 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, break; case 4: case 5: - WIN32GUI_LoadUIString( IDS_SELECTUAE, szTitle, MAX_PATH ); - WIN32GUI_LoadUIString( IDS_UAE, szFormat, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_SELECTUAE, szTitle, MAX_DPATH ); + WIN32GUI_LoadUIString( IDS_UAE, szFormat, MAX_DPATH ); sprintf( szFilter, "%s ", szFormat ); memcpy( szFilter + strlen( szFilter ), "(*.uae)\0*.uae\0", 15 ); @@ -385,8 +396,8 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, openFileName.lpstrFilter = szFilter; break; case 6: - WIN32GUI_LoadUIString( IDS_SELECTROM, szTitle, MAX_PATH ); - WIN32GUI_LoadUIString( IDS_ROM, szFormat, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_SELECTROM, szTitle, MAX_DPATH ); + WIN32GUI_LoadUIString( IDS_ROM, szFormat, MAX_DPATH ); sprintf( szFilter, "%s ", szFormat ); memcpy( szFilter + strlen( szFilter ), ROM_FORMAT_STRING, sizeof (ROM_FORMAT_STRING) + 1); @@ -395,8 +406,8 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, openFileName.lpstrFilter = szFilter; break; case 7: - WIN32GUI_LoadUIString( IDS_SELECTKEY, szTitle, MAX_PATH ); - WIN32GUI_LoadUIString( IDS_KEY, szFormat, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_SELECTKEY, szTitle, MAX_DPATH ); + WIN32GUI_LoadUIString( IDS_KEY, szFormat, MAX_DPATH ); sprintf( szFilter, "%s ", szFormat ); memcpy( szFilter + strlen( szFilter ), "(*.key)\0*.key\0", 15 ); @@ -406,8 +417,8 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, break; case 9: case 10: - WIN32GUI_LoadUIString( flag == 10 ? IDS_RESTOREUSS : IDS_SAVEUSS, szTitle, MAX_PATH ); - WIN32GUI_LoadUIString( IDS_USS, szFormat, MAX_PATH ); + WIN32GUI_LoadUIString( flag == 10 ? IDS_RESTOREUSS : IDS_SAVEUSS, szTitle, MAX_DPATH ); + WIN32GUI_LoadUIString( IDS_USS, szFormat, MAX_DPATH ); sprintf( szFilter, "%s ", szFormat ); if (flag == 10) { memcpy( szFilter + strlen( szFilter ), USS_FORMAT_STRING_RESTORE, sizeof (USS_FORMAT_STRING_RESTORE) + 1); @@ -433,8 +444,8 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, openFileName.lpstrFilter = szFilter; break; case 11: - WIN32GUI_LoadUIString( IDS_SELECTFLASH, szTitle, MAX_PATH ); - WIN32GUI_LoadUIString( IDS_FLASH, szFormat, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_SELECTFLASH, szTitle, MAX_DPATH ); + WIN32GUI_LoadUIString( IDS_FLASH, szFormat, MAX_DPATH ); sprintf( szFilter, "%s ", szFormat ); memcpy( szFilter + strlen( szFilter ), "(*.nvr)\0*.nvr\0", 15 ); @@ -444,7 +455,7 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, break; case 8: default: - WIN32GUI_LoadUIString( IDS_SELECTINFO, szTitle, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_SELECTINFO, szTitle, MAX_DPATH ); openFileName.lpstrTitle = szTitle; openFileName.lpstrFilter = NULL; @@ -466,9 +477,9 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, openFileName.nMaxCustFilter = 0; openFileName.nFilterIndex = 0; openFileName.lpstrFile = full_path; - openFileName.nMaxFile = MAX_PATH; + openFileName.nMaxFile = MAX_DPATH; openFileName.lpstrFileTitle = file_name; - openFileName.nMaxFileTitle = MAX_PATH; + openFileName.nMaxFileTitle = MAX_DPATH; openFileName.lpstrInitialDir = init_path; openFileName.lpfnHook = NULL; openFileName.lpTemplateName = NULL; @@ -483,7 +494,7 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, if( !(result = GetOpenFileName (&openFileName)) ) write_log ("GetOpenFileName() failed.\n"); } - + write_log("result=%d\n", result); // xxx if (result) { switch (wParam) @@ -501,20 +512,28 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, SetDlgItemText (hDlg, wParam, full_path); break; case IDC_DF0: + write_log("x1\n"); SetDlgItemText (hDlg, IDC_DF0TEXT, full_path); + write_log("x2\n"); strcpy( prefs->df[0], full_path ); + write_log("x3\n"); + DISK_history_add (full_path, -1); + write_log("x4\n"); break; case IDC_DF1: SetDlgItemText (hDlg, IDC_DF1TEXT, full_path); strcpy( prefs->df[1], full_path ); + DISK_history_add (full_path, -1); break; case IDC_DF2: SetDlgItemText (hDlg, IDC_DF2TEXT, full_path); strcpy( prefs->df[2], full_path ); + DISK_history_add (full_path, -1); break; case IDC_DF3: SetDlgItemText (hDlg, IDC_DF3TEXT, full_path); strcpy( prefs->df[3], full_path ); + DISK_history_add (full_path, -1); break; case IDC_DOSAVESTATE: case IDC_DOLOADSTATE: @@ -529,8 +548,8 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, case IDC_LOAD: if (cfgfile_doload(&workprefs, full_path, 0) == 0) { - char szMessage[MAX_PATH]; - WIN32GUI_LoadUIString (IDS_COULDNOTLOADCONFIG, szMessage, MAX_PATH); + char szMessage[MAX_DPATH]; + WIN32GUI_LoadUIString (IDS_COULDNOTLOADCONFIG, szMessage, MAX_DPATH); gui_message (szMessage); } else @@ -543,6 +562,7 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, break; case IDC_SAVE: SetDlgItemText( hDlg, IDC_EDITNAME, full_path ); + cfgfile_save (&workprefs, full_path, 0); break; case IDC_ROMFILE: SetDlgItemText( hDlg, IDC_ROMFILE, full_path ); @@ -598,6 +618,7 @@ int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, } } } + write_log("return=%d\n", result); return result; } @@ -608,12 +629,12 @@ static BOOL CreateHardFile (HWND hDlg, UINT hfsizem) BOOL result = FALSE; LONG highword = 0; DWORD ret; - char init_path[MAX_PATH] = ""; + char init_path[MAX_DPATH] = ""; uae_u64 hfsize; hfsize = (uae_u64)hfsizem * 1024 * 1024; DiskSelection (hDlg, IDC_PATH_NAME, 3, &workprefs, 0); - GetDlgItemText (hDlg, IDC_PATH_NAME, init_path, MAX_PATH); + GetDlgItemText (hDlg, IDC_PATH_NAME, init_path, MAX_DPATH); if (*init_path && hfsize) { SetCursor (LoadCursor(NULL, IDC_WAIT)); if ((hf = CreateFile (init_path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL) ) != INVALID_HANDLE_VALUE) { @@ -696,9 +717,9 @@ static const char *nth[] = { }; struct ConfigStruct { - char Name[MAX_PATH]; - char Path[MAX_PATH]; - char Fullpath[MAX_PATH]; + char Name[MAX_DPATH]; + char Path[MAX_DPATH]; + char Fullpath[MAX_DPATH]; char Description[CFG_DESCRIPTION_LENGTH]; int Type, Directory; struct ConfigStruct *Parent, *Child; @@ -718,8 +739,8 @@ static void GetConfigPath (char *path, struct ConfigStruct *parent, int noroot) } if (parent) { GetConfigPath (path, parent->Parent, noroot); - strncat (path, parent->Name, MAX_PATH); - strncat (path, "\\", MAX_PATH); + strncat (path, parent->Name, MAX_DPATH); + strncat (path, "\\", MAX_DPATH); } } @@ -741,9 +762,9 @@ static int configstoresize, configstoreallocated; static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int usedirs) { DWORD num_bytes = 0; - char path[MAX_PATH]; - char path2[MAX_PATH]; - char shortpath[MAX_PATH]; + char path[MAX_DPATH]; + char path2[MAX_DPATH]; + char shortpath[MAX_DPATH]; WIN32_FIND_DATA find_data; struct ConfigStruct *config, *first; HANDLE handle; @@ -752,7 +773,7 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u GetConfigPath (path, configparent, FALSE); GetConfigPath (shortpath, configparent, TRUE); strcpy (path2, path); - strncat (path2, "*.*", MAX_PATH); + strncat (path2, "*.*", MAX_DPATH); handle = FindFirstFile(path2, &find_data ); if (handle == INVALID_HANDLE_VALUE) { #ifndef SINGLEFILE @@ -778,12 +799,17 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u if (child) config->Child = child; } else if (!(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - char path3[MAX_PATH]; - strcpy (path3, path); - strncat (path3, find_data.cFileName, MAX_PATH); - if (cfgfile_get_description (path3, config->Description, &config->Type)) { - strcpy (config->Name, find_data.cFileName); - } else { + char path3[MAX_DPATH]; + int ok = 0; + if (strlen (find_data.cFileName) > 4 && !strcasecmp (find_data.cFileName + strlen (find_data.cFileName) - 4, ".uae")) { + strcpy (path3, path); + strncat (path3, find_data.cFileName, MAX_DPATH); + if (cfgfile_get_description (path3, config->Description, &config->Type)) { + strcpy (config->Name, find_data.cFileName); + ok = 1; + } + } + if (!ok) { FreeConfigStruct (config); config = NULL; } @@ -826,31 +852,35 @@ static void CreateConfigStore (void) static char *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *config) { - char name[MAX_PATH], desc[MAX_PATH]; - char path[MAX_PATH]; - static char full_path[MAX_PATH]; + char name[MAX_DPATH], desc[MAX_DPATH]; + char path[MAX_DPATH]; + static char full_path[MAX_DPATH]; int type; type = SendDlgItemMessage (hDlg, IDC_CONFIGTYPE, CB_GETCURSEL, 0, 0); if (type == CB_ERR) type = 0; full_path[0] = 0; - GetDlgItemText (hDlg, IDC_EDITNAME, name, MAX_PATH); - GetDlgItemText (hDlg, IDC_EDITDESCRIPTION, desc, MAX_PATH); + GetDlgItemText (hDlg, IDC_EDITNAME, name, MAX_DPATH); + if (flag == CONFIG_SAVE_FULL || flag == CONFIG_SAVE) { + if (strlen (name) < 4 || strcasecmp (name + strlen (name) - 4, ".uae")) { + strcat (name, ".uae"); + SetDlgItemText (hDlg, IDC_EDITNAME, name); + } + } + GetDlgItemText (hDlg, IDC_EDITDESCRIPTION, desc, MAX_DPATH); if (config) { strcpy (path, config->Fullpath); } else { - strncpy (path, start_path, MAX_PATH); - strncat (path, "Configurations\\", MAX_PATH); + strncpy (path, start_path, MAX_DPATH); + strncat (path, "Configurations\\", MAX_DPATH); } - strncat (path, name, MAX_PATH); + strncat (path, name, MAX_DPATH); strcpy (full_path, path); switch (flag) { case CONFIG_SAVE_FULL: DiskSelection( hDlg, IDC_SAVE, 5, &workprefs, 0); - strcpy (workprefs.description, desc); - cfgfile_save (&workprefs, path, type); break; case CONFIG_LOAD_FULL: @@ -860,8 +890,8 @@ static char *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *conf case CONFIG_SAVE: if (strlen (name) == 0) { - char szMessage[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_MUSTENTERNAME, szMessage, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_MUSTENTERNAME, szMessage, MAX_DPATH ); gui_message( szMessage ); } else { strcpy (workprefs.description, desc); @@ -871,13 +901,13 @@ static char *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *conf case CONFIG_LOAD: if (strlen (name) == 0) { - char szMessage[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_MUSTSELECTCONFIG, szMessage, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_MUSTSELECTCONFIG, szMessage, MAX_DPATH ); gui_message( szMessage ); } else { if (cfgfile_doload (&workprefs, path, type) == 0) { - char szMessage[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_COULDNOTLOADCONFIG, szMessage, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_COULDNOTLOADCONFIG, szMessage, MAX_DPATH ); gui_message( szMessage ); } else { EnableWindow (GetDlgItem (hDlg, IDC_VIEWINFO), workprefs.info[0]); @@ -886,14 +916,14 @@ static char *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *conf case CONFIG_DELETE: if (strlen (name) == 0) { - char szMessage[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_MUSTSELECTCONFIGFORDELETE, szMessage, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_MUSTSELECTCONFIGFORDELETE, szMessage, MAX_DPATH ); gui_message( szMessage ); } else { - char szMessage[ MAX_PATH ]; - char szTitle[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_DELETECONFIGCONFIRMATION, szMessage, MAX_PATH ); - WIN32GUI_LoadUIString( IDS_DELETECONFIGTITLE, szTitle, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + char szTitle[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_DELETECONFIGCONFIRMATION, szMessage, MAX_DPATH ); + WIN32GUI_LoadUIString( IDS_DELETECONFIGTITLE, szTitle, MAX_DPATH ); if( MessageBox( hDlg, szMessage, szTitle, MB_YESNO | MB_ICONWARNING | MB_APPLMODAL | MB_SETFOREGROUND ) == IDYES ) { DeleteFile (path); @@ -927,26 +957,33 @@ static int disk_swap (int entry, int col) drvs[drv] = i; } if ((drv = disk_in_drive (entry)) >= 0) { - if (strcmp (workprefs.df[drv], currprefs.df[drv])) + if (strcmp (workprefs.df[drv], currprefs.df[drv])) { strcpy (workprefs.df[drv], currprefs.df[drv]); - else + disk_insert (drv, workprefs.df[drv]); + } else { workprefs.df[drv][0] = 0; + disk_eject (drv); + } if (drvs[0] < 0 || drvs[1] < 0 || drvs[2] < 0 || drvs[3] < 0) { drv++; while (drv < 4 && drvs[drv] >= 0) drv++; - if (drv < 4 && workprefs.dfxtype[drv] >= 0) + if (drv < 4 && workprefs.dfxtype[drv] >= 0) { strcpy (workprefs.df[drv], workprefs.dfxlist[entry]); + disk_insert (drv, workprefs.df[drv]); + } } return 1; } for (i = 0; i < 4; i++) { if (drvs[i] < 0 && workprefs.dfxtype[i] >= 0) { strcpy (workprefs.df[i], workprefs.dfxlist[entry]); + disk_insert (i, workprefs.df[i]); return 1; } } strcpy (workprefs.df[0], workprefs.dfxlist[entry]); + disk_insert (0, workprefs.df[0]); return 1; } @@ -1010,12 +1047,12 @@ void InitializeListView( HWND hDlg ) char blocksize_str[6] = ""; char readwrite_str[4] = ""; char size_str[32] = ""; - char volname_str[ MAX_PATH ] = ""; - char devname_str[ MAX_PATH ] = ""; + char volname_str[ MAX_DPATH ] = ""; + char devname_str[ MAX_DPATH ] = ""; char bootpri_str[6] = ""; int width = 0; - int items = 0, result = 0, i, entry = 0, temp = 0; - char tmp[10]; + int items = 0, result = 0, i, j, entry = 0, temp = 0; + char tmp[10], tmp2[MAX_DPATH]; if (hDlg == pages[HARDDISK_ID]) { listview_num_columns = HARDDISK_COLUMNS; @@ -1096,7 +1133,16 @@ void InitializeListView( HWND hDlg ) lvstruct.iItem = i; lvstruct.iSubItem = 0; result = ListView_InsertItem (list, &lvstruct); - ListView_SetItemText (list, result, 1, workprefs.dfxlist[i]); + strcpy (tmp2, workprefs.dfxlist[i]); + j = strlen (tmp2) - 1; + if (j < 0) + j = 0; + while (j > 0) { + if (tmp2[j - 1] == '\\' || tmp2[j - 1] == '/') + break; + j--; + } + ListView_SetItemText (list, result, 1, tmp2 + j); drv = disk_in_drive (i); tmp[0] = 0; if (drv >= 0) @@ -1316,11 +1362,11 @@ static HTREEITEM AddConfigNode (HWND hDlg, struct ConfigStruct *config, char *na { TVINSERTSTRUCT is; HWND TVhDlg; - char s[MAX_PATH] = ""; - char file_name[MAX_PATH], file_path[MAX_PATH]; + char s[MAX_DPATH] = ""; + char file_name[MAX_DPATH], file_path[MAX_DPATH]; - GetDlgItemText (hDlg, IDC_EDITNAME, file_name, MAX_PATH); - GetDlgItemText (hDlg, IDC_EDITPATH, file_path, MAX_PATH); + GetDlgItemText (hDlg, IDC_EDITNAME, file_name, MAX_DPATH); + GetDlgItemText (hDlg, IDC_EDITPATH, file_path, MAX_DPATH); TVhDlg = GetDlgItem(hDlg, IDC_CONFIGTREE); memset (&is, 0, sizeof (is)); is.hInsertAfter = isdir < 0 ? TVI_ROOT : TVI_SORT; @@ -1401,7 +1447,7 @@ static HTREEITEM InitializeConfigTreeView (HWND hDlg) HIMAGELIST himl = ImageList_Create (16, 16, ILC_COLOR8 | ILC_MASK, 3, 0); HWND TVhDlg = GetDlgItem(hDlg, IDC_CONFIGTREE); HTREEITEM parent; - char path[MAX_PATH]; + char path[MAX_DPATH]; int i; if (himl) { @@ -1425,17 +1471,17 @@ static HTREEITEM InitializeConfigTreeView (HWND hDlg) static void ConfigToRegistry (struct ConfigStruct *config) { - if (hWinUAEKey) { - char path[MAX_PATH]; + if (hWinUAEKey && config) { + char path[MAX_DPATH]; strcpy (path, config->Path); - strncat (path, config->Name, MAX_PATH); + strncat (path, config->Name, MAX_DPATH); RegSetValueEx (hWinUAEKey, "ConfigFile", 0, REG_SZ, (CONST BYTE *)path, strlen(path)); } } static BOOL CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - char name_buf[MAX_PATH]; + char name_buf[MAX_DPATH]; char *cfgfile; static int recursive; HTREEITEM root; @@ -1456,11 +1502,11 @@ static BOOL CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM if (hWinUAEKey) { DWORD dwType = REG_SZ; DWORD dwRFPsize = sizeof (name_buf); - char path[MAX_PATH]; + char path[MAX_DPATH]; if (RegQueryValueEx (hWinUAEKey, "ConfigFile", 0, &dwType, (LPBYTE)name_buf, &dwRFPsize) == ERROR_SUCCESS) { for (i = 0; i < configstoresize; i++) { strcpy (path, configstore[i]->Path); - strncat (path, configstore[i]->Name, MAX_PATH); + strncat (path, configstore[i]->Name, MAX_DPATH); if (!strcmp (name_buf, path)) { config = configstore[i]; break; @@ -1514,7 +1560,7 @@ static BOOL CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM if (full_property_sheet) { inputdevice_updateconfig (&workprefs); } else { - uae_restart (1, cfgfile); + uae_restart (-1, cfgfile); exit_gui(1); } break; @@ -1524,7 +1570,7 @@ static BOOL CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM if (full_property_sheet) { inputdevice_updateconfig (&workprefs); } else { - uae_restart (1, cfgfile); + uae_restart (-1, cfgfile); exit_gui(1); } break; @@ -2319,9 +2365,9 @@ static BOOL CALLBACK DisplayDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM if( RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Arabuusimiehet\\WinUAE", 0, KEY_ALL_ACCESS, &hPixelFormatKey ) == ERROR_SUCCESS ) { char szMessage[ 4096 ]; - char szTitle[ MAX_PATH ]; + char szTitle[ MAX_DPATH ]; WIN32GUI_LoadUIString( IDS_GFXCARDCHECK, szMessage, 4096 ); - WIN32GUI_LoadUIString( IDS_GFXCARDTITLE, szTitle, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_GFXCARDTITLE, szTitle, MAX_DPATH ); if( MessageBox( NULL, szMessage, szTitle, MB_YESNO | MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND ) == IDYES ) @@ -2750,9 +2796,7 @@ static void enable_for_miscdlg (HWND hDlg) EnableWindow( GetDlgItem( hDlg, IDC_STATE_CAPTURE ), FALSE ); EnableWindow( GetDlgItem( hDlg, IDC_STATE_RATE ), FALSE ); EnableWindow( GetDlgItem( hDlg, IDC_STATE_BUFFERSIZE ), FALSE ); - } - else - { + } else { #if !defined (FILESYS) EnableWindow( GetDlgItem( hDlg, IDC_CLOCKSYNC ), FALSE ); #endif @@ -2764,17 +2808,12 @@ static void enable_for_miscdlg (HWND hDlg) EnableWindow( GetDlgItem( hDlg, IDC_ASPI ), FALSE ); #endif if( workprefs.win32_logfile ) - { - EnableWindow( GetDlgItem( hDlg, IDC_ILLEGAL ), TRUE ); - } + EnableWindow( GetDlgItem( hDlg, IDC_ILLEGAL ), TRUE ); else - { - EnableWindow( GetDlgItem( hDlg, IDC_ILLEGAL ), FALSE ); - } + EnableWindow( GetDlgItem( hDlg, IDC_ILLEGAL ), FALSE ); EnableWindow( GetDlgItem( hDlg, IDC_DOSAVESTATE ), FALSE ); EnableWindow( GetDlgItem( hDlg, IDC_STATE_RATE ), workprefs.statecapture ? TRUE : FALSE ); EnableWindow( GetDlgItem( hDlg, IDC_STATE_BUFFERSIZE ), workprefs.statecapture ? TRUE : FALSE ); - } } @@ -2895,14 +2934,14 @@ static BOOL MiscDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) misc_getkbled (hDlg, IDC_KBLED1, 0); misc_getkbled (hDlg, IDC_KBLED2, 1); misc_getkbled (hDlg, IDC_KBLED3, 2); - } else { - misc_getpri (hDlg, IDC_ACTIVE_PRIORITY, &workprefs.win32_active_priority); - misc_getpri (hDlg, IDC_INACTIVE_PRIORITY, &workprefs.win32_inactive_priority); - misc_getpri (hDlg, IDC_MINIMIZED_PRIORITY, &workprefs.win32_iconified_priority); SendDlgItemMessage (hDlg, IDC_STATE_RATE, WM_GETTEXT, (WPARAM)sizeof (txt), (LPARAM)txt); workprefs.statecapturerate = atol (txt) * 50; SendDlgItemMessage (hDlg, IDC_STATE_BUFFERSIZE, WM_GETTEXT, (WPARAM)sizeof (txt), (LPARAM)txt); workprefs.statecapturebuffersize = atol (txt) * 1024 * 1024; + } else { + misc_getpri (hDlg, IDC_ACTIVE_PRIORITY, &workprefs.win32_active_priority); + misc_getpri (hDlg, IDC_INACTIVE_PRIORITY, &workprefs.win32_inactive_priority); + misc_getpri (hDlg, IDC_MINIMIZED_PRIORITY, &workprefs.win32_iconified_priority); } switch( wParam ) @@ -3609,11 +3648,11 @@ static int CALLBACK VolumeSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR { static int recursive = 0; BROWSEINFO browse_info; - char directory_path[MAX_PATH] = ""; + char directory_path[MAX_DPATH] = ""; LPITEMIDLIST browse; - char szTitle[ MAX_PATH ]; + char szTitle[ MAX_DPATH ]; - WIN32GUI_LoadUIString( IDS_SELECTFILESYSROOT, szTitle, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_SELECTFILESYSROOT, szTitle, MAX_DPATH ); browse_info.hwndOwner = hDlg; browse_info.pidlRoot = NULL; @@ -3649,10 +3688,10 @@ static int CALLBACK VolumeSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR case IDOK: if( strlen( current_fsvdlg.rootdir ) == 0 ) { - char szMessage[ MAX_PATH ]; - char szTitle[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_MUSTSELECTPATH, szMessage, MAX_PATH ); - WIN32GUI_LoadUIString( IDS_SETTINGSERROR, szTitle, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + char szTitle[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_MUSTSELECTPATH, szMessage, MAX_DPATH ); + WIN32GUI_LoadUIString( IDS_SETTINGSERROR, szTitle, MAX_DPATH ); MessageBox( hDlg, szMessage, szTitle, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND); @@ -3660,10 +3699,10 @@ static int CALLBACK VolumeSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR } if( strlen( current_fsvdlg.volume ) == 0 ) { - char szMessage[ MAX_PATH ]; - char szTitle[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_MUSTSELECTNAME, szMessage, MAX_PATH ); - WIN32GUI_LoadUIString( IDS_SETTINGSERROR, szTitle, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + char szTitle[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_MUSTSELECTNAME, szMessage, MAX_DPATH ); + WIN32GUI_LoadUIString( IDS_SETTINGSERROR, szTitle, MAX_DPATH ); MessageBox( hDlg, szMessage, szTitle, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND); @@ -3743,10 +3782,10 @@ static int CALLBACK HardfileSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LP setting = CalculateHardfileSize (hDlg); if( !CreateHardFile(hDlg, setting) ) { - char szMessage[ MAX_PATH ]; - char szTitle[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_FAILEDHARDFILECREATION, szMessage, MAX_PATH ); - WIN32GUI_LoadUIString( IDS_CREATIONERROR, szTitle, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + char szTitle[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_FAILEDHARDFILECREATION, szMessage, MAX_DPATH ); + WIN32GUI_LoadUIString( IDS_CREATIONERROR, szTitle, MAX_DPATH ); MessageBox( hDlg, szMessage, szTitle, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND); @@ -3763,10 +3802,10 @@ static int CALLBACK HardfileSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LP case IDOK: if( strlen( current_hfdlg.filename ) == 0 ) { - char szMessage[ MAX_PATH ]; - char szTitle[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_MUSTSELECTFILE, szMessage, MAX_PATH ); - WIN32GUI_LoadUIString( IDS_SETTINGSERROR, szTitle, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + char szTitle[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_MUSTSELECTFILE, szMessage, MAX_DPATH ); + WIN32GUI_LoadUIString( IDS_SETTINGSERROR, szTitle, MAX_DPATH ); MessageBox( hDlg, szMessage, szTitle, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND); @@ -4105,6 +4144,40 @@ static BOOL CALLBACK HarddiskDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM #endif +HKEY read_disk_history (void) +{ + static int regread; + char tmp2[1000]; + DWORD size2; + int idx, idx2; + HKEY fkey; + char tmp[1000]; + DWORD size; + + RegCreateKeyEx(hWinUAEKey , "DiskImageMRUList", 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, NULL, &fkey, NULL); + if (fkey == NULL || regread) + return fkey; + + idx = 0; + for (;;) { + int err; + size = sizeof (tmp); + size2 = sizeof (tmp2); + err = RegEnumValue(fkey, idx, tmp, &size, NULL, NULL, tmp2, &size2); + if (err != ERROR_SUCCESS) + break; + if (strlen (tmp) == 7) { + idx2 = atol (tmp + 5) - 1; + if (idx2 >= 0) + DISK_history_add (tmp2, idx2); + } + idx++; + } + regread = 1; + return fkey; +} + static void out_floppyspeed (HWND hDlg) { char txt[30]; @@ -4132,10 +4205,9 @@ static void addfloppytype (HWND hDlg, int n) int f_wp = floppybuttons[n][4]; int nn = workprefs.dfxtype[n] + 1; int state, i; - char *s, tmp[1000]; + char *s; HKEY fkey; - DWORD size; - static int regread; + char tmp[1000]; if (nn <= 0) state = FALSE; @@ -4148,31 +4220,9 @@ static void addfloppytype (HWND hDlg, int n) EnableWindow(GetDlgItem(hDlg, f_drive), state); CheckDlgButton(hDlg, f_wp, disk_getwriteprotect (workprefs.df[n]) && state == TRUE ? BST_CHECKED : 0); EnableWindow(GetDlgItem(hDlg, f_wp), state && DISK_validate_filename (workprefs.df[n], 0, 0) ? TRUE : FALSE); + + fkey = read_disk_history (); - RegCreateKeyEx(hWinUAEKey , "DiskImageMRUList", 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_ALL_ACCESS, NULL, &fkey, NULL); - if (!regread) { - char tmp2[1000]; - DWORD size2; - int idx, idx2; - - idx = 0; - for (;;) { - int err; - size = sizeof (tmp); - size2 = sizeof (tmp2); - err = RegEnumValue(fkey, idx, tmp, &size, NULL, NULL, tmp2, &size2); - if (err != ERROR_SUCCESS) - break; - if (strlen (tmp) == 7) { - idx2 = atol (tmp + 5) - 1; - if (idx2 >= 0) - DISK_history_add (tmp2, idx2); - } - idx++; - } - regread = 1; - } SendDlgItemMessage(hDlg, f_text, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(hDlg, f_text, WM_SETTEXT, 0, (LPARAM)workprefs.df[n]); i = 0; @@ -4183,6 +4233,8 @@ static void addfloppytype (HWND hDlg, int n) sprintf (tmp, "Image%02d", i); RegSetValueEx(fkey, tmp, 0, REG_SZ, (CONST BYTE *)s, strlen(s)); } + if (!strcmp (workprefs.df[n], s)) + SendDlgItemMessage (hDlg, f_text, CB_SETCURSEL, i - 1, 0); } if (fkey) RegCloseKey (fkey); @@ -4211,11 +4263,14 @@ static void getfloppyname (HWND hDlg, int n) SendDlgItemMessage (hDlg, f_text, WM_GETTEXT, (WPARAM)sizeof (tmp), (LPARAM)tmp); } else { char *s = DISK_history_get (val); - if (s) + if (s) { strcpy (tmp, s); + /* add to top of list */ + DISK_history_add (tmp, -1); + } } + disk_insert (n, tmp); strcpy (workprefs.df[n], tmp); - strcpy (changed_prefs.df[n], tmp); } static void addallfloppies (HWND hDlg) @@ -4285,7 +4340,40 @@ static BOOL CALLBACK FloppyDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l if (recursive > 0) break; recursive++; - switch (wParam) + if (HIWORD (wParam) == CBN_SELCHANGE) { + switch (LOWORD (wParam)) + { + case IDC_DF0TEXT: + getfloppyname (hDlg, 0); + addfloppytype (hDlg, 0); + break; + case IDC_DF1TEXT: + getfloppyname (hDlg, 1); + addfloppytype (hDlg, 1); + break; + case IDC_DF2TEXT: + getfloppyname (hDlg, 2); + addfloppytype (hDlg, 2); + break; + case IDC_DF3TEXT: + getfloppyname (hDlg, 3); + addfloppytype (hDlg, 3); + break; + case IDC_DF0TYPE: + getfloppytype (hDlg, 0); + break; + case IDC_DF1TYPE: + getfloppytype (hDlg, 1); + break; + case IDC_DF2TYPE: + getfloppytype (hDlg, 2); + break; + case IDC_DF3TYPE: + getfloppytype (hDlg, 3); + break; + } + } + switch (LOWORD (wParam)) { case IDC_DF0WP: floppysetwriteprotect (hDlg, 0, IsDlgButtonChecked (hDlg, IDC_DF0WP)); @@ -4350,14 +4438,6 @@ static BOOL CALLBACK FloppyDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l DiskSelection( hDlg, wParam, 1, &workprefs, 0); break; } - getfloppytype (hDlg, 0); - getfloppytype (hDlg, 1); - getfloppytype (hDlg, 2); - getfloppytype (hDlg, 3); - getfloppyname (hDlg, 0); - getfloppyname (hDlg, 1); - getfloppyname (hDlg, 2); - getfloppyname (hDlg, 3); recursive--; break; @@ -4383,17 +4463,17 @@ static BOOL CALLBACK DiskDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPa { static int recursive = 0; static int entry; - char tmp[256]; + char tmp[MAX_DPATH]; switch (msg) { case WM_INITDIALOG: - pages[DISK_ID] = hDlg; - currentpage = DISK_ID; - InitializeListView(hDlg); - SendMessage( GetDlgItem( hDlg, IDC_UP ), BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hMoveUp ); - SendMessage( GetDlgItem( hDlg, IDC_DOWN ), BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hMoveDown ); - entry = -1; + pages[DISK_ID] = hDlg; + currentpage = DISK_ID; + InitializeListView(hDlg); + SendMessage( GetDlgItem( hDlg, IDC_UP ), BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hMoveUp ); + SendMessage( GetDlgItem( hDlg, IDC_DOWN ), BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hMoveDown ); + entry = -1; break; case WM_COMMAND: { @@ -4417,7 +4497,7 @@ static BOOL CALLBACK DiskDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPa } break; case IDC_DOWN: - if (entry < MAX_SPARE_DRIVES - 1) { + if (entry >= 0 && entry < MAX_SPARE_DRIVES - 1) { strcpy (tmp, workprefs.dfxlist[entry + 1]); strcpy (workprefs.dfxlist[entry + 1], workprefs.dfxlist[entry]); strcpy (workprefs.dfxlist[entry], tmp); @@ -4428,6 +4508,7 @@ static BOOL CALLBACK DiskDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPa } break; } + break; } case WM_NOTIFY: if (((LPNMHDR) lParam)->idFrom == IDC_DISKLIST) @@ -4449,7 +4530,7 @@ static BOOL CALLBACK DiskDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPa if (disk_swap (entry, col)) InitializeListView (hDlg); } else if (col == 1) { - char path[MAX_PATH]; + char path[MAX_DPATH]; if (dblclick && DiskSelection (hDlg, -1, 0, &changed_prefs, path)) { strcpy (workprefs.dfxlist[entry], path); InitializeListView (hDlg); @@ -4672,8 +4753,8 @@ static void values_to_portsdlg (HWND hDlg) if( result < 0 || got == 0) { // Warn the user that their printer-port selection is not valid on this machine - char szMessage[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_INVALIDPRTPORT, szMessage, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_INVALIDPRTPORT, szMessage, MAX_DPATH ); gui_message( szMessage ); // Disable the invalid parallel-port selection @@ -4712,8 +4793,8 @@ static void values_to_portsdlg (HWND hDlg) { if (t > 0) { // Warn the user that their COM-port selection is not valid on this machine - char szMessage[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_INVALIDCOMPORT, szMessage, MAX_PATH ); + char szMessage[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_INVALIDCOMPORT, szMessage, MAX_DPATH ); gui_message( szMessage ); // Select "none" as the COM-port @@ -4817,8 +4898,8 @@ static void init_portsdlg( HWND hDlg ) } else { - char szMidiOut[ MAX_PATH ]; - WIN32GUI_LoadUIString( IDS_DEFAULTMIDIOUT, szMidiOut, MAX_PATH ); + char szMidiOut[ MAX_DPATH ]; + WIN32GUI_LoadUIString( IDS_DEFAULTMIDIOUT, szMidiOut, MAX_DPATH ); SendDlgItemMessage( hDlg, IDC_MIDIOUTLIST, CB_RESETCONTENT, 0, 0L ); SendDlgItemMessage( hDlg, IDC_MIDIOUTLIST, CB_ADDSTRING, 0, (LPARAM)szMidiOut ); @@ -4864,6 +4945,7 @@ static BOOL CALLBACK PortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP init_portsdlg( hDlg ); enable_for_portsdlg( hDlg ); values_to_portsdlg ( hDlg); + UpdatePortRadioButtons( hDlg ); break; case WM_USER: recursive++; @@ -5117,7 +5199,7 @@ static void input_toggleautofire (void) static BOOL CALLBACK InputDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - char name_buf[MAX_PATH] = "", desc_buf[128] = ""; + char name_buf[MAX_DPATH] = "", desc_buf[128] = ""; char *posn = NULL; HWND list; int dblclick = 0; @@ -5487,8 +5569,13 @@ static char aviout_videoc[200], aviout_audioc[200]; static void enable_for_avioutputdlg(HWND hDlg) { +#if defined (PROWIZARD) + EnableWindow( GetDlgItem( hDlg, IDC_PROWIZARD ), TRUE ); +#endif + if (full_property_sheet) + EnableWindow( GetDlgItem( hDlg, IDC_PROWIZARD ), FALSE ); - EnableWindow(GetDlgItem(hDlg, IDC_SCREENSHOT), full_property_sheet ? FALSE : TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_SCREENSHOT), full_property_sheet ? FALSE : TRUE); EnableWindow(GetDlgItem(hDlg, IDC_AVIOUTPUT_PAL), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_AVIOUTPUT_NTSC), TRUE); @@ -5496,33 +5583,32 @@ static void enable_for_avioutputdlg(HWND hDlg) EnableWindow(GetDlgItem(hDlg, IDC_AVIOUTPUT_FILE), TRUE); CheckDlgButton (hDlg, IDC_AVIOUTPUT_FRAMELIMITER, avioutput_framelimiter ? FALSE : TRUE); - if(workprefs.produce_sound < 2) - { - EnableWindow(GetDlgItem(hDlg, IDC_AVIOUTPUT_AUDIO), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_AVIOUTPUT_AUDIO_STATIC), FALSE); - avioutput_audio = 0; - } - else - { - EnableWindow(GetDlgItem(hDlg, IDC_AVIOUTPUT_AUDIO), TRUE); - EnableWindow(GetDlgItem(hDlg, IDC_AVIOUTPUT_AUDIO_STATIC), TRUE); - - } - - if(!avioutput_audio) - { - CheckDlgButton(hDlg, IDC_AVIOUTPUT_AUDIO, BST_UNCHECKED); - WIN32GUI_LoadUIString (IDS_AVIOUTPUT_NOCODEC, aviout_audioc, sizeof (aviout_audioc)); - } - SetWindowText(GetDlgItem(hDlg, IDC_AVIOUTPUT_AUDIO_STATIC), aviout_audioc); + if(workprefs.produce_sound < 2) + { + EnableWindow(GetDlgItem(hDlg, IDC_AVIOUTPUT_AUDIO), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_AVIOUTPUT_AUDIO_STATIC), FALSE); + avioutput_audio = 0; + } + else + { + EnableWindow(GetDlgItem(hDlg, IDC_AVIOUTPUT_AUDIO), TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_AVIOUTPUT_AUDIO_STATIC), TRUE); - if(!avioutput_video) - { - CheckDlgButton(hDlg, IDC_AVIOUTPUT_VIDEO, BST_UNCHECKED); - WIN32GUI_LoadUIString (IDS_AVIOUTPUT_NOCODEC, aviout_videoc, sizeof (aviout_videoc)); - } - SetWindowText(GetDlgItem(hDlg, IDC_AVIOUTPUT_VIDEO_STATIC), aviout_videoc); - + } + + if(!avioutput_audio) + { + CheckDlgButton(hDlg, IDC_AVIOUTPUT_AUDIO, BST_UNCHECKED); + WIN32GUI_LoadUIString (IDS_AVIOUTPUT_NOCODEC, aviout_audioc, sizeof (aviout_audioc)); + } + SetWindowText(GetDlgItem(hDlg, IDC_AVIOUTPUT_AUDIO_STATIC), aviout_audioc); + + if(!avioutput_video) + { + CheckDlgButton(hDlg, IDC_AVIOUTPUT_VIDEO, BST_UNCHECKED); + WIN32GUI_LoadUIString (IDS_AVIOUTPUT_NOCODEC, aviout_videoc, sizeof (aviout_videoc)); + } + SetWindowText(GetDlgItem(hDlg, IDC_AVIOUTPUT_VIDEO_STATIC), aviout_videoc); } static BOOL CALLBACK AVIOutputDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) @@ -5570,6 +5656,11 @@ static BOOL CALLBACK AVIOutputDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM switch(wParam) { +#ifdef PROWIZARD + case IDC_PROWIZARD: + moduleripper (); + break; +#endif case IDC_AVIOUTPUT_ACTIVATED: avioutput_requested = !avioutput_requested; SendMessage(hDlg, WM_HSCROLL, (WPARAM) NULL, (LPARAM) NULL); @@ -5651,7 +5742,7 @@ static BOOL CALLBACK AVIOutputDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM ofn.nMaxCustFilter = 0; ofn.nFilterIndex = 0; ofn.lpstrFile = avioutput_filename; - ofn.nMaxFile = MAX_PATH; + ofn.nMaxFile = MAX_DPATH; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; @@ -5725,7 +5816,9 @@ static HWND updatePanel (HWND hDlg, int id) GetClientRect (GetDlgItem (hDlg, IDC_PANEL_FRAME), &r1c); GetWindowRect (hDlg, &r2w); GetClientRect (hDlg, &r2c); - chwnd = CreateDialogParam (hInst, ppage[id].pp.pszTemplate, hDlg, ppage[id].pp.pfnDlgProc, id); + gui_width = r2c.right; + gui_height = r2c.bottom; + chwnd = CreateDialogParam (hUIDLL ? hUIDLL : hInst, ppage[id].pp.pszTemplate, hDlg, ppage[id].pp.pfnDlgProc, id); GetWindowRect (hDlg, &r3w); GetClientRect (chwnd, &r3c); x = r1w.left - r2w.left; @@ -5864,7 +5957,7 @@ static void centerWindow (HWND hDlg) int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage) { int cnt, i, drv, list; - char file[MAX_PATH]; + char file[MAX_DPATH]; POINT pt; int ret = 0; @@ -5980,11 +6073,11 @@ static BOOL CALLBACK DialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara case IDC_RESETAMIGA: uae_reset (0); SendMessage (hDlg, WM_COMMAND, IDOK, 0); - break; + return TRUE; case IDC_QUITEMU: uae_quit (); SendMessage (hDlg, WM_COMMAND, IDCANCEL, 0); - break; + return TRUE; case IDHELP: if (pHtmlHelp && ppage[currentpage].help) HtmlHelp (NULL, help_file, HH_DISPLAY_TOPIC, ppage[currentpage].help); @@ -6019,8 +6112,8 @@ static int init_page (int tmpl, int icon, int title, LPTSTR lpstrTitle; ppage[id].pp.pszTemplate = MAKEINTRESOURCE (tmpl); ppage[id].pp.pszIcon = MAKEINTRESOURCE (icon); - lpstrTitle = calloc (1, MAX_PATH); - LoadString( hUIDLL, title, lpstrTitle, MAX_PATH ); + lpstrTitle = calloc (1, MAX_DPATH); + LoadString( hUIDLL, title, lpstrTitle, MAX_DPATH ); ppage[id].pp.pszTitle = lpstrTitle; ppage[id].pp.pfnDlgProc = func; ppage[id].help = help; @@ -6039,7 +6132,7 @@ static int GetSettings (int all_options, HWND hwnd) pguiprefs = &currprefs; default_prefs (&workprefs, 0); - WIN32GUI_LoadUIString( IDS_NONE, szNone, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_NONE, szNone, MAX_DPATH ); prefs_to_gui (&changed_prefs); @@ -6075,9 +6168,9 @@ static int GetSettings (int all_options, HWND hwnd) hMoveDown = (HICON)LoadImage( hInst, MAKEINTRESOURCE( IDI_MOVE_DOWN ), IMAGE_ICON, 16, 16, LR_LOADMAP3DCOLORS ); } - if (all_options) + if (all_options || !configstore) CreateConfigStore (); - psresult = DialogBox (hInst, MAKEINTRESOURCE (IDD_PANEL), hwnd, DialogProc); + psresult = DialogBox (hUIDLL ? hUIDLL : hInst, MAKEINTRESOURCE (IDD_PANEL), hwnd, DialogProc); if (quit_program) psresult = -2; @@ -6207,33 +6300,99 @@ void gui_filename (int num, const char *name) { } + +static int fsdialog (HWND *hwnd) +{ + HRESULT hr; + if (gui_active || !isfullscreen ()) + return 0; + hr = DirectDraw_FlipToGDISurface(); + if (hr != DD_OK) { + write_log ("FlipToGDISurface failed, %s\n", DXError (hr)); + return 0; + } + *hwnd = NULL; + return 1; +} + +int gui_message_multibutton (int flags, const char *format,...) +{ + char msg[2048]; + char szTitle[ MAX_DPATH ]; + va_list parms; + int flipflop = 0; + int fullscreen = 0; + int focuso = focus; + int mbflags, ret; + HWND hwnd = guiDlg; + + pause_sound (); + flipflop = fsdialog (&hwnd); + if( flipflop ) + ShowWindow( hAmigaWnd, SW_MINIMIZE ); + + va_start (parms, format); + vsprintf( msg, format, parms ); + va_end (parms); + write_log( msg ); + if (msg[strlen(msg)-1]!='\n') + write_log("\n"); + + WIN32GUI_LoadUIString( IDS_ERRORTITLE, szTitle, MAX_DPATH ); + + mbflags = MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND; + if (flags == 0) + mbflags |= MB_OK; + else if (flags == 1) + mbflags |= MB_YESNO; + else if (flags == 2) + mbflags |= MB_YESNOCANCEL; + ret = MessageBox (hwnd, msg, szTitle, mbflags); + + if( flipflop ) + ShowWindow( hAmigaWnd, SW_RESTORE ); + + resume_sound(); + setmouseactive( focuso ); + if (ret == IDOK) + return 0; + if (ret == IDYES) + return 1; + if (ret == IDNO) + return 2; + if (ret == IDCANCEL) + return -1; + return 0; +} + void gui_message (const char *format,...) { char msg[2048]; - char szTitle[ MAX_PATH ]; + char szTitle[ MAX_DPATH ]; va_list parms; int flipflop = 0; int fullscreen = 0; int focuso = focus; - HWND window = NULL; + HWND hwnd = guiDlg; - if( DirectDraw_GetCooperativeLevel( &window, &fullscreen ) && fullscreen ) - flipflop = 1; pause_sound (); + flipflop = fsdialog (&hwnd); if( flipflop ) - ShowWindow( window, SW_MINIMIZE ); + ShowWindow( hAmigaWnd, SW_MINIMIZE ); va_start (parms, format); vsprintf( msg, format, parms ); va_end (parms); write_log( msg ); + if (msg[strlen(msg)-1]!='\n') + write_log("\n"); - WIN32GUI_LoadUIString( IDS_ERRORTITLE, szTitle, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_ERRORTITLE, szTitle, MAX_DPATH ); - MessageBox( NULL, msg, szTitle, MB_OK | MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND ); + MessageBox (hwnd, msg, szTitle, MB_OK | MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND); if( flipflop ) - ShowWindow( window, SW_RESTORE ); + ShowWindow( hAmigaWnd, SW_RESTORE ); resume_sound(); setmouseactive( focuso ); } @@ -6241,7 +6400,7 @@ void gui_message (const char *format,...) void pre_gui_message (const char *format,...) { char msg[2048]; - char szTitle[ MAX_PATH ]; + char szTitle[ MAX_DPATH ]; va_list parms; va_start (parms, format); @@ -6249,7 +6408,7 @@ void pre_gui_message (const char *format,...) va_end (parms); write_log( msg ); - WIN32GUI_LoadUIString( IDS_ERRORTITLE, szTitle, MAX_PATH ); + WIN32GUI_LoadUIString( IDS_ERRORTITLE, szTitle, MAX_DPATH ); MessageBox( NULL, msg, szTitle, MB_OK | MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND ); diff --git a/od-win32/win32gui.h b/od-win32/win32gui.h index 5fd5a54e..710e9a94 100755 --- a/od-win32/win32gui.h +++ b/od-win32/win32gui.h @@ -44,5 +44,6 @@ extern int DiskSelection( HWND hDlg, WPARAM wParam, int flag, struct uae_prefs * void InitializeListView( HWND hDlg ); extern void pre_gui_message (const char*,...); int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage); +HKEY read_disk_history (void); #endif diff --git a/od-win32/winuae.nsi b/od-win32/winuae.nsi index 89c59d28..4689133b 100755 --- a/od-win32/winuae.nsi +++ b/od-win32/winuae.nsi @@ -15,20 +15,20 @@ InstallDir "$PROGRAMFILES\WinUAE" InstallDirRegKey HKEY_CURRENT_USER "SOFTWARE\Arabuusimiehet\WinUAE" "InstallDir" DirShow show ; (make this hide to not let the user change it) DirText "Select the directory to install WinUAE in:" -Icon "d:\projects\winuae\src\od-win32\resources\winuae.ico" +Icon "c:\projects\winuae\src\od-win32\resources\winuae.ico" WindowIcon on AllowRootDirInstall true AutoCloseWindow true Section "" ; (default section) SetOutPath "$INSTDIR" -File "d:\projects\winuae\distribution\*" +File "c:\projects\winuae\distribution\*" SetOutPath "$INSTDIR\Amiga Programs" -File "d:\projects\winuae\distribution\Amiga Programs\*" +File "c:\projects\winuae\distribution\Amiga Programs\*" SetOutPath "$INSTDIR\Docs" -File "d:\projects\winuae\distribution\Docs\*" +File "c:\projects\winuae\distribution\Docs\*" SetOutPath "$INSTDIR\Docs\Windows" -File "d:\projects\winuae\distribution\Docs\Windows\*" +File "c:\projects\winuae\distribution\Docs\Windows\*" CreateDirectory "$INSTDIR\Configurations" WriteRegStr HKEY_CURRENT_USER "SOFTWARE\Arabuusimiehet\WinUAE" "InstallDir" "$INSTDIR" diff --git a/od-win32/winuae_msvc/winuae_msvc.vcproj b/od-win32/winuae_msvc/winuae_msvc.vcproj index 61ae3e9d..e90bcf3c 100755 --- a/od-win32/winuae_msvc/winuae_msvc.vcproj +++ b/od-win32/winuae_msvc/winuae_msvc.vcproj @@ -23,7 +23,7 @@ AdditionalOptions="" Optimization="0" AdditionalIncludeDirectories="..\..\include,..\..,..\,..\resources,..\osdep,..\sounddep" - PreprocessorDefinitions="WINVER=0x0500,_DEBUG,WIN32,_WINDOWS,ZLIB_DLL,OPENGL_SUPPORT,_WIN32_IE 0x0500 " + PreprocessorDefinitions="WINVER=0x0500,_DEBUG,WIN32,_WINDOWS,ZLIB_DLL,OPENGL_SUPPORT,_WIN32_IE 0x0500,UNIX" ExceptionHandling="FALSE" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -100,7 +100,7 @@ FavorSizeOrSpeed="1" OptimizeForProcessor="2" AdditionalIncludeDirectories="..\..\include,..\..,..\,..\resources,..\osdep,..\sounddep" - PreprocessorDefinitions="WINVER=0x0500,WIN32,NDEBUG,_WINDOWS,ZLIB_DLL,_WIN32_IE 0x0500 " + PreprocessorDefinitions="WINVER=0x0500,WIN32,NDEBUG,_WINDOWS,ZLIB_DLL,_WIN32_IE 0x0500,UNIX" StringPooling="TRUE" ExceptionHandling="FALSE" RuntimeLibrary="0" @@ -458,6 +458,9 @@ + + @@ -542,6 +545,2536 @@ RelativePath="..\..\dms\u_rle.c"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/prowizard/INSTALL b/prowizard/INSTALL new file mode 100755 index 00000000..e18a0c3c --- /dev/null +++ b/prowizard/INSTALL @@ -0,0 +1,20 @@ +Installation +------------ + +This program does not need any special installation process. + +Pro-Wizard-1 (unix) uses DMalloc. You can dl FreeBSD version here : +http://prdownloads.sourceforge.net/dmalloc/ +For Linux, try http://dmalloc.com + +Prowiz.exe (dos) should be compiled with Cygwin32 GCC compiler. +It'll require the file CYGWIN1.DLL. It should be put somewhere in the PATH +(if not present already). +latest version can be found at: +ftp://ftp.uni-erlangen.de/pub/pc/gnuwin32/cygwin/mirrors/cygnus/latest/cygwin/ +or on their Web site +http://www.cygwin.com + +Pro-Wizard-1 (amiga) binary is for 68020 chipsets. Compiling the amiga +version requires at least 8Mb Chip, GCC 2.97.3, ixemul lib and a hell +of a lot of time :). It was compiled under UAE on FreeBSD. \ No newline at end of file diff --git a/prowizard/README b/prowizard/README new file mode 100755 index 00000000..5d44d4a9 --- /dev/null +++ b/prowizard/README @@ -0,0 +1,67 @@ +Prowiz4PC: ProWizard for PC +--------------------------- + + +Description +----------- + +Pro-Wizard-1 (for Peecee) is a multi-ripper for music files. (find the +list in the known formats below). Also, it extracts various data/exe files +like S404 data files. Most of the music formats are 100% Protracker compatible. +The ripped formats are ALL amiga formats ! .. for this version of Pro-Wizard +anyway :). + +Note +---- + +USE THIS PROGRAM ONLY AT YOUR OWN RISK ! +If this program destroys your data I'm interested in finding the bug, +but I'm not responsible for the damages. + +Legal issues +------------ + +The copyright is GNU GPL. See COPYING file. + +Requirements +------------ + +prowiz (cmdline tool): + At this stage, only Linux/FreeBSD are supported. + No MS-DOS/WIN* binary in this package anymore. + Grab the other packages for other archies. + +Behaviour +--------- + +Output, upon finding a known data file, will be 0.extension, 1.extension, etc. . +These extensions are editable in the file "_types_" (default name). Read the +header of this file for specific instructions on how to edit. +At this stage, I still cant guarantee the program wont crash in certain cases. +I fixed anything I've found so far, but .. . If you encounter such a case, +please, send over the data file !. + +Motivation +---------- + +"I wanted to do it myself" is the main motivation :). + +Credits +------- + +ProWizard for PC: +Amiga port: + Sylvain "Asle" Chipaux + asle@free.fr + +Port under *nix: + Michael Doering + mldoering@gmx.net + +And various bug reports: + look in CREDITS file + + +Contact me for any reason. If you think you can help this project to be +more compatible with different platforms, don't hesitate to contact. +Bug reports, EXE/Music amiga formats are also welcome !. diff --git a/prowizard/_types_ b/prowizard/_types_ new file mode 100755 index 00000000..27e2e576 --- /dev/null +++ b/prowizard/_types_ @@ -0,0 +1,389 @@ +############################################################################### +# # +# _types_ : should be part of Pro-Wizard 1 (for PC/Unix/Amiga). # +# # +# # +# # +# 1997-2003 (c) Sylvain "asle" Chipaux # +# # +############################################################################### +# +# Edit the extensions of the known formats +# +# BEWARE: Leave the order the way it is !!. It's fastly coded and I didn't +# want to spend all night on this small thing !. +# Beside the lines with the extensions, there should NOT be any empty +# lines !. Add as many lines as you want, as long as you begin them +# with '#'. +# And last, an extension can be from 2 to 32 chars long. +# +# NOTE: at now, there should be 116 extensions. +# +############################################################################### +# +# list starts now ... +# +############################################################################### +##01 : AC1D packer (AC1D_packer) +ac1d +# +##02 : Sound monitor v2 / v3 (SoundMonitor) +bp +# +##03 : FC-M packer (FC_M_packer) +fc-m +# +##04 : Hornet packer (Hornet_packer) +hrt +# +##05 : KRIS tracker (KRIS_tracker) +kris +# +##06 : OPTIMOD's power music (Power_Music) +PowerMusic +# +##07 : Promizer 1.0c (Promizer_10c) +Promizer10c +# +##08 : Promizer 1.8a (Promizer_18a) +Promizer18a +# +##09 : Promizer 2.0 (Promizer_20) +Promizer20 +# +##10 : ProRunner v1 (ProRunner_v1) +ProRunner1 +# +##11 : ProRunner v2 (ProRunner_v2) +ProRunner2 +# +##12 : SKYT packer (SKYT_packer) +skyt +# +##13 : Wanton packer (Wanton_packer) +WantonPacker +# +##14 : XANN packer (XANN_packer) +xann +# +##15 : Module Protector (Module_protector) +ModuleProtector +# +##16 : Digital Illusion (Digital_illusion) +DigitalIllusion +# +##17 : Pha Packer (Pha_packer) +PhaPacker +# +##18 : Promizer 0.1 (Promizer_01) +Promizer01 +# +##19 : ProPacker 2.1 (Propacker_21) +ProPacker21 +# +##20 : ProPacker 3.0 (Propacker_30) +ProPacker30 +# +##21 : Eureka packer (Eureka_packer) +Eureka +# +##22 : StarTrekker pack (Star_pack) +StarTrekkerPack +# +##23 : Protracker (Protracker) +mod +# +##24 : UNIC tracker v1 (UNIC_v1) +unic1 +# +##25 : UNIC tracker v2 (UNIC_v2) +unic2 +# +##26 : Fuzzac packer (Fuzzac) +Fuzzac +# +##27 : Game music creator (GMC) +gmc +# +##28 : Heatseeker (Heatseeker) +crb +# +##29 : Kefrens sound machine (KSM) +ksm +# +##30 : Noiserunner (Noiserunner) +Noiserunner +# +##31 : NoisePacker v1 (Noisepacker1) +NoisePacker1 +# +##32 : NoisePacker v2 (Noisepacker2) +NoisePacker2 +# +##33 : NoisePacker v3 (Noisepacker3) +NoisePacker3 +# +##34 : The player 4.0A (P40A) +P40A +# +##35 : The player 4.0B (P40B) +P40B +# +##36 : The player 4.1A (P41A) +P41A +# +##37 : Promizer 4.0 (PM40) +Promizer4 +# +##38 : Propacker 1.0 (PP10) +ProPacker1 +# +##39 : Tracker packer 1.0 (TP1) +TrackerPacker1 +# +##40 : Tracker packer 2.0 (TP2) +TrackerPacker2 +# +##41 : Tracker packer 3.0 (TP3) +TrackerPacker3 +# +##42 : Zen packer (ZEN) +ZenPacker +# +##43 : The player 5.0A (P50A) +P50A +# +##44 : The player 6.0A (P60A) +P60A +# +##45 : StarTrekker (StarTrekker) +mod +# +##46 : StoneCracker 4.04 Data (S404) (also S401,S403,S310 and S300) +StoneCrackerData +# +##47 : StoneCracker 2.70 (exe) +StoneCracker270 +# +##48 : The Player 6.1A (P61A) +P61A +# +##49 : STIM_Slamtilt (STIM) +stim +# +##50 : SoundTracker +mod +# +##51 : Tetrapack 2.2 (TPACK22) +TetraPack22 +# +##52 : Crunchmania / Normal (CRM2/CRM!) / Address +CrunchmaniaData +# +##53 : Defjam Cruncher 3.2 / 3.2 pro (Defjam_32) +DefjamCruncher +# +##54 : Tetrapack 2.1 (TPACK21) +Tetrapack21 +# +##55 : IAM Packer 1.0 data +ice +# +##56 : Byte Killer 1.3 / 2.0 / 3.0 and Pro 1.0 +ByteKiller +# +##57 : XPK file +xpk +# +##58 : Imploder (data) +Imploder +# +##59 : Propack (RNC) data +rnc +# +##60 : Double Action 1.0 (exe) (Double_Action) +DoubleAction +# +##61 : Powerpacker 3.0 (exe) (Powerpacker3) +PowerPacker3 +# +##62 : Powerpacker 4.0 (exe) (Powerpacker4 & PP4 library) +PowerPacker4 +# +##63 : Powerpacker 2.3 (exe) (Powerpacker23) +PowerPacker23 +# +##64 : Spike Cruncher (exe) (SpikeCruncher) +SpikeCruncher +# +##65 : Tetrapack 1.02 (exe) (TPACK102) +Tetrapack102 +# +##66 : Time Cruncher 1.7 (exe) (TimeCruncher) +TimeCruncher17 +# +##67 : MasterCruncher +MasterCruncher +# +##68 : Master Cruncher 3.0 address (MasterCruncher) +## Mega Cruncher 1.0 / 1.2 +MegaCruncher +# +##69 : JamCracker / Pro (JamCracker) +jam +# +##70 : BSI Future Composer (BSIFC) +BSI-FC +# +##71 : DigiBooster 1.7 (DigiBooster) +digi +# +##72 : Quadra Composer (QuadraComposer) +qc +# +##73 : The Dark Demon (TDD) +TheDarkDemon +# +##74 : Fuchs Tracker (FuchsTracker) +FuchsTracker +# +##75 : Syncro Packer 4.6 +SynchroPacker46 +# +##76 : TNM Cruncher 1.1 (TNMCruncher) +TNMCruncher11 +# +##77 : Super Cuncher 2.7 (SuperCruncher) +SuperCruncher27 +# +##78 : PPbk (AMOS PowerPacker Bank) (PP20 inside) +PPbk +# +##79 : Relok It 1.0 (RelokIt) +RelokIt1 +# +##80 : StoneCracker 2.92 data +StoneCracker292data +# +##81 : FIRE (RNC clone) Cruncher (data) (FIRE) +fire +# +##82 : Max Packer 1.2 (MaxPacker) +MaxPacker12 +# +##83 : SoundFX 1.3 (SoundFX) +SoundFX13 +# +##84 : arcD Data Cruncher (arcD) +arcD +# +##85 : PARA Data Cruncher (PARA) +para +# +##86 : CRND Data Cruncher (CRND) +crnd +# +##87 : =SB= Data Cruncher (SB_DataCruncher) +-sb- +# +##88 : SF Data Cruncher (SF) +sf +# +##89 : RLE Data Cruncher (RLE) +RLE +# +##90 : Virtual Dreams (VDCO) Data Cruncher (VDCO) +VDC0 +# +##91 : SQ Data Cruncher (SQ) +sq +# +##92 : SP Data Cruncher (SP) +sp +# +##93 : SoundTracker 2.6 (ST2) +ST2 +# +##94 : IceTracker 1.0 (IT1) +IT1 +# +##95 : HQC Cruncher 2.0 (HQC) +HQC +# +##96 : Try-It Cruncher 1.01 (TIC) +TIC +# +##97 : Future Composer 1.0 - 1.3 (FC3) +FC3 +# +##98 : Future Composer 1.4 (FC4) +FC4 +# +##99 : Amnesty Design (1AM) Data Cruncher +1AM +# +##100 : Amnesty Design (2AM) Data Cruncher +2AM +# +##101 : MED / OctaMED (MMD0/MMD1/MMD2/MMD3) +med +# +##102 : Ace? (Cruncher Data) +AceCruncherData +# +##103 : Newtron packer (real name ?) +Newtron +# +##104 : GPMO (Crunch player ?) +GPMO +# +##105 : Polka Packer +PolkaPacker +# +##106 : GnuPlayer +GnuPlayer +# +##107 : -CJ- Data Cruncher +CJ_DataCruncher +# +##108 : AmBk +AmBk +# +##109 : Master Cruncher 3.0 data +MasterCruncher3data +# +##110 : fasttracker 2 +xm +# +##111 : Megacruncher obj +MegaCruncherObj +# +##112 : Turbo Squeezer 6.1 +TurboSqueezer61 +# +##113 : Stonecracker 2.99d +StoneCracker299d +# +##114 : StoneCracker 3.10 +StoneCracker310 +# +##115 : StoneCracker 2.99b +StoneCracker299b +# +##116 : StoneCracker 2.99 +StoneCracker299 +# +##117 : StoneCracker 3.00 +StoneCracker300 +# +##118 : The Player 3.0a +ThePlayer30a +# +##119 : The Player 2.2a +ThePlayer22a +# +##120 : Noise from Heaven +NoiseFromHeaven +# +############################################################################### +############################################################################### \ No newline at end of file diff --git a/prowizard/depack/ac1d.c b/prowizard/depack/ac1d.c new file mode 100755 index 00000000..c988ee03 --- /dev/null +++ b/prowizard/depack/ac1d.c @@ -0,0 +1,205 @@ +/* + * ac1d.c 1996-1997 (c) Asle / ReDoX + * + * Converts AC1D packed MODs back to PTK MODs + * thanks to Gryzor and his ProWizard tool ! ... without it, this prog + * would not exist !!! + * + * Last update: 30/11/99 + * - removed open() (and other fread()s and the like) + * - general Speed & Size Optmizings +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_AC1D ( void ) +{ + Uchar NO_NOTE=0xff; + Uchar c1,c2,c3,c4; + Uchar *Whatever; + Uchar Nbr_Pat; + Uchar poss[37][2]; + Uchar Note,Smp,Fx,FxVal; + long Sample_Data_Address; + long WholeSampleSize=0; + long Pattern_Addresses[128]; + long Pattern_Sizes[128]; + long siztrack1,siztrack2,siztrack3; + long i,j,k; + long Where = PW_Start_Address; + FILE *out; + + if ( Save_Status == BAD ) + return; + + memset (Pattern_Addresses , 0 , 128*4); + BZERO (Pattern_Sizes , 128*4); + + +#ifdef DOS + #include "..\include\ptktable.h" +#endif +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* bypass ID */ + Where += 4; + + Sample_Data_Address = (in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3]; + Where += 4; + /*printf ( "adress of sample datas : %ld\n" , Sample_Data_Address );*/ + + /* write title */ + Whatever = (Uchar *) malloc (1024); + BZERO ( Whatever , 1024 ); + fwrite ( Whatever , 20 , 1 , out ); + + for ( i=0 ; i<31 ; i++ ) + { + fwrite ( Whatever , 22 , 1 , out ); + WholeSampleSize += (((in_data[Where]*256)+in_data[Where+1])*2); + fwrite ( &in_data[Where] , 8 , 1 , out ); + Where += 8; + } + /*printf ( "Whole sample size : %ld\n" , WholeSampleSize );*/ + + /* pattern addresses */ + for ( Nbr_Pat=0 ; Nbr_Pat<128 ; Nbr_Pat++ ) + { + Pattern_Addresses[Nbr_Pat] = (in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3]; + Where += 4; + if ( Pattern_Addresses[Nbr_Pat] == 0 ) + break; + } + Nbr_Pat -= 1; + /*printf ( "Number of pattern saved : %d\n" , Nbr_Pat );*/ + + for ( i=0 ; i<(Nbr_Pat-1) ; i++ ) + { + Pattern_Sizes[i] = Pattern_Addresses[i+1]-Pattern_Addresses[i]; + } + + + /* write number of pattern pos */ + /* write "noisetracker" byte */ + fwrite ( &in_data[PW_Start_Address] , 2 , 1 , out ); + + /* go to pattern table .. */ + Where = PW_Start_Address + 0x300; + + /* pattern table */ + fwrite ( &in_data[Where] , 128 , 1, out ); + Where += 128; + + /* write ID */ + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + + /* pattern data */ + for ( i=0 ; i> 2 ); + Smp |= (( c2 >> 4 ) & 0x0f); + Note = c1 & 0x3f; + if ( Note == 0x3f ) + Note = NO_NOTE; + else if ( Note != 0x00 ) + Note -= 0x0b; + if ( Note == 0x00 ) + Note += 0x01; + Whatever[j*16+k*4] = Smp&0xf0; + if ( Note != NO_NOTE ) + { + Whatever[j*16+k*4] |= poss[Note][0]; + Whatever[j*16+k*4+1] = poss[Note][1]; + } + if ( (c2 & 0x0f) == 0x07 ) + { + Fx = 0x00; + FxVal = 0x00; + Whatever[j*16+k*4+2] = (Smp << 4)&0xf0; + continue; + } + c3 = in_data[Where++]; + Fx = c2 & 0x0f; + FxVal = c3; + Whatever[j*16+k*4+2] = ((Smp<<4)&0xf0); + Whatever[j*16+k*4+2] |= Fx; + Whatever[j*16+k*4+3] = FxVal; + } + } + fwrite ( Whatever , 1024 , 1 , out ); + /*printf ( "+" );*/ + } + free ( Whatever ); + /*printf ( "\n" );*/ + + /* sample data */ + Where = PW_Start_Address + Sample_Data_Address; + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + /* crap ... */ + Crap ( " AC1D Packer " , BAD , BAD , out ); + + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/ambk.c b/prowizard/depack/ambk.c new file mode 100755 index 00000000..dce849b4 --- /dev/null +++ b/prowizard/depack/ambk.c @@ -0,0 +1,150 @@ +/* + * ambk.c mar 2003 (c) Asle / ReDoX + * + * based in Kyz description ... thx !. + * +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_AmBk ( void ) +{ + /*Uchar c1,c2,c3,c4;*/ + Uchar *Whatever,*address; + Uchar poss[37][2]; + /*Uchar Note,Smp,Fx,FxVal;*/ + long i,j,k; + long Where = PW_Start_Address; + long INST_HDATA_ADDY,SONGS_DATA_ADDY,PAT_DATA_ADDY;/*,INST_DATA_ADDY;*/ + long BANK_LEN; + long smps_addys[31],smp_sizes[31]; + FILE *out; + + if ( Save_Status == BAD ) + return; + + +#ifdef DOS + #include "..\include\ptktable.h" +#endif +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + Whatever = (Uchar *) malloc (1024); + BZERO (Whatever,1024); + + BANK_LEN = ((in_data[Where + 0x09]*256*256)+ + (in_data[Where + 0x0a]*256)+ + in_data[Where + 0x0b]) + 0x0c; + + INST_HDATA_ADDY = ((in_data[Where + 0x14]*256*256*256)+ + (in_data[Where + 0x15]*256*256)+ + (in_data[Where + 0x16]*256)+ + in_data[Where + 0x17]) + 0x14; + SONGS_DATA_ADDY = ((in_data[Where + 0x18]*256*256*256)+ + (in_data[Where + 0x19]*256*256)+ + (in_data[Where + 0x1A]*256)+ + in_data[Where + 0x1B]) + 0x14; + PAT_DATA_ADDY = ((in_data[Where + 0x1C]*256*256*256)+ + (in_data[Where + 0x1D]*256*256)+ + (in_data[Where + 0x1E]*256)+ + in_data[Where + 0x1F]) +0x14; + + /* title stuff */ + Where = PW_Start_Address + SONGS_DATA_ADDY; + j = in_data[Where]*256 + in_data[Where+1]; /* number of songs */ + if ( j > 1 ) + { + printf ( "\n!!! unsupported feature in depack_AmBk() - send this file to asle@free.fr !\n" ); + return; + } + j = ((in_data[Where+2]*256*256*256)+(in_data[Where+3]*256*256)+(in_data[Where+4]*256)+in_data[Where+5]); + fwrite ( &in_data[Where + j + 0x0c], 16, 1, out ); + fwrite ( Whatever, 4, 1, out ); + + Where = PW_Start_Address + INST_HDATA_ADDY; + /*printf ( "\naddy of instrument headers : %ld\n", Where );*/ + + /* samples header + data */ + j = (in_data[Where]*256) + in_data[Where+1]; /* nbr of samples */ + /*printf ( "nbr of samples : %ld\n", j );*/ + Where += 2; + for ( i=0 ; i Whatever[256] ) + Whatever[256] = Whatever[i]; + } + fwrite ( Whatever , 128 , 1 , out ); + + /*printf ( "Number of pattern : %d\n" , Whatever[257] );*/ + /*printf ( "Highest pattern number : %d\n" , Whatever[256] );*/ + + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + + Where = k; + for ( i=0 ; i<=Whatever[256] ; i++ ) + { + Pattern_Addresses_Table[i] = (in_data[Where]*256)+in_data[Where+1]; + Where += 2; + } + + for ( i=0 ; i<=Whatever[256] ; i++ ) + { + Where = PW_Start_Address + Pattern_Addresses_Table[i]; + for ( k=0 ; k<256 ; k++ ) /* 256 = 4(voices) * 64(rows) */ + { + Whatever[0] = Whatever[1] = Whatever[2] = Whatever[3] = 0x00; + Whatever[10] = in_data[Where++]; + if ( (Whatever[10] & 0x80) == 0 ) + { + Whatever[11] = in_data[Where++]; + Note = ( ((Whatever[10] << 4) & 0x30) | ( ( Whatever[11]>>4 ) & 0x0f ) ); + Whatever[0] = poss[Note][0]; + Whatever[1] = poss[Note][1]; + Smp = (Whatever[10] >> 2) & 0x1f; + Whatever[0] |= (Smp & 0xf0); + Whatever[2] = (Smp << 4) & 0xf0; + Fx = Whatever[11] & 0x0f; + Whatever[2] |= Fx; + FxVal = 0x00; + Whatever[3] = FxVal; + fwrite ( Whatever , 4 , 1 , out ); + continue; + } + if ( Whatever[10] == 0xff ) + { + Whatever[0] = Whatever[1] = Whatever[2] = Whatever[3] = 0x00; + fwrite ( Whatever , 4 , 1 , out ); + continue; + } + Whatever[11] = in_data[Where++]; + Whatever[12] = in_data[Where++]; + Note = ( ((Whatever[10] << 4) & 0x30) | ( (Whatever[11] >> 4) & 0x0f ) ); + Whatever[0] = poss[Note][0]; + Whatever[1] = poss[Note][1]; + Smp = (Whatever[10] >> 2) & 0x1f; + Whatever[0] |= (Smp & 0xf0); + Whatever[2] = (Smp << 4) & 0xf0; + Fx = Whatever[11] & 0x0f; + Whatever[2] |= Fx; + FxVal = Whatever[12]; + Whatever[3] = FxVal; + fwrite ( Whatever , 4 , 1 , out ); + } + } + free ( Whatever ); + + + Where = PW_Start_Address + Add_Sample_Data; + fwrite ( &in_data[Where] , Total_Sample_Size , 1 , out ); + + Crap ( " Digital Illusion " , BAD , BAD , out ); + + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ + +} diff --git a/prowizard/depack/eureka.c b/prowizard/depack/eureka.c new file mode 100755 index 00000000..85c3fbf8 --- /dev/null +++ b/prowizard/depack/eureka.c @@ -0,0 +1,150 @@ +/* + * EurekaPacker.c 1997 (c) Asle / ReDoX + * + * Converts MODs packed with Eureka packer back to ptk + * + * Last update: 30/11/99 + * - removed open() (and other fread()s and the like) + * - general Speed & Size Optmizings +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_EUREKA ( void ) +{ + Uchar *Whatever; + Uchar c1=0x00; + Uchar Pat_Max=0x00; + long Sample_Start_Address=0; + long WholeSampleSize=0; + long Track_Address[128][4]; + long i=0,j=0,k; + long Where = PW_Start_Address; + FILE *out; + + if ( Save_Status == BAD ) + return; + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* read header ... same as ptk */ + fwrite ( &in_data[Where] , 1080 , 1 , out ); + + /* now, let's sort out that a bit :) */ + /* first, the whole sample size */ + for ( i=0 ; i<31 ; i++ ) + WholeSampleSize += (((in_data[Where+i*30+42]*256)+in_data[Where+i*30+43])*2); + /*printf ( "Whole sample size : %ld\n" , WholeSampleSize );*/ + + /* next, the size of the pattern list */ + /*printf ( "Size of pattern list : %d\n" , in_data[Where+950] );*/ + + /* now, the pattern list .. and the max */ + Pat_Max = 0x00; + for ( i=0 ; i<128 ; i++ ) + { + if ( in_data[Where+952+i] > Pat_Max ) + Pat_Max = in_data[Where+952+i]; + } + Pat_Max += 1; + /*printf ( "Number of patterns : %d\n" , Pat_Max );*/ + + /* write ptk's ID */ + Whatever = (Uchar *) malloc (1024); + BZERO ( Whatever , 1024 ); + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + + /* read sample data address */ + Where = PW_Start_Address+1080; + Sample_Start_Address = (in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3]; + Where += 4; + /*printf ( "Address of sample data : %ld\n" , Sample_Start_Address );*/ + + /* read tracks addresses */ + for ( i=0 ; i Whatever[129] ) + Whatever[129] = in_data[Where]; + Where += 1; + } + fwrite ( Whatever , 128 , 1 , out ); + /*printf ( "Number of pattern : %d\n" , Whatever[129] + 1 );*/ + + /* write ptk's ID */ + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* bypass "SONG" chunk */ + Where += 4; + + /* pattern data */ + for ( i=0 ; i<=Whatever[129] ; i++ ) + { + fwrite ( &in_data[Where] , 1024 , 1 , out ); + Where += 1024; + /*printf ( "+" );*/ + } + free ( Whatever ); + /*printf ( "\n" );*/ + + + /* bypass "SAMP" chunk */ + Where += 4; + + /* sample data */ + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + /* crap */ + Crap ( " FC-M packer " , BAD , BAD , out ); + + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/fuchs.c b/prowizard/depack/fuchs.c new file mode 100755 index 00000000..efe7df75 --- /dev/null +++ b/prowizard/depack/fuchs.c @@ -0,0 +1,245 @@ +/* + * FuchsTracker.c 1999 (c) Sylvain "Asle" Chipaux + * + * Depacks Fucks Tracker modules + * + * Last update: 30/11/99 + * - removed open() (and other fread()s and the like) + * - general Speed & Size Optmizings + * - small bug correction with loops (thx to Thomas Neumann + * for pointing this out !) + * Another update : 23 nov 2003 + * - used htonl() so that use of addy is now portable on 68k archs +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_FuchsTracker ( void ) +{ + Uchar *Whatever; + Uchar c1=0x00; + long WholeSampleSize=0; + long SampleSizes[16]; + long LoopStart[16]; + unsigned long i=0,j=0,k; + long Where = PW_Start_Address; + FILE *out; + + if ( Save_Status == BAD ) + return; + + BZERO ( SampleSizes , 16*4 ); + BZERO ( LoopStart , 16*4 ); + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* write empty ptk header */ + Whatever = (Uchar *) malloc ( 1080 ); + BZERO ( Whatever , 1080 ); + fwrite ( Whatever , 1080 , 1 , out ); + + /* write title */ + fseek ( out , 0 , 0 ); + fwrite ( &in_data[Where] , 10 , 1 , out ); + Where += 10; + + /* read all sample data size */ + WholeSampleSize = ((in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3] ); + Where += 4; +/* printf ( "Whole Sample Size : %ld\n" , WholeSampleSize );*/ + + + /* read/write sample sizes */ + /* have to halve these :( */ + for ( i=0 ; i<16 ; i++ ) + { + fseek ( out , 42+i*30 , 0 ); + Whatever[0] = in_data[Where]; + Whatever[1] = in_data[Where+1]; + SampleSizes[i] = (Whatever[0]*256)+Whatever[1]; + Whatever[1] /= 2; + if ( (Whatever[0]/2)*2 != Whatever[0] ) + { + if ( Whatever[1] < 0x80 ) + Whatever[1] += 0x80; + else + { + Whatever[1] -= 0x80; + Whatever[0] += 0x01; + } + } + Whatever[0] /= 2; + fwrite ( Whatever , 2 , 1 , out ); + Where += 2; + } + + /* read/write volumes */ + for ( i=0 ; i<16 ; i++ ) + { + fseek ( out , 45+i*30 , 0 ); + Where += 1; + fwrite ( &in_data[Where++] , 1 , 1 , out ); + } + + /* read/write loop start */ + /* have to halve these :( */ + for ( i=0 ; i<16 ; i++ ) + { + fseek ( out , 46+i*30 , 0 ); + Whatever[0] = in_data[Where]; + Whatever[1] = in_data[Where+1]; + LoopStart[i] = (Whatever[0]*256)+Whatever[1]; + Whatever[1] /= 2; + if ( (Whatever[0]/2)*2 != Whatever[0] ) + { + if ( Whatever[1] < 0x80 ) + Whatever[1] += 0x80; + else + { + Whatever[1] -= 0x80; + Whatever[0] += 0x01; + } + } + Whatever[0] /= 2; + fwrite ( Whatever , 2 , 1 , out ); + Where += 2; + } + + /* write replen */ + /* have to halve these :( */ + Whatever[128] = 0x01; + for ( i=0 ; i<16 ; i++ ) + { + fseek ( out , 48+i*30 , 0 ); + j = SampleSizes[i] - LoopStart[i]; + if ( (j == 0) || (LoopStart[i] == 0) ) + { + fwrite ( &Whatever[127] , 2 , 1 , out ); + continue; + } + + j /= 2; + /* use of htonl() suggested by Xigh !.*/ + k = htonl(j); + Whatever[0] = *((Uchar *)&k+2); + Whatever[1] = *((Uchar *)&k+3); + fwrite ( Whatever , 2 , 1 , out ); + } + + + /* fill replens up to 31st sample wiz $0001 */ + Whatever[49] = 0x01; + for ( i=16 ; i<31 ; i++ ) + { + fseek ( out , 48+i*30 , 0 ); + fwrite ( &Whatever[48] , 2 , 1 , out ); + } + + /* that's it for the samples ! */ + /* now, the pattern list */ + + /* read number of pattern to play */ + fseek ( out , 950 , 0 ); + /* bypass empty byte (saved wiz a WORD ..) */ + Where += 1; + fwrite ( &in_data[Where++] , 1 , 1 , out ); + + /* write ntk byte */ + Whatever[0] = 0x7f; + fwrite ( Whatever , 1 , 1 , out ); + + /* read/write pattern list */ + for ( i=0 ; i<40 ; i++ ) + { + Where += 1; + fwrite ( &in_data[Where++] , 1 , 1 , out ); + } + + + /* write ptk's ID */ + fseek ( out , 0 , 2 ); + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + + + /* now, the pattern data */ + + /* bypass the "SONG" ID */ + Where += 4; + + /* read pattern data size */ + j = ((in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3] ); + Where += 4; + + /* read pattern data */ + free ( Whatever ); + Whatever = (Uchar *) malloc ( j ); + + /* convert shits */ + for ( i=0 ; i= 16) && (c1 <= 25) ) { Whatever[i+3] = (c1-6); continue; } + if ( (c1 >= 32) && (c1 <= 41) ) { Whatever[i+3] = (c1-12); continue; } + if ( (c1 >= 48) && (c1 <= 57) ) { Whatever[i+3] = (c1-18); continue; } + if ( (c1 >= 64) && (c1 <= 73) ) { Whatever[i+3] = (c1-24); continue; } + if ( (c1 >= 80) && (c1 <= 89) ) { Whatever[i+3] = (c1-30); continue; } + if ( (c1 >= 96) && (c1 <= 100)) { Whatever[i+3] = (c1-36); continue; } +/* printf ( "error:vol arg:%x (at:%ld)\n" , c1 , i+200 );*/ + } + } + + /* write pattern data */ + fwrite ( Whatever , j , 1 , out ); + free ( Whatever ); + + /* read/write sample data */ + Where += 4; + for ( i=0 ; i<16 ; i++ ) + { + if ( SampleSizes[i] != 0 ) + { + fwrite ( &in_data[Where] , SampleSizes[i] , 1 , out ); + Where += SampleSizes[i]; + } + } + + + /* crap */ + Crap ( " Fuchs Tracker " , BAD , BAD , out ); + + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/fuzzac.c b/prowizard/depack/fuzzac.c new file mode 100755 index 00000000..93144728 --- /dev/null +++ b/prowizard/depack/fuzzac.c @@ -0,0 +1,262 @@ +/* + * fuzzac.c 1997 (c) Asle / ReDoX + * + * Converts Fuzzac packed MODs back to PTK MODs + * thanks to Gryzor and his ProWizard tool ! ... without it, this prog + * would not exist !!! + * + * Note: A most worked-up prog ... took some time to finish this !. + * there's what lot of my other depacker are missing : the correct + * pattern order (most of the time the list is generated badly ..). + * Dont know why I did it for this depacker because I've but one + * exemple file ! :). + * + * Last update: 30/11/99 + * - removed open() (and other fread()s and the like) + * - general Speed & Size Optmizings + * - memory leak bug corrected (thx to Thomas Neumann) + * - SEnd ID bypassed REALLY now :) (Thomas Neumann again !) +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +#define ON 1 +#define OFF 2 + + +void Depack_Fuzzac ( void ) +{ + Uchar c5; + Uchar PatPos; + Uchar *Whatever; + Uchar NbrTracks; + Uchar Track_Numbers[128][16]; + Uchar Track_Numbers_Real[128][4]; + Uchar Track_Datas[4][256]; + Uchar Status=ON; + long WholeSampleSize=0; + long i,j,k,l; + long Where = PW_Start_Address; + FILE *out; + + if ( Save_Status == BAD ) + return; + + BZERO ( Track_Numbers , 128*16 ); + BZERO ( Track_Numbers_Real , 128*4 ); + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* bypass ID */ + /* bypass 2 unknown bytes */ + Where += 6; + + /* write title */ + Whatever = (Uchar *) malloc (1024); + BZERO ( Whatever , 1024 ); + fwrite ( Whatever , 20 , 1 , out ); + + /*printf ( "Converting header ... " );*/ + /*fflush ( stdout );*/ + for ( i=0 ; i<31 ; i++ ) + { + /*sample name*/ + fwrite ( &in_data[Where] , 22 , 1 , out ); + + WholeSampleSize += (((in_data[Where+60]*256)+in_data[Where+61])*2); + fwrite ( &in_data[Where+60] , 2 , 1 , out ); + fwrite ( &in_data[Where+66] , 2 , 1 , out ); + fwrite ( &in_data[Where+62] , 2 , 1 , out ); + + Whatever[0] = in_data[Where+65]; + if ( (in_data[Where+64]==0x00) && (in_data[Where+65]==0x00) ) + Whatever[0] = 0x01; + fwrite ( &in_data[Where+64] , 1 , 1 , out ); + fwrite ( Whatever , 1 , 1 , out ); + Where += 68; + } + /*printf ( "ok\n" );*/ + /*printf ( " - Whole sample size : %ld\n" , WholeSampleSize );*/ + + /* read & write size of pattern list */ + PatPos = in_data[Where++]; + fwrite ( &PatPos , 1 , 1 , out ); + /*printf ( " - size of pattern list : %d\n" , PatPos );*/ + + /* read the number of tracks */ + NbrTracks = in_data[Where++]; + + /* write noisetracker byte */ + Whatever[0] = 0x7f; + fwrite ( Whatever , 1 , 1 , out ); + + + /* place file pointer at track number list address */ + Where = PW_Start_Address + 2118; + + /* read tracks numbers */ + for ( i=0 ; i<4 ; i++ ) + { + for ( j=0 ; j Max ) + Max = Whatever[i]; + } + /*printf ( "ok\n" );*/ + + + /* write ID */ + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + + /* pattern data */ + /*printf ( "Converting pattern datas " );*/ + Where = PW_Start_Address + 444; + for ( i=0 ; i<=Max ; i++ ) + { + BZERO ( Whatever , 1024 ); + for ( j=0 ; j<1024 ; j++ ) Whatever[j] = in_data[Where++]; + for ( j=0 ; j<256 ; j++ ) + { + switch ( Whatever[(j*4)+2]&0x0f ) + { + case 3: /* replace by C */ + Whatever[(j*4)+2] += 0x09; + break; + case 4: /* replace by D */ + Whatever[(j*4)+2] += 0x09; + break; + case 5: /* replace by B */ + Whatever[(j*4)+2] += 0x06; + break; + case 6: /* replace by E0 */ + Whatever[(j*4)+2] += 0x08; + break; + case 7: /* replace by E0 */ + Whatever[(j*4)+2] += 0x07; + break; + case 8: /* replace by F */ + Whatever[(j*4)+2] += 0x07; + break; + default: + break; + } + } + fwrite ( Whatever , 1024 , 1 , out ); + /*printf ( "." );*/ + /*fflush ( stdout );*/ + } + free ( Whatever ); + /*printf ( " ok\n" );*/ + /*fflush ( stdout );*/ + + /* sample data */ + /*printf ( "Saving sample data ... " );*/ + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + /*printf ( "ok\n" );*/ + /*fflush ( stdout );*/ + + /* crap */ + Crap ( "Game Music Creator" , BAD , BAD , out ); + + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/gnpl.c b/prowizard/depack/gnpl.c new file mode 100755 index 00000000..b0df6cfc --- /dev/null +++ b/prowizard/depack/gnpl.c @@ -0,0 +1,269 @@ +/* + * GnuPlayer.c 2003 (c) Asle@free.fr + * +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +#define MAXI(a,b) (a>b?a:b) + +void Depack_GnuPlayer ( void ) +{ + Uchar *Whatever; + long i=0,j=0,k=0,l=0; + long Where = PW_Start_Address; + Uchar * Pattern; + Uchar poss[37][2]; + FILE *out;/*,*info;*/ + long SizOfTrack,len1,len2; + long SmpSizes[31]; + long NbrSmp = 0; + short SfxNbr=0; + + if ( Save_Status == BAD ) + return; + + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + /*info = fopen ( "info", "w+b" );*/ + + /* read and write title */ + fwrite ( &in_data[Where] , 20 , 1 , out ); + + /* get global sample rate */ + /* + for ( SmpRate=0x00 ; i<37 ; SmpRate+=0x01 ) + if ( (poss[SmpRate][0] == in_data[Where + 0x90]) && (poss[SmpRate][1] == in_data[Where + 0x91])) + break; + */ + + /*take care of pattern right now*/ + Pattern = (Uchar *) malloc (65536); + BZERO (Pattern, 65536); + Where = PW_Start_Address + 0x96; + /* track 1 & 2 */ + SizOfTrack = (in_data[Where]*256) + in_data[Where+1]; /* size of track 1 */ + /*fprintf ( info, "Size of track 1 : %ld (%x)\n", SizOfTrack,SizOfTrack );*/ + Where += 2; len1=0;l=0; + for ( i=0 ; i>4)&0x0f; + if ( samp & 0x08 ) samp -= 0x10; + Whatever[k++] = Whatever[k-1] + samp; + samp = in_data[Where] & 0x0f; + if ( samp & 0x08 ) samp -= 0x10; + Whatever[k++] = Whatever[k-1] + samp; + Where += 1; + } + Where -= 1; + fwrite ( &Whatever[0], out_end, 1, out ); + } + free ( Whatever ); + + /* crap */ + Crap ( " GnuPlayer " , BAD , BAD , out ); + + fflush ( out ); + fclose ( out ); + /*fclose ( info );*/ + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/gpmo.c b/prowizard/depack/gpmo.c new file mode 100755 index 00000000..c106c724 --- /dev/null +++ b/prowizard/depack/gpmo.c @@ -0,0 +1,83 @@ +/* + * gpmo.c 2003 (c) Asle / ReDoX + * + * Converts GPMO MODs back to PTK + * +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_GPMO ( void ) +{ + Uchar *Whatever; + Uchar Max=0x00; + long WholeSampleSize=0; + long i=0; + long Where=PW_Start_Address; + FILE *out; + + if ( Save_Status == BAD ) + return; + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* get whole sample size and patch vols (/2)*/ + for ( i=0 ; i<31 ; i++ ) + { + WholeSampleSize += (((in_data[Where+42+i*30]*256)+in_data[Where+43+i*30])*2); + in_data[Where+45+i*30] = in_data[Where+45+i*30]/2; + } + /*printf ( "Whole sanple size : %ld\n" , WholeSampleSize );*/ + + /* read and write whole header */ + fwrite ( &in_data[Where] , 1080 , 1 , out ); + + Where += 952; + + /* write ID */ + Whatever = (Uchar *) malloc (4); + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + free ( Whatever ); + + /* get number of pattern */ + Max = 0x00; + for ( i=0 ; i<128 ; i++ ) + { + if ( in_data[Where+i] > Max ) + Max = in_data[Where+i]; + } + /*printf ( "Number of pattern : %d\n" , Max );*/ + + /* pattern data */ + Where = PW_Start_Address + 1084; + fwrite ( &in_data[Where], (Max+1)*1024, 1, out); + Where += ((Max+1)*1024); + + /* sample data */ + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + /* crap */ + Crap ( " GPMO " , BAD , BAD , out ); + + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} + diff --git a/prowizard/depack/heatseek.c b/prowizard/depack/heatseek.c new file mode 100755 index 00000000..d7453a64 --- /dev/null +++ b/prowizard/depack/heatseek.c @@ -0,0 +1,175 @@ +/* + * Heatseeker_mc1.0.c 1997 (c) Asle / ReDoX + * + * Converts back to ptk Heatseeker packed MODs + * + * Note: There's a good job ! .. gosh !. + * + * Last update: 30/11/99 + * - removed open() (and other fread()s and the like) + * - general Speed & Size Optmizings +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_HEATSEEKER ( void ) +{ + Uchar c1=0x00,c2=0x00,c3=0x00,c4=0x00; + Uchar Pat_Max=0x00; + Uchar *Whatever; + long Track_Addresses[512]; + long i=0,j=0,k=0,l=0,m; + long WholeSampleSize=0; + long Where = PW_Start_Address; + FILE *out; + + if ( Save_Status == BAD ) + return; + + BZERO ( Track_Addresses , 512*4 ); + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* write title */ + Whatever = (Uchar *) malloc (1024); + BZERO ( Whatever , 1024 ); + fwrite ( Whatever , 20 , 1 , out ); + + /* read and write sample descriptions */ + for ( i=0 ; i<31 ; i++ ) + { + /*sample name*/ + fwrite ( Whatever , 22 , 1 , out ); + + WholeSampleSize += (((in_data[Where]*256)+in_data[Where+1])*2); + fwrite ( &in_data[Where] , 6 , 1 , out ); + Whatever[32] = in_data[Where+6]; + Whatever[33] = in_data[Where+7]; + if ( (Whatever[32] == 0x00) && (Whatever[33] == 0x00) ) + Whatever[33] = 0x01; + fwrite ( &Whatever[32] , 2 , 1 , out ); + Where += 8; + } + /*printf ( "Whole sample size : %ld\n" , WholeSampleSize );*/ + + /* read and write pattern table lenght */ + /* read and write NoiseTracker byte */ + fwrite ( &in_data[Where] , 2 , 1 , out ); + Where += 2; + + /* read and write pattern list and get highest patt number */ + for ( i=0 ; i<128 ; i++ ) + { + Whatever[i] = in_data[Where++]; + if ( Whatever[i] > Pat_Max ) + Pat_Max = Whatever[i]; + } + fwrite ( Whatever , 128 , 1 , out ); + Pat_Max += 1; + /*printf ( "Number of pattern : %d\n" , Pat_Max );*/ + + /* write ptk's ID */ + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* pattern data */ + for ( i=0 ; i Max ) + Max = in_data[Where+i]; + } + /*printf ( "Number of pattern : %d\n" , Max );*/ + + /* write ptk's ID */ + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* pattern data */ + Where = PW_Start_Address + 1084; + for ( i=0 ; i<=Max ; i++ ) + { + for ( j=0 ; j<256 ; j++ ) + { + Whatever[0] = in_data[Where]; + Whatever[1] = in_data[Where+1]; + Whatever[2] = in_data[Where+2]; + Whatever[3] = in_data[Where+3]; + Whatever[0] /= 2; + Whatever[16] = Whatever[0] & 0xf0; + if ( Whatever[1] == 0x00 ) + Whatever[17] = 0x00; + else + { + Whatever[16] |= poss[(Whatever[1]/2)][0]; + Whatever[17] = poss[(Whatever[1]/2)][1]; + } + Whatever[18] = (Whatever[0]<<4)&0xf0; + Whatever[18] |= Whatever[2]; + Whatever[19] = Whatever[3]; + + fwrite ( &Whatever[16] , 4 , 1 , out ); + Where += 4; + } + } + free ( Whatever ); + + /* sample data */ + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + /* crap */ + Crap ( " Hornet Packer " , BAD , BAD , out ); + + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} + diff --git a/prowizard/depack/kris.c b/prowizard/depack/kris.c new file mode 100755 index 00000000..94143425 --- /dev/null +++ b/prowizard/depack/kris.c @@ -0,0 +1,240 @@ +/* + * Kris_packer.c 1997-2000 (c) Asle / ReDoX + * + * Kris Tracker to Protracker. + * + * Update: 28/11/1999 + * - removed fopen() + * - Overall Speed and Size optimizings. + * Update: 03/04/2000 + * - no more sample beginning with $01 :) (Thomas Neumann again ... thx) + * Update: 20/12/2000 + * - major debugging around the patterntable ... +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_KRIS ( void ) +{ + Uchar *Whatever; + Uchar c1=0x00,c2=0x00; + Uchar poss[37][2]; + Uchar Max=0x00; + Uchar Note,Smp,Fx,FxVal; + Uchar TrackData[512][256]; + Uchar PatternTableSize=0x00; + Uchar PatternTable[128]; + short TrackAddressTable[128][4]; + long i=0,j=0,k=0; + long WholeSampleSize=0; + long Where = PW_Start_Address; + short MaxTrackAddress=0; + FILE *out; /*,*debug;*/ + + if ( Save_Status == BAD ) + return; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef DOS + #include "../include/ptktable.h" +#endif + + BZERO ( TrackAddressTable , 128*4*2 ); + BZERO ( TrackData , 512*256 ); + BZERO ( PatternTable , 128 ); + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; +/* debug = fopen ( "debug" , "w+b" );*/ + + /* title */ + fwrite ( &in_data[Where] , 20 , 1 , out ); + Where += 22; /* 20 + 2 */ + + /* 31 samples */ + Whatever = (Uchar *) malloc (1024); + BZERO (Whatever , 1024); + for ( i=0 ; i<31 ; i++ ) + { + /* sample name,siz,fine,vol */ + if ( in_data[Where] == 0x01 ) + { + fwrite ( Whatever , 20 , 1 , out ); + fwrite ( &in_data[Where+20] , 6 , 1 , out ); + } + else + fwrite ( &in_data[Where] , 26 , 1 , out ); + + /* size */ + WholeSampleSize += (((in_data[Where+22]*256)+in_data[Where+23])*2); + + /* loop start */ + c1 = in_data[Where+26]/2; + c2 = in_data[Where+27]/2; + if ( (c1*2) != in_data[Where+26] ) + c2 += 1; + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + + /* loop size */ + fwrite ( &in_data[Where+28] , 2 , 1 , out ); + + Where += 30; + } + /*printf ( "Whole sample size : %ld\n" , WholeSampleSize );*/ + + /* bypass ID "KRIS" */ + Where += 4; + + /* number of pattern in pattern list */ + /* Noisetracker restart byte */ + PatternTableSize = in_data[Where]; + fwrite ( &in_data[Where] , 2 , 1 , out ); + Where += 2; + + /* pattern table (read,count and write) */ + c1 = 0x00; + k=0; + for ( i=0 ; i<128 ; i++ , k++ ) + { +/*fprintf ( debug , "%-2ld" , i );*/ + for ( j=0 ; j<4 ; j++ ) + { + TrackAddressTable[k][j]= (in_data[Where]*256)+in_data[Where+1]; + if ( TrackAddressTable[k][j] > MaxTrackAddress ) + MaxTrackAddress = TrackAddressTable[k][j]; + Where += 2; +/*fprintf ( debug , "- %4d" , TrackAddressTable[k][j] );*/ + } +/*fprintf ( debug , "\n" );*/ + for ( j=0 ; j patterntable[%ld] : %ld\n" , i , PatternTable[i] );*/ + k-=1; + j = 9999l; /* hum ... sure now ! */ + break; + } +/*fprintf ( debug , "\n" );*/ + } + if ( k == j ) + { + PatternTable[i] = c1; + c1 += 0x01; +/*fprintf ( debug , "---> patterntable[%ld] : %d\n" , i , PatternTable[i] );*/ + } + fwrite ( &PatternTable[i] , 1 , 1 , out ); + } + + Max = c1; + /*printf ( "Number of patterns : %d\n" , Max );*/ + + /* ptk ID */ + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* bypass two unknown bytes */ + Where += 2; + + /* Track data ... */ + for ( i=0 ; i<=(MaxTrackAddress/256) ; i+=1 ) + { + BZERO ( Whatever , 1024 ); + for ( j=0 ; j<256 ; j++ ) + Whatever[j] = in_data[Where+j]; + Where += 256; + + for ( j=0 ; j<64 ; j++ ) + { + Note = Whatever[j*4]; + Smp = Whatever[j*4+1]; + Fx = Whatever[j*4+2] & 0x0f; + FxVal = Whatever[j*4+3]; + + TrackData[i][j*4] = (Smp & 0xf0); + /*if ( (Note < 0x46) || (Note > 0xa8) )*/ + /*printf ( "!! Note value : %x (beside ptk 3 octaves limit)\n" , Note );*/ + + if ( Note != 0xa8 ) + { + TrackData[i][j*4] |= poss[(Note/2)-35][0]; + TrackData[i][j*4+1] |= poss[(Note/2)-35][1]; + } + TrackData[i][j*4+2] = (Smp<<4)&0xf0; + TrackData[i][j*4+2] |= (Fx & 0x0f); + TrackData[i][j*4+3] = FxVal; + } + } + + for ( i=0 ; i Max ) + Max = Track_Numbers[PatPos][0]; + if ( Track_Numbers[PatPos][1] > Max ) + Max = Track_Numbers[PatPos][1]; + if ( Track_Numbers[PatPos][2] > Max ) + Max = Track_Numbers[PatPos][2]; + if ( Track_Numbers[PatPos][3] > Max ) + Max = Track_Numbers[PatPos][3]; + } + + /* write patpos */ + fwrite ( &PatPos , 1 , 1 , out ); + + /* ntk byte */ + c1 = 0x7f; + fwrite ( &c1 , 1 , 1 , out ); + + /* sort tracks numbers */ + c5 = 0x00; + for ( i=0 ; i Whatever[32] ) + Whatever[32] = in_data[Where+i]; + } + fwrite ( &in_data[Where] , 128 , 1 , out ); + Where += 128; + /*printf ( "Number of pattern : %d\n" , Max+1 );*/ + + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* bypass 4 unknown empty bytes */ + if ( (in_data[Where]==0x00)&&(in_data[Where+1]==0x00)&&(in_data[Where+2]==0x00)&&(in_data[Where+3]==0x00) ) + Where += 4; + /*else*/ + /*printf ( "! four empty bytes bypassed at the beginning of the pattern data\n" );*/ + + /* pattern data */ + i = (Whatever[32]+1)*1024; + fwrite ( &in_data[Where] , i , 1 , out ); + Where += i; + free ( Whatever ); + + /* sample data */ + fwrite ( &in_data[Where] , Total_Sample_Size , 1 , out ); + + Crap ( " Module Protector " , BAD , BAD , out ); + + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/newtron.c b/prowizard/depack/newtron.c new file mode 100755 index 00000000..de06f026 --- /dev/null +++ b/prowizard/depack/newtron.c @@ -0,0 +1,91 @@ +/* + * newtron.c 2003 (c) Asle / ReDoX + * + * Converts Newtron packed MODs back to PTK MODs + * + * Last update: 09 mar 2003 +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_Newtron ( void ) +{ + Uchar *Whatever; + long i=0; + long Total_Sample_Size=0; + long Where = PW_Start_Address; + FILE *out; + + if ( Save_Status == BAD ) + return; + + Whatever = (Uchar *) malloc (64); + BZERO ( Whatever , 64 ); + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + if (!out) + return; + out = mr_fopen ( Depacked_OutName , "w+b" ); + + /* title */ + fwrite ( Whatever , 20 , 1 , out ); + + Where = 4; + + for ( i=0 ; i<31 ; i++ ) + { + /*sample name*/ + fwrite ( Whatever , 22 , 1 , out ); + + Total_Sample_Size += (((in_data[Where]*256)+in_data[Where+1])*2); + fwrite ( &in_data[Where] , 8 , 1 , out ); + Where += 8; + } + /*printf ( "Whole sample size : %ld\n" , Total_Sample_Size );*/ + + /* pattern table lenght & Ntk byte */ + fwrite ( &in_data[0] , 1 , 1 , out ); + Whatever[0] = 0x7f; + fwrite ( &Whatever[0] , 1 , 1 , out ); + + Whatever[32] = 0x00; + for ( i=0 ; i<128 ; i++ ) + { + if ( in_data[Where+i] > Whatever[32] ) + Whatever[32] = in_data[Where+i]; + } + fwrite ( &in_data[Where] , 128 , 1 , out ); + Where += 128; + /*printf ( "Number of pattern : %d\n" , Max+1 );*/ + + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* pattern data */ + i = (Whatever[32]+1)*1024; + fwrite ( &in_data[Where] , i , 1 , out ); + Where += i; + free ( Whatever ); + + /* sample data */ + fwrite ( &in_data[Where] , Total_Sample_Size , 1 , out ); + + Crap ( " Newtron " , BAD , BAD , out ); + + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/nfh.c b/prowizard/depack/nfh.c new file mode 100755 index 00000000..b9517397 --- /dev/null +++ b/prowizard/depack/nfh.c @@ -0,0 +1,106 @@ +/* + * nfh.c 2003 (c) Asle / ReDoX + * + * converts ziks from Noise From Heaven chiptune diskmag by Iris'01 + * +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_NFH ( void ) +{ + Uchar *Whatever; + Uchar poss[37][2]; + Uchar Max=0x00; + long WholeSampleSize=0; + long i=0,j=0; + long Where=PW_Start_Address; + FILE *out; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + + if ( Save_Status == BAD ) + return; + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* read and write whole header */ + fwrite ( &in_data[Where] , 1080 , 1 , out ); + + /* get whole sample size */ + for ( i=0 ; i<31 ; i++ ) + { + WholeSampleSize += (((in_data[Where+42+i*30]*256)+in_data[Where+43+i*30])*2); + } + /*printf ( "Whole sanple size : %ld\n" , WholeSampleSize );*/ + + Where += 952 /* after size of pattern list .. before pattern list itself */; + + /* write ID */ + Whatever = (Uchar *) malloc (4); + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* get number of pattern */ + Max = 0x00; + for ( i=0 ; i<128 ; i++ ) + { + if ( in_data[Where+i] > Max ) + Max = in_data[Where+i]; + } + /*printf ( "Number of pattern : %d\n" , Max );*/ + + /* pattern data */ + Where = PW_Start_Address + 1084; + for ( i=0 ; i<=Max ; i++ ) + { + for ( j=0 ; j<256 ; j++ ) + { + Whatever[0] = in_data[Where] & 0xf0; + Whatever[2] = (in_data[Where] & 0x0f)<<4; + Whatever[2] |= (in_data[Where+2]/2); + Whatever[3] = in_data[Where+3]; + Whatever[0] |= poss[(in_data[Where+1]/2)][0]; + Whatever[1] = poss[(in_data[Where+1]/2)][1]; + fwrite ( Whatever , 4 , 1 , out ); + Where += 4; + } + } + free ( Whatever ); + + + /* sample data */ + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + + /* crap */ + Crap ( "Noise From Heaven2" , BAD , BAD , out ); + + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} + diff --git a/prowizard/depack/noiserun.c b/prowizard/depack/noiserun.c new file mode 100755 index 00000000..93ed885b --- /dev/null +++ b/prowizard/depack/noiserun.c @@ -0,0 +1,266 @@ +/* + * NoiseRunner.c 1997 (c) Asle / ReDoX + * + * NoiseRunner to Protracker. + * + * Last revision : 26/11/1999 by Sylvain "Asle" Chipaux + * reduced to only one FREAD. + * Speed-up, Clean-up and Binary smaller. + * update: 01/12/99 + * - removed fopen() and attached funcs + * Another Update : 26 nov 2003 + * - used htonl() so that use of addy is now portable on 68k archs +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +#define PAT_DATA_ADDRESS 0x43C + +void Depack_Noiserunner ( void ) +{ + Uchar poss[37][2]; + Uchar Max=0x00; + Uchar Note,Smp,Fx,FxVal; + Uchar *Whatever; + long Where=PW_Start_Address; + long i=0,j=0,l=0,k; + long WholeSampleSize=0; + FILE *out; + + if ( Save_Status == BAD ) + return; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + Whatever = (Uchar *) malloc (1024); + BZERO ( Whatever , 1024 ); + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* title */ + fwrite ( Whatever , 20 , 1 , out ); + + /* 31 samples */ + /*printf ( "Converting sample headers ... " );*/ + for ( i=0 ; i<31 ; i++ ) + { + /* sample name */ + fwrite ( Whatever , 22 , 1 , out ); + + /* read sample address */ + j = ((in_data[Where+2]*256*256*256)+ + (in_data[Where+3]*256*256)+ + (in_data[Where+4]*256)+ + in_data[Where+5]); + + /* read and write sample size */ + fwrite ( &in_data[Where+6] , 2 , 1 , out ); + WholeSampleSize += (((in_data[Where+6]*256)+in_data[Where+7])*2); + + /* read loop start address */ + l = ((in_data[Where+8]*256*256*256)+ + (in_data[Where+9]*256*256)+ + (in_data[Where+10]*256)+ + in_data[Where+11]); + + /* calculate loop start value */ + j = l-j; + + /* read finetune ?!? */ + Whatever[32] = in_data[Where+14]; + Whatever[33] = in_data[Where+15]; + if ( Whatever[32] > 0xf0 ) + { + if ( (Whatever[32] == 0xFB) && (Whatever[33] == 0xC8) ) + Whatever[32] = 0x0f; + if ( (Whatever[32] == 0xFC) && (Whatever[33] == 0x10) ) + Whatever[32] = 0x0E; + if ( (Whatever[32] == 0xFC) && (Whatever[33] == 0x58) ) + Whatever[32] = 0x0D; + if ( (Whatever[32] == 0xFC) && (Whatever[33] == 0xA0) ) + Whatever[32] = 0x0C; + if ( (Whatever[32] == 0xFC) && (Whatever[33] == 0xE8) ) + Whatever[32] = 0x0B; + if ( (Whatever[32] == 0xFD) && (Whatever[33] == 0x30) ) + Whatever[32] = 0x0A; + if ( (Whatever[32] == 0xFD) && (Whatever[33] == 0x78) ) + Whatever[32] = 0x09; + if ( (Whatever[32] == 0xFD) && (Whatever[33] == 0xC0) ) + Whatever[32] = 0x08; + if ( (Whatever[32] == 0xFE) && (Whatever[33] == 0x08) ) + Whatever[32] = 0x07; + if ( (Whatever[32] == 0xFE) && (Whatever[33] == 0x50) ) + Whatever[32] = 0x06; + if ( (Whatever[32] == 0xFE) && (Whatever[33] == 0x98) ) + Whatever[32] = 0x05; + if ( (Whatever[32] == 0xFE) && (Whatever[33] == 0xE0) ) + Whatever[32] = 0x04; + if ( (Whatever[32] == 0xFF) && (Whatever[33] == 0x28) ) + Whatever[32] = 0x03; + if ( (Whatever[32] == 0xFF) && (Whatever[33] == 0x70) ) + Whatever[32] = 0x02; + if ( (Whatever[32] == 0xFF) && (Whatever[33] == 0xB8) ) + Whatever[32] = 0x01; + } + else + Whatever[32] = 0x00; + + /* write fine */ + fwrite ( &Whatever[32] , 1 , 1 , out ); + + /* write vol */ + fwrite ( &in_data[Where+1] , 1 , 1 , out ); + + /* write loop start */ + /* use of htonl() suggested by Xigh !.*/ + j/=2; + k = htonl(j); + Whatever[32] = *((Uchar *)&k+2); + Whatever[33] = *((Uchar *)&l+3); + fwrite ( &Whatever[32] , 2 , 1 , out ); + + /* write loop size */ + fwrite ( &in_data[Where+12] , 2 , 1 , out ); + Where += 16; + } + /*printf ( "ok\n" );*/ + /*printf ( "Whole sample size : %ld\n" , WholeSampleSize );*/ + + /* pattablesiz & Ntk Byte & pattern table */ + Where = PW_Start_Address + 950; + fwrite ( &in_data[Where] , 130 , 1 , out ); + Where += 2; + + Max = 0x00; + for ( i=0 ; i<128 ; i++ ) + { + if ( in_data[Where] > Max ) + Max = in_data[Where]; + Where += 1; + } + Max += 1; /* starts at $00 */ + /*printf ( "number of pattern : %d\n" , Max );*/ + + /* write Protracker's ID */ + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* pattern data */ + Where = PW_Start_Address + PAT_DATA_ADDRESS; + for ( i=0 ; i>3)&0x1f; + Note = in_data[Where+j*4+2]; + Fx = in_data[Where+j*4]; + FxVal= in_data[Where+j*4+1]; + switch ( Fx ) + { + case 0x00: /* tone portamento */ + Fx = 0x03; + break; + + case 0x04: /* slide up */ + Fx = 0x01; + break; + + case 0x08: /* slide down */ + Fx = 0x02; + break; + + case 0x0C: /* no Fx */ + Fx = 0x00; + break; + + case 0x10: /* set vibrato */ + Fx = 0x04; + break; + + case 0x14: /* portamento + volume slide */ + Fx = 0x05; + break; + + case 0x18: /* vibrato + volume slide */ + Fx = 0x06; + break; + + case 0x20: /* set panning ?!?!? not PTK ! Heh, Gryzor ... */ + Fx = 0x08; + break; + + case 0x24: /* sample offset */ + Fx = 0x09; + break; + + case 0x28: /* volume slide */ + Fx = 0x0A; + break; + + case 0x30: /* set volume */ + Fx = 0x0C; + break; + + case 0x34: /* pattern break */ + Fx = 0x0D; + break; + + case 0x38: /* extended command */ + Fx = 0x0E; + break; + + case 0x3C: /* set speed */ + Fx = 0x0F; + break; + + default: + /*printf ( "%x : at %x\n" , Fx , i*1024 + j*4 + 1084 );*/ + Fx = 0x00; + break; + } + Whatever[j*4] = (Smp & 0xf0); + Whatever[j*4] |= poss[(Note/2)][0]; + Whatever[j*4+1] = poss[(Note/2)][1]; + Whatever[j*4+2] = ((Smp<<4)&0xf0); + Whatever[j*4+2] |= Fx; + Whatever[j*4+3] = FxVal; + } + Where += 1024; + fwrite ( Whatever , 1024 , 1 , out ); + /*printf ( "pattern %ld written\n" , i );*/ + } + free ( Whatever ); + + /* sample data */ + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + + Crap ( " Noiserunner " , BAD , BAD , out ); + + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} + diff --git a/prowizard/depack/np1.c b/prowizard/depack/np1.c new file mode 100755 index 00000000..647411e1 --- /dev/null +++ b/prowizard/depack/np1.c @@ -0,0 +1,237 @@ +/* + * NoisePacker_v1.c 1997 (c) Asle / ReDoX + * + * Converts NoisePacked MODs back to ptk + * Last revision : 26/11/1999 by Sylvain "Asle" Chipaux + * reduced to only one FREAD. + * Speed-up and Binary smaller. + * Update:30/11/99 + * - removed fopen() and attached funcs. +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_Noisepacker1 ( void ) +{ + Uchar *Whatever; + Uchar c1=0x00,c2=0x00,c3=0x00,c4=0x00; + Uchar Nbr_Pos; + Uchar poss[37][2]; + Uchar Pat_Max=0x00; + long Max_Add=0; + long WholeSampleSize=0; + long TrackDataSize; + long Track_Addresses[128][4]; + long Unknown1; + long i=0,j=0,k; + long Track_Data_Start_Address; + long Where = PW_Start_Address; + FILE *out; + + if ( Save_Status == BAD ) + return; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + BZERO ( Track_Addresses , 128*4*4 ); + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* read number of sample */ + Whatever = (Uchar *) malloc ( 1024 ); + BZERO ( Whatever , 1024 ); + Whatever[128] = ((in_data[Where]<<4)&0xf0) | ((in_data[Where+1]>>4)&0x0f); + Where += 3; + /*printf ( "Number of sample : %d (%x)\n" , Whatever[128] , Whatever[128] );*/ + + /* write title */ + fwrite ( Whatever , 20 , 1 , out ); + + /* read size of pattern list */ + Nbr_Pos = in_data[Where++]/2; + /*printf ( "Size of pattern list : %d\n" , Nbr_Pos );*/ + + /* read 2 unknown bytes which size seem to be of some use ... */ + Unknown1 = (in_data[Where]*256)+in_data[Where+1]; + Where += 2; + + /* read track data size */ + TrackDataSize = (in_data[Where]*256)+in_data[Where+1]; + Where += 2; + /*printf ( "TrackDataSize : %ld\n" , TrackDataSize );*/ + + /* read sample descriptions */ + for ( i=0 ; i Pat_Max ) + Pat_Max = Whatever[i]; + } + Pat_Max += 1; + Where += Nbr_Pos*2; + /*printf ( "Number of pattern : %d\n" , Pat_Max );*/ + + /* write pattern table */ + fwrite ( Whatever , 128 , 1 , out ); + + /* write ptk's ID */ + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* read tracks addresses per pattern */ + for ( i=0 ; i Max_Add ) + Max_Add = Track_Addresses[i][0]; + Track_Addresses[i][1] = (in_data[Where+(i*8)+2]*256)+in_data[Where+(i*8)+3]; + if ( Track_Addresses[i][1] > Max_Add ) + Max_Add = Track_Addresses[i][1]; + Track_Addresses[i][2] = (in_data[Where+(i*8)+4]*256)+in_data[Where+(i*8)+5]; + if ( Track_Addresses[i][2] > Max_Add ) + Max_Add = Track_Addresses[i][2]; + Track_Addresses[i][3] = (in_data[Where+(i*8)+6]*256)+in_data[Where+(i*8)+7]; + if ( Track_Addresses[i][3] > Max_Add ) + Max_Add = Track_Addresses[i][3]; + } + Track_Data_Start_Address = (Where + (Pat_Max*8)); + + /* the track data now ... */ + for ( i=0 ; i 0x80 ) + c3 = 0x100-c3; + else + c3 = (c3<<4)&0xf0; + } + if ( (c2&0x0f) == 0x06 ) + { + if ( c3 > 0x80 ) + c3 = 0x100-c3; + else + c3 = (c3<<4)&0xf0; + } + if ( (c2&0x0f) == 0x05 ) + { + if ( c3 > 0x80 ) + c3 = 0x100-c3; + else + c3 = (c3<<4)&0xf0; + } + if ( (c2&0x0f) == 0x0B ) + { + c3 += 0x04; + c3 /= 2; + } + Whatever[k*16+j*4+2] = c2; + Whatever[k*16+j*4+3] = c3; + } + } + fwrite ( Whatever , 1024 , 1 , out ); + } + free ( Whatever ); + + /* sample data */ + Where = Max_Add+192+Track_Data_Start_Address; + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + Crap ( " NoisePacker v1 " , BAD , BAD , out ); + + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/np2.c b/prowizard/depack/np2.c new file mode 100755 index 00000000..f8d917e0 --- /dev/null +++ b/prowizard/depack/np2.c @@ -0,0 +1,224 @@ +/* + * NoisePacker_v2.c 1997 (c) Asle / ReDoX + * + * Converts NoisePacked MODs back to ptk + * Last revision : 26/11/1999 by Sylvain "Asle" Chipaux + * reduced to only one FREAD. + * Speed-up and Binary smaller. + * update : 01/12/99 + * - removed fopen() and attached funcs. +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_Noisepacker2 ( void ) +{ + Uchar *Whatever; + Uchar c1=0x00,c2=0x00,c3=0x00,c4=0x00; + Uchar Nbr_Pos; + Uchar Nbr_Smp; + Uchar poss[37][2]; + Uchar Pat_Max=0x00; + long Where=PW_Start_Address; + long Max_Add=0; + long WholeSampleSize=0; + long TrackDataSize; + long Track_Addresses[128][4]; + long Unknown1; + long i=0,j=0,k; + long Track_Data_Start_Address; + FILE *out; + + if ( Save_Status == BAD ) + return; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + BZERO ( Track_Addresses , 128*4*4 ); + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* read number of sample */ + Nbr_Smp = ((in_data[Where]<<4)&0xf0) | ((in_data[Where+1]>>4)&0x0f); + /*printf ( "Number of sample : %d (%x)\n" , Nbr_Smp , Nbr_Smp );*/ + + /* write title */ + Whatever = (Uchar *) malloc ( 1024 ); + BZERO ( Whatever , 1024 ); + fwrite ( Whatever , 20 , 1 , out ); + + /* read size of pattern list */ + Nbr_Pos = in_data[Where+3]/2; + /*printf ( "Size of pattern list : %d\n" , Nbr_Pos );*/ + + /* read 2 unknown bytes which size seem to be of some use ... */ + Unknown1 = (in_data[Where+4]*256)+in_data[Where+5]; + + /* read track data size */ + TrackDataSize = (in_data[Where+6]*256)+in_data[Where+7]; + /*printf ( "TrackDataSize : %ld\n" , TrackDataSize );*/ + + /* read sample descriptions */ + Where += 8; + for ( i=0 ; i Pat_Max ) + Pat_Max = Whatever[i]; + } + Pat_Max += 1; + Where += Nbr_Pos*2; + /*printf ( "Number of pattern : %d\n" , Pat_Max );*/ + + /* write pattern table */ + fwrite ( Whatever , 128 , 1 , out ); + + /* write ptk's ID */ + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* read tracks addresses per pattern */ + for ( i=0 ; i Max_Add ) + Max_Add = Track_Addresses[i][0]; + Track_Addresses[i][1] = (in_data[Where+(i*8)+2]*256)+in_data[Where+(i*8)+3]; + if ( Track_Addresses[i][1] > Max_Add ) + Max_Add = Track_Addresses[i][1]; + Track_Addresses[i][2] = (in_data[Where+(i*8)+4]*256)+in_data[Where+(i*8)+5]; + if ( Track_Addresses[i][2] > Max_Add ) + Max_Add = Track_Addresses[i][2]; + Track_Addresses[i][3] = (in_data[Where+(i*8)+6]*256)+in_data[Where+(i*8)+7]; + if ( Track_Addresses[i][3] > Max_Add ) + Max_Add = Track_Addresses[i][3]; + } + Track_Data_Start_Address = (Where + (Pat_Max*8)); + + /* the track data now ... */ + for ( i=0 ; i 0x80 ) + c3 = 0x100-c3; + else + c3 = (c3<<4)&0xf0; + } + if ( (c2&0x0f) == 0x06 ) + { + if ( c3 > 0x80 ) + c3 = 0x100-c3; + else + c3 = (c3<<4)&0xf0; + } + if ( (c2&0x0f) == 0x05 ) + { + if ( c3 > 0x80 ) + c3 = 0x100-c3; + else + c3 = (c3<<4)&0xf0; + } + if ( (c2&0x0f) == 0x0E ) + { + c3 -= 0x01; + } + if ( (c2&0x0f) == 0x0B ) + { + c3 += 0x04; + c3 /= 2; + } + Whatever[k*16+j*4+2] = c2; + Whatever[k*16+j*4+3] = c3; + } + } + fwrite ( Whatever , 1024 , 1 , out ); + } + free ( Whatever ); + + /* sample data */ + Where = Max_Add+192+Track_Data_Start_Address; + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + Crap ( " NoisePacker v2 " , BAD , BAD , out ); + + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/np3.c b/prowizard/depack/np3.c new file mode 100755 index 00000000..8a329523 --- /dev/null +++ b/prowizard/depack/np3.c @@ -0,0 +1,234 @@ +/* + * NoisePacker_v3.c 1998 (c) Asle / ReDoX + * + * Converts NoisePacked MODs back to ptk + * Last revision : 26/11/1999 by Sylvain "Asle" Chipaux + * reduced to only one FREAD. + * Speed-up and Binary smaller. + * update : 01/12/99 + * - removed fopen() and attached funcs. +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_Noisepacker3 ( void ) +{ + Uchar *Whatever; + Uchar c1=0x00,c2=0x00,c3=0x00,c4=0x00; + Uchar Nbr_Pos; + Uchar Nbr_Smp; + Uchar poss[36][2]; + Uchar Pat_Max=0x00; + long Where=PW_Start_Address; + long WholeSampleSize=0; + long TrackDataSize; + long Track_Addresses[128][4]; + long Unknown1; + long i=0,j=0,k; + long Track_Data_Start_Address; + long SampleDataAddress=0; + FILE *out; + + if ( Save_Status == BAD ) + return; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + BZERO ( Track_Addresses , 128*4*4 ); + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* read number of sample */ + Nbr_Smp = ((in_data[Where]<<4)&0xf0) | ((in_data[Where+1]>>4)&0x0f); + /*printf ( "\nNumber of sample : %d (%x)\n" , Nbr_Smp , Nbr_Smp );*/ + + /* write title */ + Whatever = (Uchar *) malloc ( 1024 ); + BZERO ( Whatever , 1024 ); + fwrite ( Whatever , 20 , 1 , out ); + + /* read size of pattern list */ + Nbr_Pos = in_data[Where+3]/2; + /*printf ( "Size of pattern list : %d\n" , Nbr_Pos );*/ + + /* read 2 unknown bytes which size seem to be of some use ... */ + Unknown1 = (in_data[Where+4]*256)+in_data[Where+5]; + + /* read track data size */ + TrackDataSize = (in_data[Where+6]*256)+in_data[Where+7]; + /*printf ( "TrackDataSize : %ld\n" , TrackDataSize );*/ + + /* read sample descriptions */ + Where += 8; + for ( i=0 ; i Pat_Max ) + Pat_Max = Whatever[i]; + } + Where += Nbr_Pos*2; + Pat_Max += 1; + /*printf ( "Number of pattern : %d\n" , Pat_Max );*/ + + /* write pattern table */ + fwrite ( Whatever , 128 , 1 , out ); + + /* write ptk's ID */ + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* read tracks addresses per pattern */ + /*printf ( "\nWhere : %ld\n" , Where );*/ + for ( i=0 ; i= 0x80 ) + { + k += ((0x100-c1)-1); + continue; + } + c2 = in_data[Where]; + Where += 1; + c3 = in_data[Where]; + Where += 1; + + Whatever[k*16+j*4] = (c1<<4)&0x10; + c4 = (c1 & 0xFE)/2; + Whatever[k*16+j*4] |= poss[c4][0]; + Whatever[k*16+j*4+1] = poss[c4][1]; + if ( (c2&0x0f) == 0x08 ) + c2 &= 0xf0; + if ( (c2&0x0f) == 0x07 ) + { + c2 = (c2&0xf0)+0x0A; + if ( c3 > 0x80 ) + c3 = 0x100-c3; + else + c3 = (c3<<4)&0xf0; + } + if ( (c2&0x0f) == 0x06 ) + { + if ( c3 > 0x80 ) + c3 = 0x100-c3; + else + c3 = (c3<<4)&0xf0; + } + if ( (c2&0x0f) == 0x05 ) + { + if ( c3 > 0x80 ) + c3 = 0x100-c3; + else + c3 = (c3<<4)&0xf0; + } + if ( (c2&0x0f) == 0x0E ) + { + c3 = 0x01; + } + if ( (c2&0x0f) == 0x0B ) + { + c3 += 0x04; + c3 /= 2; + } + Whatever[k*16+j*4+2] = c2; + Whatever[k*16+j*4+3] = c3; + if ( (c2&0x0f) == 0x0D ) + k = 100; /* to leave the loop */ + } + if ( Where > SampleDataAddress ) + SampleDataAddress = Where; + } + fwrite ( Whatever , 1024 , 1 , out ); + } + free ( Whatever ); + + /* sample data */ + if ( (((SampleDataAddress-PW_Start_Address)/2)*2) != SampleDataAddress ) + SampleDataAddress += 1; + Where = SampleDataAddress; + /*printf ( "Starting address of sample data : %x\n" , ftell ( in ) );*/ + fwrite ( &in_data[SampleDataAddress] , WholeSampleSize , 1 , out ); + + Crap ( " NoisePacker v3 " , BAD , BAD , out ); + + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/p22a.c b/prowizard/depack/p22a.c new file mode 100755 index 00000000..cf9f1885 --- /dev/null +++ b/prowizard/depack/p22a.c @@ -0,0 +1,285 @@ +/* + * The_Player_2.2.c 2003 (c) Asle / ReDoX + * + * The Player 2.2a to Protracker. + * + * Update : 26 nov 2003 + * - used htonl() so that use of addy is now portable on 68k archs +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +void Depack_P22 ( void ) +{ + Uchar c1,c2,c3,c4; + Uchar *Whatever; + Uchar PatPos = 0x00; + Uchar Nbr_Sample = 0x00; + Uchar poss[37][2]; + Uchar sample,note,Note[2]; + Uchar Pattern_Data[128][1024]; + short Pattern_Addresses[128]; + long Track_Data_Address = 0; + long Track_Table_Address = 0; + long Sample_Data_Address = 0; + long WholeSampleSize = 0; + long SampleAddress[31]; + long SampleSize[31]; + long i=0,j,k,l; + long voice[4]; + long Where = PW_Start_Address; + FILE *out;/*,*debug;*/ + + if ( Save_Status == BAD ) + return; + + BZERO ( Pattern_Addresses , 128*2 ); + BZERO ( Pattern_Data , 128*1024 ); + BZERO ( SampleAddress , 31*4 ); + BZERO ( SampleSize , 31*4 ); + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + /*debug = fopen ( "debug", "w+b" );*/ + + /* read check ID */ + Where += 4; + + /* bypass Real number of pattern */ + Where += 1; + + /* read number of pattern in pattern list */ + PatPos = (in_data[Where++]/2) - 1; + + /* read number of samples */ + Nbr_Sample = in_data[Where++]; + + /* bypass empty byte */ + Where += 1; + + +/**********/ + + /* read track data address */ + Track_Data_Address = (in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3]; + Where += 4; + + /* read track table address */ + Track_Table_Address = (in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3]; + Where += 4; + + /* read sample data address */ + Sample_Data_Address = (in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3]; + Where += 4; + + + /* write title */ + Whatever = (Uchar *) malloc ( 1024 ); + BZERO ( Whatever , 1024 ); + fwrite ( Whatever , 20 , 1 , out ); + + /* sample headers stuff */ + for ( i=0 ; i k ) + continue; + + c1 = in_data[Where++]; + c2 = in_data[Where++]; + c3 = in_data[Where++]; + c4 = in_data[Where++]; + + /*fprintf (debug,"[%2ld][%2d][%4x] - %2x,%2x,%2x,%2x -> ",j,voice[j],Where-4,c1,c2,c3,c4);*/ + + sample = ((c1<<4)&0x10) | ((c2>>4)&0x0f); + BZERO ( Note , 2 ); + note = c1 & 0x7f; + Note[0] = poss[(note/2)][0]; + Note[1] = poss[(note/2)][1]; + switch ( c2&0x0f ) + { + case 0x08: + c2 -= 0x08; + break; + case 0x05: + case 0x06: + case 0x0A: + c3 = (c3 > 0x7f) ? ((0x100-c3)<<4) : c3; + break; + default: + break; + } + Pattern_Data[i][voice[j]*16+j*4] = (sample&0xf0) | (Note[0]&0x0f); + Pattern_Data[i][voice[j]*16+j*4+1] = Note[1]; + Pattern_Data[i][voice[j]*16+j*4+2] = c2; + Pattern_Data[i][voice[j]*16+j*4+3] = c3; + + /*fprintf ( debug, "%2x,%2x,%2x,%2x",Pattern_Data[i][voice[j]*16+j*4],Pattern_Data[i][voice[j]*16+j*4+1],Pattern_Data[i][voice[j]*16+j*4+2],Pattern_Data[i][voice[j]*16+j*4+3]);*/ + + if ( (c4 > 0x00) && (c4 <0x80) ) + { + voice[j] += c4; + /*fprintf ( debug, " <-- %d empty lines",c4 );*/ + } + /*fprintf ( debug, "\n" );*/ + voice[j] += 1; + } /* end of case 0x80 for first byte */ + } + } + /* printf ( "ok\n" );*/ + + + + /* write pattern data */ + /*printf ( "writing pattern data ... " );*/ + /*fflush ( stdout );*/ + for ( i=0 ; i k ) + continue; + + c1 = in_data[Where++]; + c2 = in_data[Where++]; + c3 = in_data[Where++]; + c4 = in_data[Where++]; + +fprintf (debug,"[%2ld][%2ld][%4lx] - %2x,%2x,%2x,%2x -> ",j,voice[j],Where-4,c1,c2,c3,c4);fflush(debug); + + if ( c1 != 0x80 ) + { + sample = ((c1<<4)&0x10) | ((c2>>4)&0x0f); + BZERO ( Note , 2 ); + note = c1 & 0x7f; + Note[0] = poss[(note/2)][0]; + Note[1] = poss[(note/2)][1]; + switch ( c2&0x0f ) + { + case 0x08: + c2 -= 0x08; + break; + case 0x05: + case 0x06: + case 0x0A: + c3 = (c3 > 0x7f) ? ((c3<<4)&0xf0) : c3; + break; + default: + break; + } + Pattern_Data[i][voice[j]*16+j*4] = (sample&0xf0) | (Note[0]&0x0f); + Pattern_Data[i][voice[j]*16+j*4+1] = Note[1]; + Pattern_Data[i][voice[j]*16+j*4+2] = c2; + Pattern_Data[i][voice[j]*16+j*4+3] = c3; + +fprintf ( debug, "%2x,%2x,%2x,%2x",Pattern_Data[i][voice[j]*16+j*4],Pattern_Data[i][voice[j]*16+j*4+1],Pattern_Data[i][voice[j]*16+j*4+2],Pattern_Data[i][voice[j]*16+j*4+3]);fflush(debug); + + if ( (c4 > 0x00) && (c4 <0x80) ) + { + voice[j] += c4; +fprintf ( debug, " <-- %d empty lines",c4 );fflush(debug); + } +fprintf ( debug, "\n" );fflush(debug); + voice[j] += 1; + } /* end of case 0x80 for first byte */ + + else /* repeat some lines */ + { + a = Where; + + c5 = c2; + Where -= (((c3&0x7f)*256)+ (c4*4)); +fprintf ( debug , "\n![%2ld] - go back %d bytes and read %d notes (at %lx)\n" , i , (((c3&0x7f)*256)+ (c4*4)),c5 , a-4 );fflush(debug); + for ( c=0 ; c<=c5 ; c++ ) + { + /*fprintf ( debug , "%ld," , k );*/ + c1 = in_data[Where++]; + c2 = in_data[Where++]; + c3 = in_data[Where++]; + c4 = in_data[Where++]; +fprintf (debug,"[%2ld][%2ld][%4lx] - %2x,%2x,%2x,%2x -> ",j,voice[j],Where-4,c1,c2,c3,c4);fflush(debug); + + sample = ((c1<<4)&0x10) | ((c2>>4)&0x0f); + BZERO ( Note , 2 ); + note = c1 & 0x7f; + Note[0] = poss[(note/2)][0]; + Note[1] = poss[(note/2)][1]; + switch ( c2&0x0f ) + { + case 0x08: + c2 -= 0x08; + break; + case 0x05: + case 0x06: + case 0x0A: + c3 = (c3 > 0x7f) ? ((c3<<4)&0xf0) : c3; + break; + default: + break; + } + Pattern_Data[i][voice[j]*16+j*4] = (sample&0xf0) | (Note[0]&0x0f); + Pattern_Data[i][voice[j]*16+j*4+1] = Note[1]; + Pattern_Data[i][voice[j]*16+j*4+2] = c2; + Pattern_Data[i][voice[j]*16+j*4+3] = c3; + +fprintf ( debug, "%2x,%2x,%2x,%2x",Pattern_Data[i][voice[j]*16+j*4],Pattern_Data[i][voice[j]*16+j*4+1],Pattern_Data[i][voice[j]*16+j*4+2],Pattern_Data[i][voice[j]*16+j*4+3]);fflush(debug); + if ( (c4 > 0x00) && (c4 <0x80) ) + { + voice[j] += c4; + c += c4; /* empty lines are counted ! */ +fprintf ( debug, " <-- %d empty lines",c4 );fflush(debug); + } + voice[j] += 1; +fprintf ( debug, "\n" );fflush(debug); + } + + voice[j] -= 1; + Where = a; +fprintf ( debug , "\n!## back to %lx\n" , a );fflush(debug); + } + } + } + } + /* printf ( "ok\n" );*/ + + + + /* write pattern data */ + /*printf ( "writing pattern data ... " );*/ + /*fflush ( stdout );*/ + for ( i=0 ; i>4)&0x0f); + BZERO ( Note , 2 ); + note = c1 & 0x7f; + Note[0] = poss[(note/2)][0]; + Note[1] = poss[(note/2)][1]; + switch ( c2&0x0f ) + { + case 0x08: + c2 -= 0x08; + break; + case 0x05: + case 0x06: + case 0x0A: + c3 = (c3 > 0x7f) ? ((0x100-c3)<<4) : c3; +// if ( c3 >= 0x80 ) +// c3 = (c3<<4)&0xf0; + break; + default: + break; + } + Track_Data[i*4+j][k*4] = (sample&0xf0) | (Note[0]&0x0f); + Track_Data[i*4+j][k*4+1] = Note[1]; + Track_Data[i*4+j][k*4+2] = c2; + Track_Data[i*4+j][k*4+3] = c3; + + if ( (c4 > 0x00) && (c4 <0x80) ) + k += c4; + if ( (c4 > 0x7f) && (c4 <=0xff) ) + { + k+=1; + for ( l=256 ; l>c4 ; l-- ) + { + Track_Data[i*4+j][k*4] = (sample&0xf0) | (Note[0]&0x0f); + Track_Data[i*4+j][k*4+1] = Note[1]; + Track_Data[i*4+j][k*4+2] = c2; + Track_Data[i*4+j][k*4+3] = c3; + k+=1; + } + k -= 1; + } + } + + else + { + a = Where; + + c5 = c2; + Where = PW_Start_Address + (c3 * 256) + c4 + Track_Data_Address + 4; +/*fprintf ( debug , "%2d (pattern %ld)(at %x)\n" , c2 , i , a-4 );*/ + for ( c=0 ; c<=c5 ; c++ ) + { +/*fprintf ( debug , "%ld," , k );*/ + c1 = in_data[Where++]; + c2 = in_data[Where++]; + c3 = in_data[Where++]; + c4 = in_data[Where++]; + + sample = ((c1<<4)&0x10) | ((c2>>4)&0x0f); + BZERO ( Note , 2 ); + note = c1 & 0x7f; + Note[0] = poss[(note/2)][0]; + Note[1] = poss[(note/2)][1]; + switch ( c2&0x0f ) + { + case 0x08: + c2 -= 0x08; + break; + case 0x05: + case 0x06: + case 0x0A: + c3 = (c3 > 0x7f) ? ((0x100-c3)<<4) : c3; +// if ( c3 >= 0x80 ) +// c3 = (c3<<4)&0xf0; + break; + default: + break; + } + Track_Data[i*4+j][k*4] = (sample&0xf0) | (Note[0]&0x0f); + Track_Data[i*4+j][k*4+1] = Note[1]; + Track_Data[i*4+j][k*4+2] = c2; + Track_Data[i*4+j][k*4+3] = c3; + + if ( (c4 > 0x00) && (c4 <0x80) ) + k += c4; + if ( (c4 > 0x7f) && (c4 <=0xff) ) + { + k+=1; + for ( l=256 ; l>c4 ; l-- ) + { + Track_Data[i*4+j][k*4] = (sample&0xf0) | (Note[0]&0x0f); + Track_Data[i*4+j][k*4+1] = Note[1]; + Track_Data[i*4+j][k*4+2] = c2; + Track_Data[i*4+j][k*4+3] = c3; + k+=1; + } + k -= 1; + } + k += 1; + } + + k -= 1; + Where = a; +/*fprintf ( debug , "\n## back to %x\n" , a );*/ + } + } + } + } + /*printf ( "ok\n" );*/ + +/* +for ( i=0 ; i>4)&0x0f); + BZERO ( Note , 2 ); + note = c1 & 0x7f; + Note[0] = poss[(note/2)][0]; + Note[1] = poss[(note/2)][1]; + switch ( c2&0x0f ) + { + case 0x08: + c2 -= 0x08; + break; + case 0x05: + case 0x06: + case 0x0A: + c3 = (c3 > 0x7f) ? ((0x100-c3)<<4) : c3; +// if ( c3 >= 0x80 ) +// c3 = (c3<<4)&0xf0; + break; + default: + break; + } + Track_Data[i*4+j][k*4] = (sample&0xf0) | (Note[0]&0x0f); + Track_Data[i*4+j][k*4+1] = Note[1]; + Track_Data[i*4+j][k*4+2] = c2; + Track_Data[i*4+j][k*4+3] = c3; + + if ( (c4 > 0x00) && (c4 <0x80) ) + k += c4; + if ( (c4 > 0x7f) && (c4 <=0xff) ) + { + k+=1; + for ( l=256 ; l>c4 ; l-- ) + { + Track_Data[i*4+j][k*4] = (sample&0xf0) | (Note[0]&0x0f); + Track_Data[i*4+j][k*4+1] = Note[1]; + Track_Data[i*4+j][k*4+2] = c2; + Track_Data[i*4+j][k*4+3] = c3; + k+=1; + } + k -= 1; + } + } + + else + { + a = Where; + + c5 = c2; + Where = PW_Start_Address + (c3 * 256) + c4 + Track_Data_Address + 4; +/*fprintf ( debug , "%2d (pattern %ld)(at %x)\n" , c2 , i , a-4 );*/ + for ( c=0 ; c<=c5 ; c++ ) + { +/*fprintf ( debug , "%ld," , k );*/ + c1 = in_data[Where++]; + c2 = in_data[Where++]; + c3 = in_data[Where++]; + c4 = in_data[Where++]; + + sample = ((c1<<4)&0x10) | ((c2>>4)&0x0f); + BZERO ( Note , 2 ); + note = c1 & 0x7f; + Note[0] = poss[(note/2)][0]; + Note[1] = poss[(note/2)][1]; + switch ( c2&0x0f ) + { + case 0x08: + c2 -= 0x08; + break; + case 0x05: + case 0x06: + case 0x0A: + c3 = (c3 > 0x7f) ? ((0x100-c3)<<4) : c3; +// if ( c3 >= 0x80 ) +// c3 = (c3<<4)&0xf0; + break; + default: + break; + } + Track_Data[i*4+j][k*4] = (sample&0xf0) | (Note[0]&0x0f); + Track_Data[i*4+j][k*4+1] = Note[1]; + Track_Data[i*4+j][k*4+2] = c2; + Track_Data[i*4+j][k*4+3] = c3; + + if ( (c4 > 0x00) && (c4 <0x80) ) + k += c4; + if ( (c4 > 0x7f) && (c4 <=0xff) ) + { + k+=1; + for ( l=256 ; l>c4 ; l-- ) + { + Track_Data[i*4+j][k*4] = (sample&0xf0) | (Note[0]&0x0f); + Track_Data[i*4+j][k*4+1] = Note[1]; + Track_Data[i*4+j][k*4+2] = c2; + Track_Data[i*4+j][k*4+3] = c3; + k+=1; + } + k -= 1; + } + k += 1; + } + + k -= 1; + Where = a; +/*fprintf ( debug , "\n## back to %x\n" , a );*/ + } + } + } + } + /*printf ( "ok\n" );*/ + +/* +for ( i=0 ; i 0xFF00 ) + { + SampleSizes[i] = SampleSizes[0xFFFF-j]; + SmpSizes[i][0] = SmpSizes[0xFFFF-j][0]; + SmpSizes[i][1] = SmpSizes[0xFFFF-j][1]; +/*fprintf ( debug , "!%2ld!" , 0xFFFF-j );*/ + SampleAddresses[i+1] = SampleAddresses[0xFFFF-j+1];/* - SampleSizes[i]+SampleSizes[0xFFFF-j];*/ + } + else + { + SampleAddresses[i+1] = SampleAddresses[i]+SampleSizes[i-1]; + SampleSizes[i] = j*2; + WholeSampleSize += SampleSizes[i]; + } + j = SampleSizes[i]/2; + fwrite ( &SmpSizes[i][0] , 1 , 1 , out ); + fwrite ( &SmpSizes[i][1] , 1 , 1 , out ); + + /* finetune,vol */ + fwrite ( &in_data[Where+2] , 2 , 1 , out ); + + /* loop start */ +/*fprintf ( debug , "loop start : %2x, %2x " , c1,c2 );*/ + if ( (in_data[Where+4]==0xFF) && (in_data[Where+5]==0xFF) ) + { + Whatever[53]=0x01; + fwrite ( &Whatever[50] , 4 , 1 , out ); +/*fprintf ( debug , " <--- no loop! (%2x,%2x)\n" ,c3,c4);*/ + Where += 6; + continue; + } + fwrite ( &in_data[Where+4] , 2 , 1 , out ); + l = j - ((in_data[Where+4]*256)+in_data[Where+5]); +/*fprintf ( debug , " -> size:%6ld lstart:%5d -> lsize:%ld\n" , j,c1*256+c2,l );*/ + + /* use of htonl() suggested by Xigh !.*/ + z = htonl(l); + c1 = *((Uchar *)&z+2); + c2 = *((Uchar *)&z+3); + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + + Where += 6; + } + + /* go up to 31 samples */ + Whatever[129] = 0x01; + while ( i != 31 ) + { + fwrite ( &Whatever[100] , 30 , 1 , out ); + i += 1; + } + /*printf ( "Whole sample size : %ld\n" , WholeSampleSize );*/ + +/*fprintf ( debug , "Where after sample headers : %x\n" , ftell ( in ) );*/ + + /* read tracks addresses per pattern */ + for ( i=0 ; i 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + if ( c6 == 0x0D ) + { +/*fprintf ( debug , " <-- PATTERN BREAK !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + if ( c6 == 0x0B ) + { +/*fprintf ( debug , " <-- PATTERN JUMP !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + + if ( c4 < 0x80 ) + { +/*fprintf ( debug , "%2x <--- bypass %d rows !\n" , c4 , c4 );*/ + k += c4; + continue; + } +/*fprintf ( debug , "%2x <--- repeat current row %d times\n" , c4 , 0x100-c4 );*/ + c4=0x100-c4; + for ( l=0 ; l 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + } + continue; + } + if ( c1 == 0x80 ) + { + c4 = in_data[Where++]; +/*fprintf ( debug , "%2x <--- repeat %2d lines some %2d bytes before\n" , c4,c2+1,(c3*256)+c4);*/ + a = Where; + c5 = c2; + Where -= ((c3*256)+c4); + for ( l=0 ; l<=c5 ; l++,k++ ) + { + c1 = in_data[Where++]; + c2 = in_data[Where++]; + c3 = in_data[Where++]; +/*fprintf ( debug , "#%2ld: %2x, %2x, %2x, " , k , c1,c2,c3 );*/ + if ( ((c1&0x80) == 0x80) && (c1!=0x80) ) + { + c4 = in_data[Where++]; + c1 = 0xFF-c1; + Track_Data[i*4+j][k*4] = ((c1<<4)&0x10) | (poss[c1/2][0]); + Track_Data[i*4+j][k*4+1] = poss[c1/2][1]; + c6 = c2&0x0f; + if ( c6 == 0x08 ) + c2 -= 0x08; + Track_Data[i*4+j][k*4+2] = c2; + if ( (c6==0x05) || (c6==0x06) || (c6==0x0a) ) + c3 = (c3 > 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + if ( c6 == 0x0D ) + { + Max = k; + k = l = 9999l; +/*fprintf ( debug , " <-- PATTERN BREAK !, track ends\n" );*/ + continue; + } + if ( c6 == 0x0B ) + { + Max = k; + k = l = 9999l; +/*fprintf ( debug , " <-- PATTERN JUMP !, track ends\n" );*/ + continue; + } + + if ( c4 < 0x80 ) + { +/*fprintf ( debug , "%2x <--- bypass %d rows !\n" , c4 , c4 );*/ + /*l += c4;*/ + k += c4; + continue; + } +/*fprintf ( debug , "%2x <--- repeat current row %d times\n" , c4 , 0x100-c4 );*/ + c4=0x100-c4; + /*l += (c4-1);*/ + for ( b=0 ; b 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + } + } + Track_Data[i*4+j][k*4] = ((c1<<4)&0x10) | (poss[c1/2][0]); + Track_Data[i*4+j][k*4+1] = poss[c1/2][1]; + c6 = c2&0x0f; + if ( c6 == 0x08 ) + c2 -= 0x08; + Track_Data[i*4+j][k*4+2] = c2; + if ( (c6==0x05) || (c6==0x06) || (c6==0x0a) ) + c3 = (c3 > 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; +/*fprintf ( debug , "\n" );*/ + } + Where = a; +/*fprintf ( debug , "\n" );*/ + k -= 1; + continue; + } + + Track_Data[i*4+j][k*4] = ((c1<<4)&0x10) | (poss[c1/2][0]); + Track_Data[i*4+j][k*4+1] = poss[c1/2][1]; + c6 = c2&0x0f; + if ( c6 == 0x08 ) + c2 -= 0x08; + Track_Data[i*4+j][k*4+2] = c2; + if ( (c6==0x05) || (c6==0x06) || (c6==0x0a) ) + c3 = (c3 > 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + if ( c6 == 0x0D ) + { +/*fprintf ( debug , " <-- PATTERN BREAK !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + if ( c6 == 0x0B ) + { +/*fprintf ( debug , " <-- PATTERN JUMP !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + +/*fprintf ( debug , "\n" );*/ + } + } + } + /*printf ( "ok\n" );*/ + + /* write pattern data */ + + /*printf ( "writing pattern data ... " );*/ + /*fflush ( stdout );*/ + for ( i=0 ; i 0xFF00 ) + { + SampleSizes[i] = SampleSizes[0xFFFF-j]; + SmpSizes[i][0] = SmpSizes[0xFFFF-j][0]; + SmpSizes[i][1] = SmpSizes[0xFFFF-j][1]; +/*fprintf ( debug , "!%2ld!" , 0xFFFF-j );*/ + SampleAddresses[i+1] = SampleAddresses[0xFFFF-j+1];/* - SampleSizes[i]+SampleSizes[0xFFFF-j];*/ + } + else + { + SampleAddresses[i+1] = SampleAddresses[i]+SampleSizes[i-1]; + SampleSizes[i] = j*2; + WholeSampleSize += SampleSizes[i]; + } + j = SampleSizes[i]/2; + fwrite ( &SmpSizes[i][0] , 1 , 1 , out ); + fwrite ( &SmpSizes[i][1] , 1 , 1 , out ); + + /* finetune */ + c1 = in_data[Where+2]; + if ( (c1&0x40) == 0x40 ) + PACK[i]=ON; + c1 &= 0x3F; + fwrite ( &c1 , 1 , 1 , out ); + + /* vol */ + fwrite ( &in_data[Where+3] , 1 , 1 , out ); + + /* loop start */ +/*fprintf ( debug , "loop start : %2x, %2x " , c1,c2 );*/ + if ( (in_data[Where+4]==0xFF) && (in_data[Where+5]==0xFF) ) + { + Whatever[53]=0x01; + fwrite ( &Whatever[50] , 4 , 1 , out ); +/*fprintf ( debug , " <--- no loop! (%2x,%2x)\n" ,c3,c4);*/ + Where += 6; + continue; + } + fwrite ( &in_data[Where+4] , 2 , 1 , out ); + l = j - ((in_data[Where+4]*256)+in_data[Where+5]); +/*fprintf ( debug , " -> size:%6ld lstart:%5d -> lsize:%ld\n" , j,c1*256+c2,l );*/ + + /* use of htonl() suggested by Xigh !.*/ + z = htonl (l); + c1 = *((Uchar *)&z+2); + c2 = *((Uchar *)&z+3); + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + + Where += 6; + } + + /* go up to 31 samples */ + Whatever[129] = 0x01; + while ( i != 31 ) + { + fwrite ( &Whatever[100] , 30 , 1 , out ); + i += 1; + } + /*printf ( "Whole sample size : %ld\n" , WholeSampleSize );*/ + +/*fprintf ( debug , "Where after sample headers : %x\n" , ftell ( in ) );*/ + + /* read tracks addresses per pattern */ + for ( i=0 ; i 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + if ( c6 == 0x0D ) + { +/*fprintf ( debug , " <-- PATTERN BREAK !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + if ( c6 == 0x0B ) + { +/*fprintf ( debug , " <-- PATTERN JUMP !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + + if ( c4 < 0x80 ) + { +/*fprintf ( debug , "%2x <--- bypass %d rows !\n" , c4 , c4 );*/ + k += c4; + continue; + } +/*fprintf ( debug , "%2x <--- repeat current row %d times\n" , c4 , 0x100-c4 );*/ + c4=0x100-c4; + for ( l=0 ; l 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + } + continue; + } + if ( c1 == 0x80 ) + { + c4 = in_data[Where++]; +/*fprintf ( debug , "%2x <--- repeat %2d lines some %2d bytes before\n" , c4,c2+1,(c3*256)+c4);*/ + a = Where; + c5 = c2; + Where -= ((c3*256)+c4); + for ( l=0 ; l<=c5 ; l++,k++ ) + { + c1 = in_data[Where++]; + c2 = in_data[Where++]; + c3 = in_data[Where++]; +/*fprintf ( debug , "#%2ld: %2x, %2x, %2x, " , k , c1,c2,c3 );*/ + if ( ((c1&0x80) == 0x80) && (c1!=0x80) ) + { + c4 = in_data[Where++]; + c1 = 0xFF-c1; + Track_Data[i*4+j][k*4] = ((c1<<4)&0x10) | (poss[c1/2][0]); + Track_Data[i*4+j][k*4+1] = poss[c1/2][1]; + c6 = c2&0x0f; + if ( c6 == 0x08 ) + c2 -= 0x08; + Track_Data[i*4+j][k*4+2] = c2; + if ( (c6==0x05) || (c6==0x06) || (c6==0x0a) ) + c3 = (c3 > 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + if ( c6 == 0x0D ) + { + Max = k; + k = l = 9999l; +/*fprintf ( debug , " <-- PATTERN BREAK !, track ends\n" );*/ + continue; + } + if ( c6 == 0x0B ) + { + Max = k; + k = l = 9999l; +/*fprintf ( debug , " <-- PATTERN JUMP !, track ends\n" );*/ + continue; + } + + if ( c4 < 0x80 ) + { +/*fprintf ( debug , "%2x <--- bypass %d rows !\n" , c4 , c4 );*/ + /*l += c4;*/ + k += c4; + continue; + } +/*fprintf ( debug , "%2x <--- repeat current row %d times\n" , c4 , 0x100-c4 );*/ + c4=0x100-c4; + /*l += (c4-1);*/ + for ( b=0 ; b 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + } + } + Track_Data[i*4+j][k*4] = ((c1<<4)&0x10) | (poss[c1/2][0]); + Track_Data[i*4+j][k*4+1] = poss[c1/2][1]; + c6 = c2&0x0f; + if ( c6 == 0x08 ) + c2 -= 0x08; + Track_Data[i*4+j][k*4+2] = c2; + if ( (c6==0x05) || (c6==0x06) || (c6==0x0a) ) + c3 = (c3 > 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; +/*fprintf ( debug , "\n" );*/ + } + Where = a; +/*fprintf ( debug , "\n" );*/ + k -= 1; + continue; + } + + Track_Data[i*4+j][k*4] = ((c1<<4)&0x10) | (poss[c1/2][0]); + Track_Data[i*4+j][k*4+1] = poss[c1/2][1]; + c6 = c2&0x0f; + if ( c6 == 0x08 ) + c2 -= 0x08; + Track_Data[i*4+j][k*4+2] = c2; + if ( (c6==0x05) || (c6==0x06) || (c6==0x0a) ) + c3 = (c3 > 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + if ( c6 == 0x0D ) + { +/*fprintf ( debug , " <-- PATTERN BREAK !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + if ( c6 == 0x0B ) + { +/*fprintf ( debug , " <-- PATTERN JUMP !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + +/*fprintf ( debug , "\n" );*/ + } + } + } + /*printf ( "ok\n" );*/ + + /* write pattern data */ + + /*printf ( "writing pattern data ... " );*/ + /*fflush ( stdout );*/ + for ( i=0 ; i 0xFF00 ) + { + SampleSizes[i] = SampleSizes[0xFFFF-j]; + SmpSizes[i][0] = SmpSizes[0xFFFF-j][0]; + SmpSizes[i][1] = SmpSizes[0xFFFF-j][1]; +/*fprintf ( debug , "!%2ld!" , 0xFFFF-j );*/ + SampleAddresses[i+1] = SampleAddresses[0xFFFF-j+1];/* - SampleSizes[i]+SampleSizes[0xFFFF-j];*/ + } + else + { + SampleAddresses[i+1] = SampleAddresses[i]+SampleSizes[i-1]; + SampleSizes[i] = j*2; + WholeSampleSize += SampleSizes[i]; + } + j = SampleSizes[i]/2; + fwrite ( &SmpSizes[i][0] , 1 , 1 , out ); + fwrite ( &SmpSizes[i][1] , 1 , 1 , out ); + + /* finetune */ + c1 = in_data[Where+2]; + if ( (c1&0x40) == 0x40 ) + PACK[i]=ON; + c1 &= 0x3F; + fwrite ( &c1 , 1 , 1 , out ); + + /* vol */ + fwrite ( &in_data[Where+3] , 1 , 1 , out ); + + /* loop start */ +/*fprintf ( debug , "loop start : %2x, %2x " , c1,c2 );*/ + if ( (in_data[Where+4]==0xFF) && (in_data[Where+5]==0xFF) ) + { + Whatever[53]=0x01; + fwrite ( &Whatever[50] , 4 , 1 , out ); +/*fprintf ( debug , " <--- no loop! (%2x,%2x)\n" ,c3,c4);*/ + Where += 6; + continue; + } + fwrite ( &in_data[Where+4] , 2 , 1 , out ); + l = j - ((in_data[Where+4]*256)+in_data[Where+5]); +/*fprintf ( debug , " -> size:%6ld lstart:%5d -> lsize:%ld\n" , j,c1*256+c2,l );*/ + + /* use of htonl() suggested by Xigh !.*/ + w = htonl(l); + c1 = *((Uchar *)&w+2); + c2 = *((Uchar *)&w+3); + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + + Where += 6; + } + + /* go up to 31 samples */ + Whatever[129] = 0x01; + while ( i != 31 ) + { + fwrite ( &Whatever[100] , 30 , 1 , out ); + i += 1; + } + /*printf ( "Whole sample size : %ld\n" , WholeSampleSize );*/ + +/*fprintf ( debug , "Where after sample headers : %x\n" , ftell ( in ) );*/ + + /* read tracks addresses per pattern */ + for ( i=0 ; i>4)&0x0e); + Track_Data[i*4+j][k*4] = (c2&0x10) | (poss[c6/2][0]); + Track_Data[i*4+j][k*4+1] = poss[c6/2][1]; + Track_Data[i*4+j][k*4+2] = ((c2<<4)&0xf0); + + if ( (c1 & 0x80) == 0x80 ) + { + c3 = in_data[Where++]; + if ( c3 < 0x80 ) + { +/*fprintf ( debug , "%2x <--- bypass %d rows !\n" , c3 , c3 );*/ + k += c3; + continue; + } +/*fprintf ( debug , "%2x <--- repeat current row %d times\n" , c3 , c3-0x80 );*/ + c4=c3-0x80; + for ( l=0 ; l 0x7f) ? ((0x100-c2)<<4) : c2; + Track_Data[i*4+j][k*4+3] = c2; + + if ( c6 == 0x0D ) + { +/*fprintf ( debug , " <-- PATTERN BREAK !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + if ( c6 == 0x0B ) + { +/*fprintf ( debug , " <-- PATTERN JUMP !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + if ( (c1 & 0x80) == 0x80 ) + { + c3 = in_data[Where++]; + if ( c3 < 0x80 ) + { +/*fprintf ( debug , "%2x <--- bypass %d rows !\n" , c3 , c3 );*/ + k += c3; + continue; + } +/*fprintf ( debug , "%2x <--- repeat current row %d times\n" , c3 , c3-0x80 );*/ + c4=c3-0x80; + for ( l=0 ; l 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + if ( c6 == 0x0D ) + { +/*fprintf ( debug , " <-- PATTERN BREAK !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + if ( c6 == 0x0B ) + { +/*fprintf ( debug , " <-- PATTERN JUMP !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + + if ( c4 < 0x80 ) + { +/*fprintf ( debug , "%2x <--- bypass %d rows !\n" , c4 , c4 );*/ + k += c4; + continue; + } +/*fprintf ( debug , "%2x <--- repeat current row %d times\n" , c4 , c4-0x80 );*/ + c4=c4-0x80; + for ( l=0 ; l 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + } + continue; + } + + + if ( (c1&0x7F) == 0x7F ) + { + if ( (c1&0x80) == 0x00 ) + { +/*fprintf ( debug , " <--- bypass 1 row !\n" );*/ + /*k += 1;*/ + continue; + } + c2 = in_data[Where++]; + if ( c2 < 0x40 ) + { +/*fprintf ( debug , "%2x <--- bypass %d rows !\n" , c2 , c2 );*/ + k += c2; + continue; + } +/*fprintf ( debug , "%2x, " , c2 );*/ + c2 -= 0x40; + c3 = in_data[Where++]; +/*fprintf ( debug , "%2x, " , c3 );*/ + z = c3; + if ( c2 >= 0x80 ) + { + c2 -= 0x80; + c4 = in_data[Where++]; +/*fprintf ( debug , "%2x, " , c4 );*/ + z = (c3*256)+c4; + } +/*fprintf ( debug , " <--- repeat %2d lines some %ld bytes before\n" , c2,z );*/ + a = Where; + c5 = c2; + Where -= z; + for ( l=0 ; (l<=c5)&&(k<=Max) ; l++,k++ ) + { + c1 = in_data[Where++]; +/*fprintf ( debug , "#%2ld: %2x, " , l , c1 );*/ + + /* case no Fx nor FxArg (3 bytes) */ + if ( ((c1&0x70) == 0x70) && (c1 != 0xFF) && (c1!=0x7F)) + { + c2 = in_data[Where++]; +/*fprintf ( debug , "%2x, " , c2 );*/ + c6 = ((c1<<4)&0xf0)|((c2>>4)&0x0e); + Track_Data[i*4+j][k*4] = (c2&0x10) | (poss[c6/2][0]); + Track_Data[i*4+j][k*4+1] = poss[c6/2][1]; + Track_Data[i*4+j][k*4+2] = ((c2<<4)&0xf0); + + if ( (c1 & 0x80) == 0x80 ) + { + c3 = in_data[Where++]; + if ( c3 < 0x80 ) + { +/*fprintf ( debug , "%2x <--- bypass %d rows !\n" , c3 , c3 );*/ + k += c3; + continue; + } +/*fprintf ( debug , "%2x <--- repeat current row %d times\n" , c3 , c3-0x80 );*/ + c4=c3-0x80; + for ( b=0 ; b 0x7f) ? ((0x100-c2)<<4) : c2; + Track_Data[i*4+j][k*4+3] = c2; + + if ( c6 == 0x0D ) + { +/*fprintf ( debug , " <-- PATTERN BREAK !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + if ( c6 == 0x0B ) + { +/*fprintf ( debug , " <-- PATTERN JUMP !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + + if ( (c1 & 0x80) == 0x80 ) + { + c3 = in_data[Where++]; + if ( c3 < 0x80 ) + { +/*fprintf ( debug , "%2x <--- bypass %d rows !\n" , c3 , c3 );*/ + k += c3; + continue; + } +/*fprintf ( debug , "%2x <--- repeat current row %d times\n" , c3 , c3-0x80 );*/ + c4=c3-0x80; + for ( b=0 ; b 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + if ( c6 == 0x0D ) + { + Max = k; + k = l = 9999l; +/*fprintf ( debug , " <-- PATTERN BREAK !, track ends\n" );*/ + continue; + } + if ( c6 == 0x0B ) + { + Max = k; + k = l = 9999l; +/*fprintf ( debug , " <-- PATTERN JUMP !, track ends\n" );*/ + continue; + } + + if ( c4 < 0x80 ) + { +/*fprintf ( debug , "%2x <--- bypass %d rows !\n" , c4 , c4 );*/ + /*l += c4;*/ + k += c4; + continue; + } +/*fprintf ( debug , "%2x <--- repeat current row %d times\n" , c4 , c4-0x80 );*/ + c4=c4-0x80; + /*l += (c4-1);*/ + for ( b=0 ; b 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + } + continue; + } + if ( (c1&0x7F) == 0x7F ) + { + if ( (c1&0x80) == 0x00 ) + { +/*fprintf ( debug , " <--- bypass 1 row !\n" );*/ + /*k += 1;*/ + continue; + } + c2 = in_data[Where++]; + if ( c2 < 0x40 ) + { +/*fprintf ( debug , "%2x <--- bypass %d rows !\n" , c2 , c2 );*/ + k += c2; + continue; + } + continue; + } + + c2 = in_data[Where++]; + c3 = in_data[Where++]; +/*fprintf ( debug , "%2x, %2x" , c2,c3 );*/ + Track_Data[i*4+j][k*4] = ((c1<<4)&0x10) | (poss[c1/2][0]); + Track_Data[i*4+j][k*4+1] = poss[c1/2][1]; + c6 = c2&0x0f; + if ( c6 == 0x08 ) + c2 -= 0x08; + Track_Data[i*4+j][k*4+2] = c2; + if ( (c6==0x05) || (c6==0x06) || (c6==0x0a) ) + c3 = (c3 > 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; +/*fprintf ( debug , "\n" );*/ + } + Where = a; +/*fprintf ( debug , "\n" );*/ + k -= 1; + continue; + } + + c2 = in_data[Where++]; + c3 = in_data[Where++]; +/*fprintf ( debug , "%2x, %2x" , c2,c3 );*/ + Track_Data[i*4+j][k*4] = ((c1<<4)&0x10) | (poss[c1/2][0]); + Track_Data[i*4+j][k*4+1] = poss[c1/2][1]; + c6 = c2&0x0f; + if ( c6 == 0x08 ) + c2 -= 0x08; + Track_Data[i*4+j][k*4+2] = c2; + if ( (c6==0x05) || (c6==0x06) || (c6==0x0a) ) + c3 = (c3 > 0x7f) ? ((0x100-c3)<<4) : c3; + Track_Data[i*4+j][k*4+3] = c3; + if ( c6 == 0x0D ) + { +/*fprintf ( debug , " <-- PATTERN BREAK !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + if ( c6 == 0x0B ) + { +/*fprintf ( debug , " <-- PATTERN JUMP !, track ends\n" );*/ + Max = k; + k = 9999l; + continue; + } + +/*fprintf ( debug , "\n" );*/ + } + } + } + /*printf ( "ok\n" );*/ + + /* write pattern data */ + + /*printf ( "writing pattern data ... " );*/ + for ( i=0 ; i new patter [addy:%ld] [nbr:%d]\n", MyPatList[c1], c1);*/ + c1 += 0x01; + } + if ( Whole_Pattern_Data[i] == 0xff ) + { + i += 1; + /* Old_cpt[(k+3)%4] = 0xff - Whole_Pattern_Data[i];*/ + Old_cpt[(k-1)%4] = 0xff - Whole_Pattern_Data[i]; + /* fprintf (info, "-> count set to [%d] for voice [%ld]\n",Old_cpt[(k-1)%4],(k-1)%4 );*/ + /*k += 1;*/ + continue; + } + if ( Old_cpt[k%4] != 0 ) + { + Smp = Old_Note_Value[k%4][0]; + Note = Old_Note_Value[k%4][1]; + Fx = Old_Note_Value[k%4][2]; + FxVal = Old_Note_Value[k%4][3]; + /* fprintf ( info, "[%5ld]-[%ld] %2x %2x %2x %2x [%ld] [%6ld] (count : %d)\n",i,k%4,Smp,Note,Fx,FxVal,j,MyPatList[c1-1],Old_cpt[k%4] );*/ + Old_cpt[k%4] -= 1; + + Pattern[j] = Smp&0xf0; + Pattern[j] |= poss[(Note/2)][0]; + Pattern[j+1] = poss[(Note/2)][1]; + Pattern[j+2] = (Smp<<4)&0xf0; + Pattern[j+2] |= Fx; + Pattern[j+3] = FxVal; + k+=1; + j+=4; + i-=1; + continue; + } + Smp = Whole_Pattern_Data[i]; + Note = Whole_Pattern_Data[i+1]; + Fx = Whole_Pattern_Data[i+2]; + FxVal = Whole_Pattern_Data[i+3]; + Old_Note_Value[k%4][0] = Smp; + Old_Note_Value[k%4][1] = Note; + Old_Note_Value[k%4][2] = Fx; + Old_Note_Value[k%4][3] = FxVal; + /* fprintf ( info, "[%5ld]-[%ld] %2x %2x %2x %2x [%ld] [%6ld]\n",i,k%4,Smp,Note,Fx,FxVal,j, MyPatList[c1-1]);*/ + /* fflush (info);*/ + i += 3; + Pattern[j] = Smp&0xf0; + Pattern[j] |= poss[(Note/2)][0]; + Pattern[j+1] = poss[(Note/2)][1]; + Pattern[j+2] = (Smp<<4)&0xf0; + Pattern[j+2] |= Fx; + Pattern[j+3] = FxVal; + k+=1; + j+=4; + } + PatMax = c1; + + /* +fprintf ( info , "pats address pats address tmp\n" ); +for ( i=0 ; i<128 ; i++ ) +{ + fprintf ( info , "%3ld: %6ld %ld [%ld]\n" , i , Pats_Address[i] , Pats_Address_tmp[i],MyPatList[i] ); +} +fflush ( info );*/ + + /* try to get the number of pattern in pattern list */ + for ( c1=128 ; c1>0x00 ; c1-=0x01 ) + if ( Pats_Address[c1] != Pats_Address[127] ) + break; + + /* write this value */ + c1 += 1; + fwrite ( &c1 , 1 , 1 , out ); + + /* ntk restart byte */ + c2 = 0x7f; + fwrite ( &c2 , 1 , 1 , out ); + + /* write pattern list */ + for ( i=0 ; i<128 ; i++ ) + { + for (c1=0x00; Pats_Address[i]!=MyPatList[c1];c1+=0x01); + fwrite ( &c1 , 1 , 1 , out ); + } + + + /* ID string */ + c1 = 'M'; + c2 = '.'; + c3 = 'K'; + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + fwrite ( &c3 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + + + fwrite ( Pattern , PatMax*1024 , 1 , out ); + free ( Whole_Pattern_Data ); + free ( Pattern ); + + /* Sample data */ + fseek ( in , Sample_Data_Address , 0 ); /* SEEK_SET */ + Sample_Data = (Uchar *) malloc ( Whole_Sample_Size ); + fread ( Sample_Data , Whole_Sample_Size , 1 , in ); + fwrite ( Sample_Data , Whole_Sample_Size , 1 , out ); + free ( Sample_Data ); + + Crap ( " PhaPacker " , BAD , BAD , out ); + /* + fseek ( out , 830 , SEEK_SET ); + fprintf ( out , " -[Converted with]- " ); + fseek ( out , 860 , SEEK_SET ); + fprintf ( out , " -[PhaPacker to]- " ); + fseek ( out , 890 , SEEK_SET ); + fprintf ( out , " -[Protracker]- " ); + fseek ( out , 920 , SEEK_SET ); + fprintf ( out , " -[by Asle /ReDoX]- " ); + */ + fflush ( in ); + fflush ( out ); + fclose ( in ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/pm.c b/prowizard/depack/pm.c new file mode 100755 index 00000000..d67c22da --- /dev/null +++ b/prowizard/depack/pm.c @@ -0,0 +1,109 @@ +/* + * PowerMusic.c 1996 (c) Asle / ReDoX + * + * Converts back to ptk Optimod's power music files + * + * Last revision : 26/11/1999 by Sylvain "Asle" Chipaux + * reduced to only one FREAD. + * Speed-up and Binary smaller. + * update: 01/12/99 + * - removed fopen() and attached funcs +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_PM ( void ) +{ + signed char *Smp_Data; + Uchar c1=0x00,c2=0x00; + Uchar Max=0x00; + long WholeSampleSize=0; + long i=0,j; + long Where = PW_Start_Address; + FILE *out; + + if ( Save_Status == BAD ) + return; + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* write whole header */ + fwrite ( &in_data[Where] , 950 , 1 , out ); + + /* get whole sample size */ + for ( i=0 ; i<31 ; i++ ) + WholeSampleSize += (((in_data[Where+42+i*30]*256)+in_data[Where+43+i*30])*2); + /*printf ( "Whole sanple size : %ld\n" , WholeSampleSize );*/ + + /* read and write size of pattern list */ + fwrite ( &in_data[Where+950] , 1 , 1 , out ); + + /* read and write ntk byte and pattern list */ + c1 = 0x7f; + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &in_data[Where+952] , 128 , 1 , out ); + + /* write ID */ + c1 = 'M'; + c2 = '.'; + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + c1 = 'K'; + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + + /* get number of pattern */ + Max = 0x00; + for ( i=0 ; i<128 ; i++ ) + { + if ( in_data[Where+i+952] > Max ) + Max = in_data[Where+i+952]; + } + j = Max += 1; + /*printf ( "\nNumber of pattern : %ld\n" , j );*/ + /* pattern data */ + j *= 1024; + fwrite ( &in_data[Where+1084] , j , 1 , out ); + j += 1084; + + /* sample data */ + Smp_Data = (signed char *) malloc ( WholeSampleSize ); + BZERO ( Smp_Data , WholeSampleSize ); + Smp_Data[0] = in_data[Where+j]; + for ( i=1 ; i>4)&0x0f); + if ( c3 == 0 ) + c3 = Old_Smp_Nbr[i%4]; + else + Old_Smp_Nbr[i%4] = c3; + if ( (k != 0) && (Smp_Fine_Table[c3-1] != 0x00) ) + { +/*fprintf ( info , "! (at %ld)(smp:%x)(pitch:%ld)\n" , (i*4)+382 , c3 , k );*/ + for ( l=0 ; l<36 ; l++ ) + { + if ( k == Tuning[Smp_Fine_Table[c3-1]][l] ) + { + Whatever[i*4] = poss[l+1][0]; + Whatever[i*4+1] = poss[l+1][1]; + } + } + } + else + { + Whatever[i*4] = PatternData[i*4]&0x0f; + Whatever[i*4+1] = PatternData[i*4+1]; + } + Whatever[i*4] |= (PatternData[i*4]&0xf0); + Whatever[i*4+2] = PatternData[i*4+2]; + Whatever[i*4+3] = PatternData[i*4+3]; + } + fwrite ( Whatever , j , 1 , out ); + free ( Whatever ); + free ( PatternData ); + + /* sample data */ + Where += j; + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + /* crap */ + Crap ( " Promizer 0.1 " , BAD , BAD , out ); + + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/pm10c.c b/prowizard/depack/pm10c.c new file mode 100755 index 00000000..1dce1b49 --- /dev/null +++ b/prowizard/depack/pm10c.c @@ -0,0 +1,258 @@ +/* + * Promizer_10c.c 1997 (c) Asle / ReDoX + * + * Converts PM10c packed MODs back to PTK MODs + * + * update 20 mar 2003 (it's war time again .. brrrr) + * - removed all open() funcs. + * - optimized more than quite a bit (src is 5kb shorter !) +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +#define ON 0 +#define OFF 1 + +#define PATTERN_DATA_ADDY 5222 + +void Depack_PM10c ( void ) +{ + Uchar c1=0x00,c2=0x00; + short Ref_Max=0; + long Pats_Address[128]; + long Read_Pats_Address[128]; + Uchar NOP=0x00; /* number of pattern */ + Uchar *ReferenceTable; + Uchar *Pattern; + long i=0,j=0,k=0,l=0,m=0; + long Total_Sample_Size=0; + long PatDataSize=0l; + long SDAV=0l; + Uchar FLAG=OFF; + Uchar Smp_Fine_Table[31]; + Uchar poss[37][2]; + Uchar OldSmpValue[4]; + Uchar *Whatever; + Uchar *WholePatternData; + long Where = PW_Start_Address; + short Period; + FILE *out;/*,*info;*/ + +#ifdef DOS + #include "..\include\tuning.h" + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/tuning.h" + #include "../include/ptktable.h" +#endif + + + if ( Save_Status == BAD ) + return; + + BZERO ( Smp_Fine_Table , 31 ); + BZERO ( OldSmpValue , 4 ); + BZERO ( Pats_Address , 128*4 ); + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + /*info = fopen ( "info", "w+b");*/ + + Whatever = (Uchar *) malloc (128); + BZERO (Whatever,128); + + /* title */ + fwrite ( &Whatever[32] , 20 , 1 , out ); + + /* bypass replaycode routine */ + Where = PW_Start_Address + 4460; + + for ( i=0 ; i<31 ; i++ ) + { + /*sample name*/ + fwrite ( &Whatever[32] ,22 , 1 , out ); + + fwrite ( &in_data[Where], 8, 1, out ); + /* whole sample size */ + Total_Sample_Size += (((in_data[Where]*256)+in_data[Where+1])*2); + /* finetune */ + Smp_Fine_Table[i] = in_data[Where+2]; + Where += 8; + } + + /* read patterns addys */ + Where = PW_Start_Address + 4710; + for ( i=0 ; i<128 ; i++ ) + { + Pats_Address[i] = (in_data[Where]*256*256*256)+(in_data[Where+1]*256*256)+(in_data[Where+2]*256)+in_data[Where+3]; + /*fprintf ( info, "Pat[%3ld]: %ld\n",i,Pats_Address[i]);*/ + Where += 4; + } + + /* --------------------- */ + /* a little pre-calc code ... no other way to deal with these unknown pattern data sizes ! :( */ + Where = PW_Start_Address + 4456; + PatDataSize = (in_data[Where]*256*256*256)+(in_data[Where+1]*256*256)+(in_data[Where+2]*256)+in_data[Where+3]; + /*fprintf ( info, "PatDataSize : %ld\n" , PatDataSize );*/ + + /* go back to pattern data starting address */ + Where = PW_Start_Address + PATTERN_DATA_ADDY; + + /* now, reading all pattern data to get the max value of note */ + WholePatternData = (Uchar *) malloc (PatDataSize+1); + BZERO (WholePatternData, PatDataSize+1); + for ( j=0 ; j Ref_Max ) + Ref_Max = ((WholePatternData[j]*256)+WholePatternData[j+1]); + } + Where += PatDataSize; + + /*fprintf ( info, "highest ref number (Ref_Max) = %d\n" , Ref_Max );*/ + + /* read "reference Table" */ + Ref_Max += 1; /* coz 1st value is 0 ! */ + i = Ref_Max * 4; /* coz each block is 4 bytes long */ + ReferenceTable = (Uchar *) malloc ( i+1 ); + BZERO ( ReferenceTable, i+1 ); + for ( j=0 ; j new pattern %2d (addy :%ld)\n", c1, j+5222 );*/ + } + + m = ((WholePatternData[j]*256)+WholePatternData[j+1])*4; + Pattern[i] = ReferenceTable[m]; + Pattern[i+1] = ReferenceTable[m+1]; + Pattern[i+2] = ReferenceTable[m+2]; + Pattern[i+3] = ReferenceTable[m+3]; + + /*fprintf ( info, "[%4x][%3ld][%ld]: %2x %2x %2x %2x", j,i,k%4,Pattern[i],Pattern[i+1],Pattern[i+2],Pattern[i+3]);*/ + + c2 = ((Pattern[i+2]>>4)&0x0f) | (Pattern[i]&0xf0); + if ( c2 != 0x00 ) + { + OldSmpValue[k%4] = c2; + } + Period = ((Pattern[i]&0x0f)*256)+Pattern[i+1]; + if ( (Period != 0) && (Smp_Fine_Table[OldSmpValue[k%4]-1] != 0x00) ) + { + for ( l=0 ; l<36 ; l++ ) + if ( Tuning[Smp_Fine_Table[OldSmpValue[k%4]-1]][l] == Period ) + { + Pattern[i] &= 0xf0; + Pattern[i] |= poss[l+1][0]; + Pattern[i+1] = poss[l+1][1]; + break; + } + } + + if ( ( (Pattern[i+2] & 0x0f) == 0x0d ) || + ( (Pattern[i+2] & 0x0f) == 0x0b ) ) + { + /*fprintf ( info, " <-- B or D detected" );*/ + FLAG = ON; + } + if ( (FLAG == ON) && ((k%4) == 3) ) + { + /*fprintf ( info, "\n -> bypassing end of pattern" );*/ + FLAG=OFF; + while ( (i%1024) != 0) + i ++; + i -= 4; + } + k += 1; + i += 4; + /*fprintf ( info, "\n" );*/ + } + free ( ReferenceTable ); + free ( WholePatternData ); + + /* pattern table lenght */ + Where = PW_Start_Address + 4708; + NOP = ((in_data[Where]*256)+in_data[Where+1])/4; + fwrite ( &NOP , 1 , 1 , out ); + + Whatever[0] = 0x7f; + fwrite ( &Whatever[0], 1, 1, out ); + + /* write pattern table */ + BZERO ( Whatever, 128 ); + for ( c2=0; c2<128 ; c2+=0x01 ) + for ( i=0 ; i Ref_Max ) + Ref_Max = ((WholePatternData[j]*256)+WholePatternData[j+1]); + } + Where += PatDataSize; + + /* read "reference Table" */ + Ref_Max += 1; /* coz 1st value is 0 ! */ + i = Ref_Max * 4; /* coz each block is 4 bytes long */ + ReferenceTable = (Uchar *) malloc ( i ); + BZERO ( ReferenceTable, i+1 ); + for ( j=0 ; j new pattern %2d (addy :%ld)\n", c1, j+5226 );*/ + } + + m = ((WholePatternData[j]*256)+WholePatternData[j+1])*4; + Pattern[i] = ReferenceTable[m]; + Pattern[i+1] = ReferenceTable[m+1]; + Pattern[i+2] = ReferenceTable[m+2]; + Pattern[i+3] = ReferenceTable[m+3]; + + /*fprintf ( info, "[%4x][%3ld][%ld]: %2x %2x %2x %2x", j,i,k%4,Pattern[i],Pattern[i+1],Pattern[i+2],Pattern[i+3]);*/ + + c2 = ((Pattern[i+2]>>4)&0x0f) | (Pattern[i]&0xf0); + if ( c2 != 0x00 ) + { + OldSmpValue[k%4] = c2; + } + Period = ((Pattern[i]&0x0f)*256)+Pattern[i+1]; + if ( (Period != 0) && (Smp_Fine_Table[OldSmpValue[k%4]-1] != 0x00) ) + { + for ( l=0 ; l<36 ; l++ ) + if ( Tuning[Smp_Fine_Table[OldSmpValue[k%4]-1]][l] == Period ) + { + Pattern[i] &= 0xf0; + Pattern[i] |= poss[l+1][0]; + Pattern[i+1] = poss[l+1][1]; + break; + } + } + + if ( ( (Pattern[i+2] & 0x0f) == 0x0d ) || + ( (Pattern[i+2] & 0x0f) == 0x0b ) ) + { + /*fprintf ( info, " <-- B or D detected" );*/ + FLAG = ON; + } + if ( (FLAG == ON) && ((k%4) == 3) ) + { + /*fprintf ( info, "\n -> bypassing end of pattern" );*/ + FLAG=OFF; + while ( (i%1024) != 0) + i ++; + i -= 4; + } + k += 1; + i += 4; + /*fprintf ( info, "\n" );*/ + } + free ( ReferenceTable ); + free ( WholePatternData ); + + /* write pattern table */ + BZERO ( Whatever, 128 ); + for ( c2=0; c2<128 ; c2+=0x01 ) + for ( i=0 ; i Ref_Max ) + Ref_Max = ((WholePatternData[j]*256)+WholePatternData[j+1]); + } + + /* read "reference Table" */ + Where = PW_Start_Address + ADDRESS_REF_TABLE; + j = (in_data[Where]*256*256*256)+(in_data[Where+1]*256*256)+(in_data[Where+2]*256)+in_data[Where+3]; + Where = PW_Start_Address + AFTER_REPLAY_CODE + j; + + Ref_Max += 1; /* coz 1st value is 0 ! */ + i = Ref_Max * 4; /* coz each block is 4 bytes long */ + ReferenceTable = (Uchar *) malloc ( i ); + BZERO ( ReferenceTable, i ); + for ( j=0 ; j new pattern %2d (addy :%ld)\n", c1, j );*/ + } + + m = ((WholePatternData[j]*256)+WholePatternData[j+1])*4; + + Smp = ReferenceTable[m]; + Smp = Smp >> 2; + Note = ReferenceTable[m+1]; + + Pattern[i] = (Smp&0xf0); + Pattern[i] |= poss[(Note/2)][0]; + Pattern[i+1] = poss[(Note/2)][1]; + Pattern[i+2] = ReferenceTable[m+2]; + Pattern[i+2] |= ((Smp<<4)&0xf0); + Pattern[i+3] = ReferenceTable[m+3]; + /*fprintf ( info, "[%4ld][%ld][%ld] %2x %2x %2x %2x",i,k%4,j,Pattern[i],Pattern[i+1],Pattern[i+2],Pattern[i+3] );*/ + + if ( ( (Pattern[i+2] & 0x0f) == 0x0d ) || + ( (Pattern[i+2] & 0x0f) == 0x0b ) ) + { + /*fprintf ( info, " <- D or B detected" );*/ + FLAG = ON; + } + if ( (FLAG == ON) && ((k%4) == 3) ) + { + /*fprintf ( info, "\n -> bypassing end of pattern" );*/ + FLAG=OFF; + while ( (i%1024) != 0) + i ++; + i -= 4; + } + + k += 1; + i += 4; + /*fprintf ( info, "\n" );*/ + } + + free ( ReferenceTable ); + free ( WholePatternData ); + + /* write pattern table */ + BZERO ( Whatever, 128 ); + for ( c2=0; c2<128 ; c2+=0x01 ) + for ( i=0 ; i Ref_Max ) + Ref_Max = (c1*256)+c2; + } +/* + printf ( "* Ref_Max = %d\n" , Ref_Max ); + printf ( "* where : %ld\n" , ftell ( in ) ); +*/ + /* read "reference Table" */ + fseek ( in , ADDRESS_REF_TABLE , 0 ); /* SEEK_SET */ + fread ( &c1 , 1 , 1 , in ); + fread ( &c2 , 1 , 1 , in ); + fread ( &c3 , 1 , 1 , in ); + fread ( &c4 , 1 , 1 , in ); + j = (c1*256*256*256)+(c2*256*256)+(c3*256)+c4; + fseek ( in , 8+j , 0 ); /* SEEK_SET */ +/* printf ( "address of 'reference table' : %ld\n" , ftell (in ) );*/ + Ref_Max += 1; /* coz 1st value is 0 and will be empty in this table */ + i = Ref_Max * 4; /* coz each block is 4 bytes long */ + ReferenceTable = (Uchar *) malloc ( i ); + BZERO ( ReferenceTable , i ); + fread ( &ReferenceTable[4] , i , 1 , in ); + + /* go back to pattern data starting address */ + fseek ( in , PATTERN_DATA , 0 ); /* SEEK_SET */ +/* printf ( "Highest pattern number : %d\n" , Pat_Max );*/ + + /*printf ( "Computing the pattern datas " );*/ + k=0; + for ( j=0 ; j<=Pat_Max ; j++ ) + { + for ( i=0 ; i<64 ; i++ ) + { + /* VOICE #1 */ + + fread ( &c1 , 1 , 1 , in ); + k += 1; + fread ( &c2 , 1 , 1 , in ); + k += 1; + Smp = ReferenceTable[((c1*256)+c2)*4]; + Note = ReferenceTable[((c1*256)+c2)*4+1]; + + Pattern[j][i*16] = (Smp&0xf0); + Pattern[j][i*16] |= poss[Note][0]; + Pattern[j][i*16+1] = poss[Note][1]; + Pattern[j][i*16+2] = ReferenceTable[((c1*256)+c2)*4+2]; + Pattern[j][i*16+2] |= ((Smp<<4)&0xf0); + Pattern[j][i*16+3] = ReferenceTable[((c1*256)+c2)*4+3]; + + if ( ( (Pattern[j][i*16+2] & 0x0f) == 0x0d ) || + ( (Pattern[j][i*16+2] & 0x0f) == 0x0b ) ) + { + FLAG = ON; + } + + /* VOICE #2 */ + + fread ( &c1 , 1 , 1 , in ); + k += 1; + fread ( &c2 , 1 , 1 , in ); + k += 1; + Smp = ReferenceTable[((c1*256)+c2)*4]; + Note = ReferenceTable[((c1*256)+c2)*4+1]; + + Pattern[j][i*16+4] = (Smp&0xf0); + Pattern[j][i*16+4] |= poss[Note][0]; + Pattern[j][i*16+5] = poss[Note][1]; + Pattern[j][i*16+6] = ReferenceTable[((c1*256)+c2)*4+2]; + Pattern[j][i*16+6] |= ((Smp<<4)&0xf0); + Pattern[j][i*16+7] = ReferenceTable[((c1*256)+c2)*4+3]; + + if ( ( ( Pattern[j][i*16+6] & 0x0f) == 0x0d ) || + ( (Pattern[j][i*16+6] & 0x0f) == 0x0b ) ) + { + FLAG = ON; + } + + /* VOICE #3 */ + + fread ( &c1 , 1 , 1 , in ); + k += 1; + fread ( &c2 , 1 , 1 , in ); + k += 1; + Smp = ReferenceTable[((c1*256)+c2)*4]; + Note = ReferenceTable[((c1*256)+c2)*4+1]; + + Pattern[j][i*16+8] = (Smp&0xf0); + Pattern[j][i*16+8] |= poss[Note][0]; + Pattern[j][i*16+9] = poss[Note][1]; + Pattern[j][i*16+10] = ReferenceTable[((c1*256)+c2)*4+2]; + Pattern[j][i*16+10] |= ((Smp<<4)&0xf0); + Pattern[j][i*16+11]= ReferenceTable[((c1*256)+c2)*4+3]; + + if ( ( (Pattern[j][i*16+10] & 0x0f) == 0x0d ) || + ( (Pattern[j][i*16+10] & 0x0f) == 0x0b ) ) + { + FLAG = ON; + } + + /* VOICE #4 */ + + fread ( &c1 , 1 , 1 , in ); + k += 1; + fread ( &c2 , 1 , 1 , in ); + k += 1; + Smp = ReferenceTable[((c1*256)+c2)*4]; + Note = ReferenceTable[((c1*256)+c2)*4+1]; + + Pattern[j][i*16+12] = (Smp&0xf0); + Pattern[j][i*16+12] |= poss[Note][0]; + Pattern[j][i*16+13] = poss[Note][1]; + Pattern[j][i*16+14] = ReferenceTable[((c1*256)+c2)*4+2]; + Pattern[j][i*16+14] |= ((Smp<<4)&0xf0); + Pattern[j][i*16+15]= ReferenceTable[((c1*256)+c2)*4+3]; + + if ( ( (Pattern[j][i*16+14] & 0x0f) == 0x0d ) || + ( (Pattern[j][i*16+14] & 0x0f) == 0x0b ) ) + { + FLAG = ON; + } + + if ( FLAG == ON ) + { + FLAG=OFF; + break; + } + } + fwrite ( Pattern[j] , 1024 , 1 , out ); + /*printf ( "." );*/ + } + free ( ReferenceTable ); + /*printf ( " ok\n" );*/ + + + /* get address of sample data .. and go there */ + /*printf ( "Saving sample datas ... " );*/ + fseek ( in , ADDRESS_SAMPLE_DATA , 0 ); /* SEEK_SET */ + fread ( &c1 , 1 , 1 , in ); + fread ( &c2 , 1 , 1 , in ); + fread ( &c3 , 1 , 1 , in ); + fread ( &c4 , 1 , 1 , in ); + SDAV = (c1*256*256*256)+(c2*256*256)+(c3*256)+c4; + fseek ( in , 4 + SDAV , 0 ); /* SEEK_SET */ + + + /* read and save sample data */ +/* printf ( "out: where before saving sample data : %ld\n" , ftell ( out ) );*/ +/* printf ( "Whole sample size : %ld\n" , Total_Sample_Size );*/ + SampleData = (Uchar *) malloc ( Total_Sample_Size ); + fread ( SampleData , Total_Sample_Size , 1 , in ); + fwrite ( SampleData , Total_Sample_Size , 1 , out ); + free ( SampleData ); + /*printf ( " ok\n" );*/ + + Crap ( " Promizer 4.0 " , BAD , BAD , out ); + /* + fseek ( out , 830 , SEEK_SET ); + fprintf ( out , "-[ Converted with ]-" ); + fseek ( out , 860 , SEEK_SET ); + fprintf ( out , "-[ Promizer 4.0 ]-" ); + fseek ( out , 890 , SEEK_SET ); + fprintf ( out , "-[ to Protracker ]-" ); + fseek ( out , 920 , SEEK_SET ); + fprintf ( out , "-[ by Asle /ReDoX ]-" ); + */ + fflush ( in ); + fflush ( out ); + fclose ( in ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/polka.c b/prowizard/depack/polka.c new file mode 100755 index 00000000..957ca3db --- /dev/null +++ b/prowizard/depack/polka.c @@ -0,0 +1,116 @@ +/* + * Polka.c 2003 (c) Asle + * +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_Polka ( void ) +{ + Uchar poss[37][2]; + Uchar c1=0x00,c2=0x00; + Uchar Max=0x00; + long WholeSampleSize=0; + long i=0,j; + long Where = PW_Start_Address; + FILE *out; + unsigned char Whatever[4]; + + if ( Save_Status == BAD ) + return; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* takes care of header */ + fwrite ( &in_data[Where], 20, 1, out ); + for ( i=0 ; i<31 ; i++ ) + { + fwrite ( &in_data[Where+20+i*30], 18, 1, out ); + c1=0x00; + fwrite ( &c1, 1, 1, out );fwrite ( &c1, 1, 1, out ); + fwrite ( &c1, 1, 1, out );fwrite ( &c1, 1, 1, out ); + fwrite ( &in_data[Where+42+i*30], 8, 1, out ); + WholeSampleSize += (((in_data[Where+42+i*30]*256)+in_data[Where+43+i*30])*2); + } + /*printf ( "Whole sanple size : %ld\n" , WholeSampleSize );*/ + + /* read and write size of pattern list+ntk byte + pattern list */ + fwrite ( &in_data[Where+0x3b6] , 130 , 1 , out ); + + /* write ID */ + c1 = 'M'; + c2 = '.'; + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + c1 = 'K'; + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + + /* get number of pattern */ + Max = 0x00; + for ( i=0 ; i<128 ; i++ ) + { + if ( in_data[Where+i+0x3b8] > Max ) + Max = in_data[Where+i+0x3b8]; + } + Max += 1; + /*printf ( "\nNumber of pattern : %ld\n" , j );*/ + + /* pattern data */ + Where = PW_Start_Address + 0x43c; + for ( i=0 ; i Max ) + Max = Tracks_Numbers[j][i]; + } + } + /*printf ( "highest track number : %d\n" , Max+1 );*/ + + /* write pattern table "as is" ... */ + for (Whatever[0]=0 ; Whatever[0] Max ) + Max = Tracks_Numbers[j][i]; + } + } + /*printf ( "Number of tracks : %d\n" , Max+1 );*/ + + /* write pattern table without any optimizing ! */ + for ( c1=0x00 ; c1 Max ) + Max = Tracks_Numbers[j][i]; + } + } + + /* write pattern table without any optimizing ! */ + for ( c1=0x00 ; c1 Max ) + Max = in_data[Where+i]; + } + /*printf ( "Number of pattern : %d\n" , Max );*/ + + /* pattern data */ + Where = PW_Start_Address + 1084; + for ( i=0 ; i<=Max ; i++ ) + { + for ( j=0 ; j<256 ; j++ ) + { + Whatever[0] = in_data[Where] & 0xf0; + Whatever[2] = (in_data[Where] & 0x0f)<<4; + Whatever[2] |= in_data[Where+2]; + Whatever[3] = in_data[Where+3]; + Whatever[0] |= poss[in_data[Where+1]][0]; + Whatever[1] = poss[in_data[Where+1]][1]; + fwrite ( Whatever , 4 , 1 , out ); + Where += 4; + } + } + free ( Whatever ); + + + /* sample data */ + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + + /* crap */ + Crap ( " ProRunner v1 " , BAD , BAD , out ); + + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} + diff --git a/prowizard/depack/prun2.c b/prowizard/depack/prun2.c new file mode 100755 index 00000000..17adaf54 --- /dev/null +++ b/prowizard/depack/prun2.c @@ -0,0 +1,160 @@ +/* + * ProRunner2.c 1996-1999 (c) Asle / ReDoX + * + * Converts ProRunner v2 packed MODs back to Protracker + ******************************************************** + * 12 april 1999 : Update + * - no more open() of input file ... so no more fread() !. + * It speeds-up the process quite a bit :). + * + * 28 Nov 1999 : Update + * - optimized code for size and speed (again :) + * Heh, 1/5 shorter now !. + * + * 23 aug 2001 : debug + * - "repeat last note used bug" pointed out by Markus Jaegermeister !. + * thanks !. +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +void Depack_PRUN2 ( void ) +{ + Uchar poss[37][2]; + Uchar Voices[4][4]; + Uchar *Whatever; + long WholeSampleSize=0; + long i=0,j=0; + long Where=PW_Start_Address; /* main pointer to prevent fread() */ + FILE *out; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + if ( Save_Status == BAD ) + return; + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + Whatever = (Uchar *) malloc (1024); + BZERO (Whatever , 1024); + /* title */ + fwrite ( Whatever , 20 , 1 , out ); + + Where += 8; + + for ( i=0 ; i<31 ; i++ ) + { + /*sample name*/ + fwrite ( Whatever , 22 , 1 , out ); + /* size */ + WholeSampleSize += (((in_data[Where]*256)+in_data[Where+1])*2); + fwrite ( &in_data[Where] , 8 , 1 , out ); + Where += 8; + } + /*printf ( "Whole sample size : %ld\n" , WholeSampleSize );*/ + + fwrite ( &in_data[Where] , 1 , 1 , out ); + Where += 1; + + /* noisetracker byte */ + fwrite ( &in_data[Where] , 1 , 1 , out ); + Where += 1; + + Whatever[256] = 0x00; + for ( i=0 ; i<128 ; i++ ) + { + fwrite ( &in_data[Where] , 1 , 1 , out ); + Whatever[256] = ( in_data[Where] > Whatever[256] ) ? in_data[Where] : Whatever[256]; + Where += 1; + } + /*printf ( "Number of pattern : %d\n" , Whatever[256] );*/ + + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* pattern data stuff */ + Where = PW_Start_Address + 770; + for ( i=0 ; i<=Whatever[256] ; i++ ) + { + for ( j=0 ; j<256 ; j++ ) + { + Whatever[0] = in_data[Where++]; + Whatever[100]=Whatever[101]=Whatever[102]=Whatever[103]=0x00; + if ( Whatever[0] == 0x80 ) + { + fwrite ( &Whatever[100] , 4 , 1 , out ); + } + else if ( Whatever[0] == 0xC0 ) + { + fwrite ( Voices[j%4] , 4 , 1 , out ); + } + else if ( Whatever[0] != 0xC0 ) + { + Whatever[1] = in_data[Where++]; + Whatever[2] = in_data[Where++]; + + Whatever[100] = (Whatever[1]&0x80)>>3; + Whatever[100] |= poss[(Whatever[0]>>1)][0]; + Whatever[101] = poss[(Whatever[0]>>1)][1]; + Whatever[102] = (Whatever[1]&0x70) << 1; + Whatever[102] |= (Whatever[0]&0x01)<<4; + Whatever[102] |= (Whatever[1]&0x0f); + Whatever[103] = Whatever[2]; + + fwrite ( &Whatever[100] , 4 , 1 , out ); + + /* rol previous values */ + Voices[j%4][0] = Whatever[100]; + Voices[j%4][1] = Whatever[101]; + Voices[j%4][2] = Whatever[102]; + Voices[j%4][3] = Whatever[103]; + } + } + } + free ( Whatever ); + + + /* sample data */ + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + + /* crap */ + Crap ( " ProRunner v2 " , BAD , BAD , out ); + /* + fseek ( out , 830 , SEEK_SET ); + fprintf ( out , " -[Converted with]- " ); + fseek ( out , 860 , SEEK_SET ); + fprintf ( out , " -[Prorunner2 to ]- " ); + fseek ( out , 890 , SEEK_SET ); + fprintf ( out , " -[ProTracker]- " ); + fseek ( out , 920 , SEEK_SET ); + fprintf ( out , " -[by Asle /ReDoX]- " ); + */ + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} + diff --git a/prowizard/depack/qc.c b/prowizard/depack/qc.c new file mode 100755 index 00000000..8fede8a4 --- /dev/null +++ b/prowizard/depack/qc.c @@ -0,0 +1,320 @@ +/* + * QuadraComposer.c 1999 (c) Asle / ReDoX + * + * Converts QC MODs back to PTK MODs + * +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_QuadraComposer ( void ) +{ + Uchar c1=0x00,c2=0x00,c3=0x00,c4=0x00,c5=0x00; + Uchar Pat_Pos; + Uchar Pat_Max=0x00; + Uchar Real_Pat_Max=0x00; + Uchar *Whatever; + /*Uchar Row[16];*/ + Uchar Pattern[1024]; + Uchar NbrSample=0x00; + Uchar RealNbrSample=0x00; + Uchar NbrRow[128]; + Uchar poss[37][2]; /* <------ Ptk's pitch table */ + long SmpAddresses[32]; + long SmpSizes[32]; + long PatAddresses[128]; + long i=0,j=0,k=0; + long Where = PW_Start_Address; + FILE *out; + + if ( Save_Status == BAD ) + return; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + + BZERO ( SmpAddresses , 32*4 ); + BZERO ( SmpSizes , 32*4 ); + BZERO ( PatAddresses , 128*4 ); + BZERO ( NbrRow , 128 ); + + /* bypass ID's and chunk sizes */ + Where += 22; + /*fseek ( in , 22 , 0 );*/ + + /* read and write title */ + fwrite ( &in_data[Where], 20, 1, out ); + /*for ( i=0 ; i<20 ; i++ ) + { + fread ( &c1 , 1 , 1 , in ); + fwrite ( &c1 , 1 , 1 , out ); + }*/ + + /* bypass composer and tempo */ + Where += 41; /* + title */ + /*fseek ( in , 21 , 1 );*/ + + /* read number of samples */ + NbrSample = in_data[Where]; + Where += 1; + /*fread ( &NbrSample , 1 , 1 , in );*/ + + /* write empty 930 sample header */ + Whatever = (Uchar *) malloc ( 1024 ); + BZERO ( Whatever , 1024 ); + Whatever[29] = 0x01; + for ( i=0 ; i<31 ; i++ ) + fwrite ( &Whatever[0],30,1,out); + + /* read and write sample descriptions */ +/*printf ( "sample number:" );*/ + for ( i=0 ; i RealNbrSample ) + RealNbrSample = in_data[Where]; + + /* read/write sample name */ + fwrite ( &in_data[Where+4],20,1,out ); + fwrite ( Whatever,2,1,out ); /* filling */ + + /* write size */ + fwrite ( &in_data[Where+2] , 2 , 1 , out ); + /* store size */ + SmpSizes[in_data[Where]] = (((in_data[Where+2]*256)+in_data[Where+3])*2); + + /* finetune */ + fwrite ( &in_data[Where+25], 1, 1, out ); + + /* write volume */ + fwrite ( &in_data[Where+1] , 1 , 1 , out ); + + /* loops (start & len) */ + fwrite ( &in_data[Where+26],2,1,out); + if ( (in_data[Where+28] != 0x00) || (in_data[Where+29] != 0x00) ) + fwrite ( &in_data[Where+28],2,1,out); + else + fwrite ( &Whatever[28],2,1,out); + + /* read address of this sample in the file */ + SmpAddresses[in_data[Where]] =( (in_data[Where+30]*256*256*256) + + (in_data[Where+31]*256*256) + + (in_data[Where+32]*256) + + (in_data[Where+33]) ); + Where += 34; + } +/*printf ( "\n" );*/ + fseek ( out , 0 , 2 ); + + + /* patterns now */ + /* bypass "pad" ?!? */ + /*fread ( &c1 , 1 , 1 , in );*/ + if ( in_data[Where] == 0x00 ) + /*fseek ( in , -1 , 1 );*/ + Where += 1; + + /* read number of pattern */ + Pat_Max = in_data[Where++]; + /*fread ( &Pat_Max , 1 , 1 , in );*/ +/* printf ( "\nPat_Max : %d (at %x)\n" , Pat_Max , ftell ( in ) );*/ + + /* read patterns info */ +/*printf ( "pattern numbers:" );*/ + for ( i=0 ; i Real_Pat_Max ) + Real_Pat_Max = in_data[Where]; + Where += 1; + } +/*printf ( "Real_Pat_Max : %d\n" , Real_Pat_Max );*/ + /* fill up to 128 */ + BZERO (Whatever,930); + fwrite ( Whatever , 128 , 1 , out ); + + /* write ptk's ID */ + c1 = 'M'; + c2 = '.'; + c3 = 'K'; + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + fwrite ( &c3 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + + + /* pattern data */ +/*printf ( "patterns('-'=empty):" );*/ + for ( i=0 ; i<=Real_Pat_Max ; i++ ) + { + BZERO ( Pattern , 1024 ); + if ( PatAddresses[i] == 0l ) + { +/*printf ( "-(%d)" , NbrRow[i] );*/ + fwrite ( Pattern , 1024 , 1 , out ); + /* printf ( "-" );*/ + continue; + } +/*printf ( "#" );*/ + Where = PW_Start_Address + PatAddresses[i]; + /*fseek ( in , PatAddresses[i] , 0 );*/ + for ( j=0 ; j<=NbrRow[i] ; j++ ) + { + /*BZERO ( Row , 16 );*/ + /*fread ( Row , 16 , 1 , in );*/ + for ( k=0 ; k<4 ; k++ ) + { + /* Fx */ + /*Pattern[j*16+k*4+2] = Row[k*4+2];*/ + Pattern[j*16+k*4+2] = in_data[Where+k*4+2]; + + /* Fx args */ + switch ( Pattern[j*16+k*4+2] ) + { + case 0x09: + /*printf ( "#" );*/ + /*Pattern[j*16+k*4+3] = (Row[k*4+3]*2);*/ + Pattern[j*16+k*4+3] = (in_data[Where+k*4+3]*2); + break; + case 0x0b: + /*printf ( "!" );*/ + /*c4 = Row[k*4+3]%10; + c3 = Row[k*4+3]/10;*/ + c4 = in_data[Where+k*4+3]%10; + c3 = in_data[Where+k*4+3]/10; + Pattern[j*16+k*4+3] = 16; + Pattern[j*16+k*4+3] *= c3; + Pattern[j*16+k*4+3] += c4; + break; + case 0x0E: + /*if ( (Row[k*4+3]&0xf0) == 0xf0 )*/ + if ( (in_data[Where+k*4+3]&0xf0) == 0xf0 ) + /*Pattern[j*16+k*4+3] = (Row[k*4+3]-0x10);*/ + Pattern[j*16+k*4+3] = (in_data[Where+k*4+3]-0x10); + break; + default: + /*Pattern[j*16+k*4+3] = Row[k*4+3];*/ + Pattern[j*16+k*4+3] = in_data[Where+k*4+3]; + } + + /* smp nbr (4 lower bits) */ + /*Pattern[j*16+k*4+2] |= ((Row[k*4]<<4)&0xf0);*/ + Pattern[j*16+k*4+2] |= ((in_data[Where+k*4]<<4)&0xf0); + /* notes */ + /*c1 = Row[k*4+1];*/ + c1 = in_data[Where+k*4+1]; + if ( c1 != 0xff ) + { + Pattern[j*16+k*4] = poss[c1][0]; + Pattern[j*16+k*4+1] = poss[c1][1]; + } + /* smp nbr (4 higher bits) */ + /*Pattern[j*16+k*4] |= (Row[k*4]&0xf0);*/ + Pattern[j*16+k*4] |= (in_data[Where+k*4]&0xf0); + } + Where += 16; + } + fwrite ( Pattern , 1024 , 1 , out ); + } + + /* sample data */ +/*printf ( "\nsamples('-'=empty):" );*/ + for ( i=1 ; i<=RealNbrSample ; i++ ) + { + if ( SmpSizes[i] == 0 ) + { +/*printf ( "-(%ld)" , SmpSizes[i] );*/ + continue; + } +/*printf ( "#" );*/ + Where = PW_Start_Address + SmpAddresses[i]; + /*fseek ( in , SmpAddresses[i] , 0 );*/ + /*Whatever = (Uchar *) malloc ( SmpSizes[i] );*/ + /*fread ( Whatever , SmpSizes[i] , 1 , in );*/ + /*fwrite ( Whatever , SmpSizes[i] , 1 , out );*/ + fwrite ( &in_data[Where] , SmpSizes[i] , 1 , out ); + /* free ( Whatever );*/ + } +/*printf ( "\n" );*/ + + +/* printf ( "\nwhere: %ld\n" , ftell ( in ) );*/ + + + /* crap */ + Crap ( " Quadra Composer " , BAD , BAD , out ); + + + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/skyt.c b/prowizard/depack/skyt.c new file mode 100755 index 00000000..a029f96e --- /dev/null +++ b/prowizard/depack/skyt.c @@ -0,0 +1,174 @@ +/* + * Skyt_Packer.c 1997 (c) Asle / ReDoX + * + * Converts back to ptk SKYT packed MODs + ******************************************************** + * 13 april 1999 : Update + * - no more open() of input file ... so no more fread() !. + * It speeds-up the process quite a bit :). + * 28 Nov 1999 : Update + * - Speed & Size optimizings + * 19 Apr 2000 : Update + * - address of samples data bug correction + * (thx to Thomas Neumann) + * 29 Nov 2003 : Update + * - another bug removed :(. +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_SKYT ( void ) +{ + Uchar Pat_Pos; + Uchar *Whatever; + Uchar poss[37][2]; + long i=0,j=0,k=0; + long Total_Sample_Size=0; + long Track_Values[128][4]; + long Track_Address; + long Where=PW_Start_Address; /* main pointer to prevent fread() */ + long Highest_Track = 0; + FILE *out; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + if ( Save_Status == BAD ) + return; + + BZERO ( Track_Values , 128*16 ); + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* write title */ + Whatever = (Uchar *) malloc (1024); + BZERO ( Whatever , 1024 ); + /* title */ + fwrite ( Whatever , 20 , 1 , out ); + + /* read and write sample descriptions */ + for ( i=0 ; i<31 ; i++ ) + { + /*sample name*/ + fwrite ( Whatever , 22 , 1 , out ); + Total_Sample_Size += (((in_data[Where]*256)+in_data[Where+1])*2); + /* write Size,Fine,Vol & Loop start */ + fwrite ( &in_data[Where] , 6 , 1 , out ); + /* loop size */ + Whatever[32] = in_data[Where+7]; + if ( (in_data[Where+6] == 0x00) && (in_data[Where+7] == 0x00) ) + Whatever[32] = 0x01; + fwrite ( &in_data[Where+6] , 1 , 1 , out ); + fwrite ( &Whatever[32] , 1 , 1 , out ); + Where += 8; + } + /*printf ( "Whole sample size : %ld\n" , Total_Sample_Size );*/ + + /* bypass 8 empty bytes and bypass "SKYT" ID*/ + Where = PW_Start_Address + 260; + + /* pattern table lenght */ + Pat_Pos = in_data[Where]+1; + Where += 1; + fwrite ( &Pat_Pos , 1 , 1 , out ); + /*printf ( "Size of pattern list : %d\n" , Pat_Pos );*/ + + /* write NoiseTracker byte */ + Whatever[32] = 0x7f; + fwrite ( &Whatever[32] , 1 , 1 , out ); + + /* read track numbers ... and deduce pattern list */ + for ( i=0 ; i Highest_Track ) + Highest_Track = Track_Values[i][j]; + Where += 2; + } + } + /*printf ( "\nHighest track : %ld\n", Highest_Track );*/ + + /* write pseudo pattern list */ + for ( Whatever[0]=0x00 ; Whatever[0] Max ) + Max = c1; + } + c1 = 0x00; + while ( i != 128 ) + { + fwrite ( &c1 , 1 , 1 , out ); + i+=1; + } + + /* write ID */ + c1 = 'M'; + c2 = '.'; + c3 = 'K'; + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + fwrite ( &c3 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + + + /* pattern data */ + fseek ( in , 0x294 , 0 ); + Whatever = (Uchar *) malloc ( 1024 ); + for ( i=0 ; i<=Max ; i++ ) + { + BZERO ( Whatever , 1024 ); + fread ( Whatever , 1024 , 1 , in ); + for ( j=0 ; j<256 ; j++ ) + { + if ( Whatever[(j*4)] == 0xff ) + { + if ( Whatever[(j*4)+1] != 0xfe ) + printf ( "Volume unknown : (at:%ld) (fx:%x,%x,%x,%x)\n" , ftell (in) + , Whatever[(j*4)] + , Whatever[(j*4)+1] + , Whatever[(j*4)+2] + , Whatever[(j*4)+3] ); + Whatever[(j*4)] = 0x00; + Whatever[(j*4)+1] = 0x00; + Whatever[(j*4)+2] = 0x0C; + Whatever[(j*4)+3] = 0x00; + continue; + } + switch ( Whatever[(j*4)+2]&0x0f ) + { + case 1: /* arpeggio */ + Whatever[(j*4)+2] &= 0xF0; + break; + case 7: /* slide up */ + case 8: /* slide down */ + Whatever[(j*4)+2] -= 0x06; + break; + case 3: /* empty ... same as followings ... but far too much to "printf" it */ + case 6: /* and Noiseconverter puts 00 instead ... */ + Whatever[(j*4)+2] &= 0xF0; + Whatever[(j*4)+3] = 0x00; + break; + case 2: + case 4: + case 5: + case 9: + case 0x0a: + case 0x0b: + case 0x0c: + case 0x0d: + case 0x0e: + case 0x0f: + printf ( "unsupported effect : (at:%ld) (fx:%d)\n" , ftell (in) , Whatever[(j*4)+2]&0x0f ); + Whatever[(j*4)+2] &= 0xF0; + Whatever[(j*4)+3] = 0x00; + break; + default: + break; + } + } + fwrite ( Whatever , 1024 , 1 , out ); + fflush ( stdout ); + } + free ( Whatever ); + fflush ( stdout ); + + + /* sample data */ + Whatever = (Uchar *) malloc ( WholeSampleSize ); + BZERO ( Whatever , WholeSampleSize ); + fread ( Whatever , WholeSampleSize , 1 , in ); + fwrite ( Whatever , WholeSampleSize , 1 , out ); + free ( Whatever ); + fflush ( stdout ); + + + /* crap */ + Crap ( " Sound FX " , BAD , BAD , out ); + + fflush ( in ); + fflush ( out ); + fclose ( in ); + fclose ( out ); + + printf ( "done\n" + " WARNING: This is only an under development converter !\n" + " output could sound strange...\n" ); + return; /* useless ... but */ + +} diff --git a/prowizard/depack/starpack.c b/prowizard/depack/starpack.c new file mode 100755 index 00000000..6fe4e814 --- /dev/null +++ b/prowizard/depack/starpack.c @@ -0,0 +1,178 @@ +/* + * StarTrekker _Packer.c 1997 (c) Asle / ReDoX + * + * Converts back to ptk StarTrekker packed MODs + * +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +void Depack_STARPACK ( void ) +{ + Uchar c1=0x00,c2=0x00; + Uchar Pat_Pos; + Uchar *Whatever; + Uchar *Pattern; + long i=0,j=0,k=0; + long Total_Sample_Size=0; + long Pats_Address[128]; + long Read_Pats_Address[128]; + long SampleDataAddress=0; + long Where = PW_Start_Address; + long MaxPatAddy=0; + FILE /**in,*/*out; + + if ( Save_Status == BAD ) + return; + + BZERO ( Pats_Address , 128*4 ); + + /*in = fopen ( OutName_final , "r+b" );*/ /* +b is safe bcoz OutName's just been saved */ + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + + Whatever = (Uchar *) malloc (1024); + BZERO (Whatever, 1024); + + /* read and write title */ + fwrite (&in_data[Where], 20, 1, out ); + Where += 20; + + /* read and write sample descriptions */ + for ( i=0 ; i<31 ; i++ ) + { + fwrite ( &Whatever[0], 22, 1, out ); + /*sample name*/ + + Total_Sample_Size += (((in_data[Where+i*8]*256)+in_data[Where+1+i*8])*2); + fwrite ( &in_data[Where+i*8], 8, 1, out ); + } + /*printf ( "Whole sample size : %ld\n" , Total_Sample_Size );*/ + Where = PW_Start_Address + 268; + + /* read size of pattern table */ + Pat_Pos = ((in_data[Where]*256)+in_data[Where+1])/4; + Where += 4; + fwrite ( &Pat_Pos, 1, 1, out ); + /*printf ( "Size of pattern table : %d\n" , Pat_Pos );*/ + /* bypass $0000 unknown bytes */ + +/***********/ + + for ( i=0 ; i<128 ; i++ ) + { + Pats_Address[i] = (in_data[Where]*256*256*256)+(in_data[Where+1]*256*256)+(in_data[Where+2]*256)+in_data[Where+3]; + Where+=4; + if ( Pats_Address[i] > MaxPatAddy ) + MaxPatAddy = Pats_Address[i]; + } + + + /* write noisetracker byte */ + c1 = 0x7f; + fwrite ( &c1 , 1 , 1 , out ); + +/***********/ + + + /* read sample data address */ + Where = PW_Start_Address + 0x310; + SampleDataAddress = (in_data[Where]*256*256*256)+(in_data[Where+1]*256*256)+(in_data[Where+2]*256)+in_data[Where+3]+0x314; + + /* pattern data */ + Where += 4; + /*PatMax += 1;*/ + + c1=0; /* will count patterns */ + k=0; /* current note number */ + Pattern = (Uchar *) malloc (65536); + BZERO (Pattern, 65536); + i=0; + for ( j=0 ; j<(MaxPatAddy+0x400) ; j+=4 ) + { + if ( (i%1024) == 0 ) + { + if ( j>MaxPatAddy ) + break; + Read_Pats_Address[c1] = j; + c1 += 0x01; + } + if (in_data[Where+j] == 0x80 ) + { + j -= 3; + i += 4; + continue; + } + + c2 = ((in_data[Where+j]) | ((in_data[Where+j+2]>>4)&0x0f)) / 4; + + Pattern[i] = in_data[Where+j] & 0x0f; + Pattern[i] |= (c2&0xf0); + Pattern[i+1] = in_data[Where+j+1]; + Pattern[i+2] = in_data[Where+j+2] & 0x0f; + Pattern[i+2]|= ((c2<<4)&0xf0); + Pattern[i+3] = in_data[Where+j+3]; + + i += 4; + } + /* Where should be now on the sample data addy */ + + /* write pattern list */ + /* write pattern table */ + BZERO ( Whatever, 128 ); + for ( c2=0; c2<128 ; c2+=0x01 ) + for ( i=0 ; i<128 ; i++ ) + if ( Pats_Address[c2] == Read_Pats_Address[i]) + { + Whatever[c2] = (Uchar) i; + break; + } + fwrite ( &Whatever[0], 128, 1, out ); + + /* write ptk's ID */ + Whatever[0] = 'M';Whatever[1] = '.';Whatever[2] = 'K'; + fwrite ( &Whatever[0] , 1 , 1 , out ); + fwrite ( &Whatever[1] , 1 , 1 , out ); + fwrite ( &Whatever[2] , 1 , 1 , out ); + fwrite ( &Whatever[1] , 1 , 1 , out ); + free (Whatever); + + /* write pattern data */ + /* c1 is still the number of patterns stored */ + fwrite ( Pattern, c1*1024, 1, out ); + + /* sample data */ + Where = PW_Start_Address + SampleDataAddress; + + fwrite ( &in_data[Where] , Total_Sample_Size , 1 , out ); + + + Crap ( " StarTrekker Pack " , BAD , BAD , out ); + /* + fseek ( out , 830 , SEEK_SET ); + fprintf ( out , " -[Converted with]- " ); + fseek ( out , 860 , SEEK_SET ); + fprintf ( out , "-[StarTrekker pack]-" ); + fseek ( out , 890 , SEEK_SET ); + fprintf ( out , " -[2 Protracker]- " ); + fseek ( out , 920 , SEEK_SET ); + fprintf ( out , " -[by Asle /ReDoX]- " ); + */ + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/stim.c b/prowizard/depack/stim.c new file mode 100755 index 00000000..d7c4f32c --- /dev/null +++ b/prowizard/depack/stim.c @@ -0,0 +1,207 @@ +/* + * STIM_Packer.c 1998 (c) Sylvain "Asle" Chipaux + * + * STIM Packer to Protracker. + ******************************************************** + * 13 april 1999 : Update + * - no more open() of input file ... so no more fread() !. + * It speeds-up the process quite a bit :). + * 28 Nov 1999 : Update + * - Speed & Size optimizings +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_STIM ( void ) +{ + Uchar *Whatever; + Uchar c1=0x00,c2=0x00,c3=0x00,c4=0x00; + Uchar poss[36][2]; + Uchar Max=0x00; + Uchar Note,Smp,Fx,FxVal; + short TracksAdd[4]; + long i=0,j=0,k=0; + long WholeSampleSize=0; + long SmpDescAdd=0; + long PatAdds[64]; + long SmpDataAdds[31]; + long SmpSizes[31]; + long Where=PW_Start_Address; /* main pointer to prevent fread() */ + FILE *out; + + if ( Save_Status == BAD ) + return; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + BZERO ( PatAdds , 64*4 ); + BZERO ( SmpDataAdds , 31*4 ); + BZERO ( SmpSizes , 31*4 ); + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* write title */ + Whatever = (Uchar *) malloc (1024); + BZERO ( Whatever , 1024 ); + fwrite ( Whatever , 20 , 1 , out ); + + /* bypass ID */ + Where += 4; + + /* read $ of sample description */ + SmpDescAdd = (in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3]; + /* "Where" isn't "+=4" coz it's assigned below */ + /*printf ( "SmpDescAdd : %ld\n" , SmpDescAdd );*/ + + /* convert and write header */ + for ( i=0 ; i<31 ; i++ ) + { + Where = PW_Start_Address + SmpDescAdd + i*4; + SmpDataAdds[i]=(in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3]; + SmpDataAdds[i] += SmpDescAdd; + Where = PW_Start_Address + SmpDataAdds[i]; + SmpDataAdds[i] += 8; + + /* write sample name */ + fwrite ( Whatever , 22 , 1 , out ); + + /* sample size */ + SmpSizes[i] = (((in_data[Where]*256)+in_data[Where+1])*2); + WholeSampleSize += (((in_data[Where]*256)+in_data[Where+1])*2); + /* size,fine,vol,loops */ + fwrite ( &in_data[Where] , 8 , 1 , out ); + + /* no "Where += 8" coz it's reassigned inside and after loop */ + } + + /* size of the pattern list */ + Where = PW_Start_Address + 19; + fwrite ( &in_data[Where++] , 1 , 1 , out ); + Whatever[0] = 0x7f; + fwrite ( Whatever , 1 , 1 , out ); + + /* pattern table */ + Where += 1; + Max = in_data[Where++]; + fwrite ( &in_data[Where] , 128 , 1 , out ); + Where += 128; + + /*printf ( "number of pattern : %d\n" , Max );*/ + + /* write Protracker's ID */ + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* read pattern addresses */ + for ( i=0 ; i<64 ; i++ ) + { + PatAdds[i] = (in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3]; + PatAdds[i] += 0x0c; + Where += 4; + } + + /* pattern data */ + for ( i=0 ; i>5)&0x03); + c4 = ((c2>>4)&0x0C); + Fx |= c4; + FxVal = c3; + + Whatever[j*16+k*4] = (Smp & 0xf0); + + if ( Note != 0 ) + { + Whatever[j*16+k*4] |= poss[Note-1][0]; + Whatever[j*16+k*4+1] = poss[Note-1][1]; + } + + Whatever[j*16+k*4+2] = ((Smp<<4)&0xf0); + Whatever[j*16+k*4+2] |= Fx; + Whatever[j*16+k*4+3] = FxVal; + } + } + fwrite ( Whatever , 1024 , 1 , out ); +/* printf ( "pattern %ld written\n" , i );*/ + } + free ( Whatever ); + + /* sample data */ + for ( i=0 ; i<31 ; i++ ) + { + Where = PW_Start_Address + SmpDataAdds[i]; + fwrite ( &in_data[Where] , SmpSizes[i] , 1 , out ); + } + + + Crap ( " STIM (Slamtilt) " , BAD , BAD , out ); + /* + fseek ( out , 830 , SEEK_SET ); + fprintf ( out , " -[Converted with]- " ); + fseek ( out , 860 , SEEK_SET ); + fprintf ( out , " -[STIM packer to]- " ); + fseek ( out , 890 , SEEK_SET ); + fprintf ( out , " -[ProTracker]- " ); + fseek ( out , 920 , SEEK_SET ); + fprintf ( out , " -[by Asle /ReDoX]- " ); + */ + + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/stk26.c b/prowizard/depack/stk26.c new file mode 100755 index 00000000..c3db7389 --- /dev/null +++ b/prowizard/depack/stk26.c @@ -0,0 +1,105 @@ +/* + * STK26.c 1999 (c) Asle / ReDoX + * + * + * handles Soundtracker 2.6 and IceTracker 1.0 file + * convert them back to PTK + * + * Update: 19/04/00 + * - forced 7F value to NTK byte + * Update: 29/05/02 + * - above update was bugged ... great. +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_STK26 ( void ) +{ + Uchar *Whatever; + long WholeSampleSize=0; + long Where=PW_Start_Address; + long i=0,j,k; + FILE *out; + + if ( Save_Status == BAD ) + return; + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + + /* read and write whole header */ + fwrite ( &in_data[Where] , 952 , 1 , out ); + + /* get whole sample size */ + for ( i=0 ; i<31 ; i++ ) + WholeSampleSize += (((in_data[Where+42+i*30]*256)+in_data[Where+43+i*30])*2); + /* printf ( "Whole sanple size : %ld\n" , WholeSampleSize );*/ + + /* generate patlist */ + Whatever = (Uchar *) malloc (1536); + BZERO ( Whatever , 1536 ); + Whatever[1024] = in_data[Where+950]; + for ( i=0 ; i PatMax ) + PatMax = in_data[Where+i+2]; + Where += 130; +/* printf ( "highest pattern number : %x\n" , PatMax );*/ + + + /* sample descriptions */ +/* printf ( "sample sizes/addresses:" );*/ + for ( i=0 ; i<31 ; i++ ) + { + fseek ( out , 42+(i*30) , 0 ); + /* sample address */ + SampleAddresses[i] = ((in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3]); + Where += 4; + /* read/write size */ + Whole_Sample_Size += (((in_data[Where]*256)+in_data[Where+1])*2); + SampleSizes[i] = (((in_data[Where]*256)+in_data[Where+1])*2); + fwrite ( &in_data[Where],2,1,out); + Where += 2; +/* printf ( "%5ld ,%ld" , SampleSizes[i] , SampleAddresses[i]);*/ + + /* read/write finetune */ + /* read/write volume */ + fwrite ( &in_data[Where] , 2 , 1 , out ); + Where += 2; + + /* read loop start address */ + j = ((in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3]); + Where += 4; + j -= SampleAddresses[i]; + j /= 2; + /* use of htonl() suggested by Xigh !.*/ + z = htonl(j); + c1 = *((Uchar *)&z+2); + c2 = *((Uchar *)&z+3); + + /* write loop start */ + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + + /* read/write replen */ + fwrite ( &in_data[Where],2,1,out); + Where += 2; + } +/* printf ( "\nWhole sample size : %ld\n" , Whole_Sample_Size );*/ + + + /* bypass Samples datas */ + Where += Whole_Sample_Size; +/* printf ( "address of the pattern data : %ld (%x)\n" , ftell ( in ) , ftell ( in ) );*/ + + /* write ptk's ID string */ + fseek ( out , 0 , 2 ); + c1 = 'M'; + c2 = '.'; + c3 = 'K'; + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + fwrite ( &c3 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + + + /* read/write pattern data */ + for ( i=0 ; i<=PatMax ; i++ ) + { + BZERO ( Pattern , 1024 ); + for ( j=0 ; j<64 ; j++ ) + { +/*fprintf ( info , "at : %ld\n" , (ftell ( in )-1024+j*16) );*/ + for ( k=0 ; k<4 ; k++ ) + { + /* fx arg */ + Pattern[j*16+k*4+3] = in_data[Where+j*16+k*4+3]; + + /* fx */ + Pattern[j*16+k*4+2] = in_data[Where+j*16+k*4+2]&0x0f; + + /* smp */ + Pattern[j*16+k*4] = in_data[Where+j*16+k*4]&0xf0; + Pattern[j*16+k*4+2] |= (in_data[Where+j*16+k*4]<<4)&0xf0; + + /* note */ + Pattern[j*16+k*4] |= poss[in_data[Where+j*16+k*4+1]/2][0]; +/*fprintf ( info , "(P[0]:%x)" , Pattern[j*16+k*4] );*/ + Pattern[j*16+k*4+1] = poss[in_data[Where+j*16+k*4+1]/2][1]; +/*fprintf ( info , "%2x ,%2x ,%2x ,%2x |\n" + , Whatever[j*16+k*4] + , Whatever[j*16+k*4+1] + , Whatever[j*16+k*4+2] + , Whatever[j*16+k*4+3] ); +*/ + } + } + fwrite ( Pattern , 1024 , 1 , out ); + Where += 1024; + } + + + /* Sample data */ +/* printf ( "samples:" );*/ + for ( i=0 ; i<31 ; i++ ) + { + if ( SampleSizes[i] == 0l ) + { +/* printf ( "-" );*/ + continue; + } + Where = PW_Start_Address + SampleAddresses[i]; + fwrite ( &in_data[Where] , SampleSizes[i] , 1 , out ); +/* printf ( "+" );*/ + } + + + Crap ( " The Dark Demon " , BAD , BAD , out ); + + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/tp1.c b/prowizard/depack/tp1.c new file mode 100755 index 00000000..16c66f2b --- /dev/null +++ b/prowizard/depack/tp1.c @@ -0,0 +1,204 @@ +/* + * TrackerPacker_v1.c 1998 (c) Asle / ReDoX + * + * Converts TP1 packed MODs back to PTK MODs + * thanks to Gryzor and his ProWizard tool ! ... without it, this prog + * would not exist !!! + * + * Update : 1 may 2003 + * - changed way to locate pattern datas. Correct pattern list saved now. + * +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_TP1 ( void ) +{ + Uchar c1=0x00,c2=0x00,c3=0x00; + Uchar poss[37][2]; + Uchar *Whatever; + Uchar Note,Smp,Fx,FxVal; + Uchar Patternlist[128]; + Uchar PatPos; + long Pats_Address[128]; + long i=0,j=0,k; + long Pats_Address_read[128]; + long Start_Pat_Address; + long Whole_Sample_Size=0; + long Sample_Data_Address; + long Where=PW_Start_Address; + FILE *out; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + if ( Save_Status == BAD ) + return; + + BZERO ( Pats_Address , 128*4 ); + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* title */ + Whatever = (Uchar *) malloc (65536); + BZERO ( Whatever , 65536 ); + fwrite ( &in_data[Where+8] , 20 , 1 , out ); + + /* setting the first pattern address as the whole file size */ + Start_Pat_Address = 0xFFFFFF; + + Where += 28; + /* sample data address */ + Sample_Data_Address = (in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3]; + Where += 4; +/*printf ( "sample data address : %ld\n" , Sample_Data_Address );*/ + + for ( i=0 ; i<31 ; i++ ) + { + /*sample name*/ + fwrite ( Whatever , 22 , 1 , out ); + + /* size */ + Whole_Sample_Size += (((in_data[Where+2]*256)+in_data[Where+3])*2); + fwrite ( &in_data[Where+2] , 2 , 1 , out ); + + /* write finetune,vol */ + fwrite ( &in_data[Where] , 2 , 1 , out ); + + /* loops */ + fwrite ( &in_data[Where+4] , 4 , 1 , out ); + + Where += 8; + } + /*printf ( "Whole sample size : %ld\n" , Whole_Sample_Size );*/ + + /* read size of pattern table */ + Where = PW_Start_Address + 281; + PatPos = in_data[Where]+0x01; + fwrite ( &PatPos , 1 , 1 , out ); + Where += 1; + + /* ntk byte */ + c1 = 0x7f; + fwrite ( &c1 , 1 , 1 , out ); + + for ( i=0 ; i Pats_Address[i] ) + Start_Pat_Address = Pats_Address[i]; + /*printf ( "[at:%ld]%3ld: %ld\n" , Where-4,i,Pats_Address[i] );*/ + } + + /*printf ( "Start_Pat_Address : %ld\n",Start_Pat_Address);*/ + + /* setting real addresses */ + for ( i=0 ; i>2)&0x0f; + FxVal = c2; + Whatever[j+2] = Fx; + Whatever[j+3] = FxVal; + i += 1; + continue; + } + c2 = in_data[i+1]; + c3 = in_data[i+2]; + + Smp = ((c2>>4)&0x0f) | ((c1<<4)&0x10); + Note = c1&0xFE; + Fx = c2&0x0F; + FxVal = c3; + + Whatever[j] = Smp&0xf0; + Whatever[j] |= poss[(Note/2)][0]; + Whatever[j+1] = poss[(Note/2)][1]; + Whatever[j+2] = (Smp<<4)&0xf0; + Whatever[j+2] |= Fx; + Whatever[j+3] = FxVal; + i += 2; + } + k -= 1; + Pats_Address_read[k] = 0; + BZERO (Patternlist,128); + for ( i=0 ; i PatMax ) + PatMax = Pats_Numbers[i]; + /*fprintf ( info , "%3ld: %d\n" , i,Pats_Numbers[i] );*/ + } + + /* read tracks addresses */ + /* bypass 4 bytes or not ?!? */ + /* Here, I choose not :) */ + /*fprintf ( info , "track addresses :\n" );*/ + for ( i=0 ; i<=PatMax ; i++ ) + { + for ( j=0 ; j<4 ; j++ ) + { + Track_Address[i][j] = (in_data[Where]*256)+in_data[Where+1]; + Where += 2; + if ( Track_Address[i][j] > Max_Track_Address ) + Max_Track_Address = Track_Address[i][j]; + /*fprintf ( info , "%6ld, " , Track_Address[i][j] );*/ + } + } + /*fprintf ( info , " (%x)\n" , Max_Track_Address );fflush(info);*/ + /*printf ( "Highest pattern number : %d\n" , PatMax );*/ + + /* write pattern list */ + fwrite ( Pats_Numbers , 128 , 1 , out ); + + + /* ID string */ + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + Start_Pat_Address = Where + 2; + /*printf ( "address of the first pattern : %ld\n" , Start_Pat_Address );*/ + /*fprintf ( info , "address of the first pattern : %x\n" , Start_Pat_Address );*/ + + /* pattern datas */ + /*printf ( "converting pattern data " );*/ + for ( i=0 ; i<=PatMax ; i++ ) + { + /*fprintf ( info , "\npattern %ld:\n\n" , i );*/ + BZERO ( Whatever , 1024 ); + for ( j=0 ; j<4 ; j++ ) + { +/*fprintf ( info , "track %ld: (at %ld)\n" , j , Track_Address[i][j]+Start_Pat_Address );*/ + Where = Track_Address[i][j]+Start_Pat_Address; + for ( k=0 ; k<64 ; k++ ) + { + c1 = in_data[Where++]; +/*fprintf ( info , "%ld: %2x," , k , c1 );*/ + if ( (c1&0xC0) == 0xC0 ) + { +/*fprintf ( info , " <--- %d empty lines\n" , (0x100-c1) );*/ + k += (0x100-c1); + k -= 1; + continue; + } + if ( (c1&0xC0) == 0x80 ) + { + c2 = in_data[Where++]; +/*fprintf ( info , "%2x ,\n" , c2 );*/ + Fx = (c1>>2)&0x0f; + FxVal = c2; + if ( (Fx==0x05) || (Fx==0x06) || (Fx==0x0A) ) + { + if ( FxVal > 0x80 ) + FxVal = 0x100-FxVal; + else if ( FxVal <= 0x80 ) + FxVal = (FxVal<<4)&0xf0; + } + if ( Fx == 0x08 ) + Fx = 0x00; + Whatever[k*16+j*4+2] = Fx; + Whatever[k*16+j*4+3] = FxVal; + continue; + } + + c2 = in_data[Where++]; +/*fprintf ( info , "%2x, " , c2 );*/ + Smp = ((c2>>4)&0x0f) | ((c1<<4)&0x10); + Note = c1&0xFE; + Fx = c2&0x0F; + if ( Fx == 0x00 ) + { +/*fprintf ( info , " <--- No FX !!\n" );*/ + Whatever[k*16+j*4] = Smp&0xf0; + Whatever[k*16+j*4] |= poss[(Note/2)][0]; + Whatever[k*16+j*4+1] = poss[(Note/2)][1]; + Whatever[k*16+j*4+2] = (Smp<<4)&0xf0; + Whatever[k*16+j*4+2] |= Fx; + continue; + } + c3 = in_data[Where++]; +/*fprintf ( info , "%2x\n" , c3 );*/ + if ( Fx == 0x08 ) + Fx = 0x00; + FxVal = c3; + if ( (Fx==0x05) || (Fx==0x06) || (Fx==0x0A) ) + { + if ( FxVal > 0x80 ) + FxVal = 0x100-FxVal; + else if ( FxVal <= 0x80 ) + FxVal = (FxVal<<4)&0xf0; + } + + Whatever[k*16+j*4] = Smp&0xf0; + Whatever[k*16+j*4] |= poss[(Note/2)][0]; + Whatever[k*16+j*4+1] = poss[(Note/2)][1]; + Whatever[k*16+j*4+2] = (Smp<<4)&0xf0; + Whatever[k*16+j*4+2] |= Fx; + Whatever[k*16+j*4+3] = FxVal; + } + if ( Where > Max_Track_Address ) + Max_Track_Address = Where; + /*printf ( "%6ld, " , Max_Track_Address );*/ + } + fwrite ( Whatever , 1024 , 1 , out ); + /*printf ( "." );*/ + } + free ( Whatever ); + /*printf ( " ok\n" );*/ + + /*printf ( "sample data address : %ld\n" , Max_Track_Address );*/ + + /* Sample data */ + fwrite ( &in_data[Max_Track_Address] , Whole_Sample_Size , 1 , out ); + + + Crap ( " Tracker Packer 2 " , BAD , BAD , out ); + + + fflush ( out ); + fclose ( out ); + /*fclose ( info );*/ + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/tp3.c b/prowizard/depack/tp3.c new file mode 100755 index 00000000..975fd5d8 --- /dev/null +++ b/prowizard/depack/tp3.c @@ -0,0 +1,259 @@ +/* + * TrackerPacker_v3.c 1998 (c) Asle / ReDoX + * + * Converts TP3 packed MODs back to PTK MODs + ******************************************************** + * 13 april 1999 : Update + * - no more open() of input file ... so no more fread() !. + * It speeds-up the process quite a bit :). + * + * 28 November 1999 : Update + * - Some Optimizing for Speed and for Size. +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_TP3 ( void ) +{ + Uchar c1=0x00,c2=0x00,c3=0x00; + Uchar poss[37][2]; + Uchar *Whatever; + Uchar Note,Smp,Fx,FxVal; + Uchar PatMax=0x00; + long Track_Address[128][4]; + long i=0,j=0,k; + long Start_Pat_Address=999999l; + long Whole_Sample_Size=0; + long Max_Track_Address=0; + long Where=PW_Start_Address; /* main pointer to prevent fread() */ + FILE *out; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + if ( Save_Status == BAD ) + return; + + BZERO ( Track_Address , 128*4*4 ); + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* title */ + Where += 8; + fwrite ( &in_data[Where] , 20 , 1 , out ); + Where += 20; + + /* number of sample */ + j = (in_data[Where]*256)+in_data[Where+1]; + Where += 2; + j /= 8; + /*printf ( "number of sample : %ld\n" , j );*/ + + Whatever = (Uchar *) malloc ( 1024 ); + BZERO ( Whatever , 1024 ); + for ( i=0 ; i PatMax ) + PatMax = Whatever[i]; +/*fprintf ( info , "%3ld: %ld\n" , i,Pats_Address[i] );*/ + } + + /* read tracks addresses */ + /* bypass 4 bytes or not ?!? */ + /* Here, I choose not :) */ +/*fprintf ( info , "track addresses :\n" );*/ + for ( i=0 ; i<=PatMax ; i++ ) + { + for ( j=0 ; j<4 ; j++ ) + { + Track_Address[i][j] = (in_data[Where]*256)+in_data[Where+1]; + Where += 2; + if ( Track_Address[i][j] > Max_Track_Address ) + Max_Track_Address = Track_Address[i][j]; +/*fprintf ( info , "%6ld, " , Track_Address[i][j] );*/ + } +/*fprintf ( info , " (%x)\n" , Max_Track_Address );*/ + } + + /*printf ( "Highest pattern number : %d\n" , PatMax );*/ + + /* write pattern list */ + fwrite ( Whatever , 128 , 1 , out ); + + + /* ID string */ + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + Start_Pat_Address = Where + 2; + /*printf ( "address of the first pattern : %ld\n" , Start_Pat_Address );*/ +/*fprintf ( info , "address of the first pattern : %x\n" , Start_Pat_Address );*/ + + /* pattern datas */ + /*printf ( "converting pattern data " );*/ + for ( i=0 ; i<=PatMax ; i++ ) + { +/*fprintf ( info , "\npattern %ld:\n\n" , i );*/ + BZERO ( Whatever , 1024 ); + for ( j=0 ; j<4 ; j++ ) + { +/*fprintf ( info , "track %ld: (at %ld)\n" , j , Track_Address[i][j]+Start_Pat_Address );*/ + Where = Track_Address[i][j]+Start_Pat_Address; + for ( k=0 ; k<64 ; k++ ) + { + c1 = in_data[Where++]; +/*fprintf ( info , "%ld: %2x," , k , c1 );*/ + if ( (c1&0xC0) == 0xC0 ) + { +/*fprintf ( info , " <--- %d empty lines\n" , (0x100-c1) );*/ + k += (0x100-c1); + k -= 1; + continue; + } + if ( (c1&0xC0) == 0x80 ) + { + c2 = in_data[Where++]; +/*fprintf ( info , "%2x ,\n" , c2 );*/ + Fx = (c1>>1)&0x0f; + FxVal = c2; + if ( (Fx==0x05) || (Fx==0x06) || (Fx==0x0A) ) + { + if ( FxVal > 0x80 ) + FxVal = 0x100-FxVal; + else if ( FxVal <= 0x80 ) + FxVal = (FxVal<<4)&0xf0; + } + if ( Fx == 0x08 ) + Fx = 0x00; + Whatever[k*16+j*4+2] = Fx; + Whatever[k*16+j*4+3] = FxVal; + continue; + } + + c2 = in_data[Where++]; +/*fprintf ( info , "%2x, " , c2 );*/ + Smp = ((c2>>4)&0x0f) | ((c1>>2)&0x10); + if ( (c1&0x40) == 0x40 ) + Note = 0x7f-c1; + else + Note = c1&0x3F; + Fx = c2&0x0F; + if ( Fx == 0x00 ) + { +/*fprintf ( info , " <--- No FX !!\n" );*/ + Whatever[k*16+j*4] = Smp&0xf0; + Whatever[k*16+j*4] |= poss[Note][0]; + Whatever[k*16+j*4+1] = poss[Note][1]; + Whatever[k*16+j*4+2] = (Smp<<4)&0xf0; + Whatever[k*16+j*4+2] |= Fx; + continue; + } + c3 = in_data[Where++]; +/*fprintf ( info , "%2x\n" , c3 );*/ + if ( Fx == 0x08 ) + Fx = 0x00; + FxVal = c3; + if ( (Fx==0x05) || (Fx==0x06) || (Fx==0x0A) ) + { + if ( FxVal > 0x80 ) + FxVal = 0x100-FxVal; + else if ( FxVal <= 0x80 ) + FxVal = (FxVal<<4)&0xf0; + } + + Whatever[k*16+j*4] = Smp&0xf0; + Whatever[k*16+j*4] |= poss[Note][0]; + Whatever[k*16+j*4+1] = poss[Note][1]; + Whatever[k*16+j*4+2] = (Smp<<4)&0xf0; + Whatever[k*16+j*4+2] |= Fx; + Whatever[k*16+j*4+3] = FxVal; + } + if ( Where > Max_Track_Address ) + Max_Track_Address = Where; +/*fprintf ( info , "%6ld, " , Max_Track_Address );*/ + } + fwrite ( Whatever , 1024 , 1 , out ); + /*printf ( "." );*/ + } + free ( Whatever ); + /*printf ( " ok\n" );*/ + + /*printf ( "sample data address : %ld\n" , Max_Track_Address );*/ + + /* Sample data */ + if ( ((Max_Track_Address/2)*2) != Max_Track_Address ) + Max_Track_Address += 1; + fwrite ( &in_data[Max_Track_Address] , Whole_Sample_Size , 1 , out ); + + Crap ( " Tracker Packer 3 " , BAD , BAD , out ); + /* + fseek ( out , 830 , SEEK_SET ); + fprintf ( out , "[Converted with ]" ); + fseek ( out , 860 , SEEK_SET ); + fprintf ( out , "[TrackerPacker v3 ]" ); + fseek ( out , 890 , SEEK_SET ); + fprintf ( out , "[to Protracker ]" ); + fseek ( out , 920 , SEEK_SET ); + fprintf ( out , "[by Asle /ReDoX ]" ); + */ + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/unic.c b/prowizard/depack/unic.c new file mode 100755 index 00000000..73c30941 --- /dev/null +++ b/prowizard/depack/unic.c @@ -0,0 +1,228 @@ +/* + * Unic_Tracker.c 1997 (c) Asle / ReDoX + * + * + * Unic tracked MODs to Protracker + * both with or without ID Unic files will be converted + ******************************************************** + * 13 april 1999 : Update + * - no more open() of input file ... so no more fread() !. + * It speeds-up the process quite a bit :). + * +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +#define ON 1 +#define OFF 2 + +void Depack_UNIC ( void ) +{ + Uchar c1=0x00,c2=0x00,c3=0x00,c4=0x00; + Uchar NumberOfPattern=0x00; + Uchar poss[37][2]; + Uchar Max=0x00; + Uchar Smp,Note,Fx,FxVal; + Uchar fine=0x00; + Uchar Pattern[1025]; + Uchar LOOP_START_STATUS=OFF; /* standard /2 */ + long i=0,j=0,k=0,l=0; + long WholeSampleSize=0; + long Where=PW_Start_Address; /* main pointer to prevent fread() */ + FILE *out; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + if ( Save_Status == BAD ) + return; + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* title */ + fwrite ( &in_data[Where] , 20 , 1 , out ); + Where += 20; + + + for ( i=0 ; i<31 ; i++ ) + { + /* sample name */ + fwrite ( &in_data[Where] , 20 , 1 , out ); + c1 = 0x00; + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c1 , 1 , 1 , out ); + Where += 20; + + /* fine on ? */ + c1 = in_data[Where++]; + c2 = in_data[Where++]; + j = (c1*256)+c2; + if ( j != 0 ) + { + if ( j < 256 ) + fine = 0x10-c2; + else + fine = 0x100-c2; + } + else + fine = 0x00; + + /* smp size */ + c1 = in_data[Where++]; + c2 = in_data[Where++]; + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + l = ((c1*256)+c2)*2; + WholeSampleSize += l; + + /* fine */ + Where += 1; + fwrite ( &fine , 1 , 1 , out ); + + /* vol */ + fwrite ( &in_data[Where++] , 1 , 1 , out ); + + /* loop start */ + c1 = in_data[Where++]; + c2 = in_data[Where++]; + + /* loop size */ + c3 = in_data[Where++]; + c4 = in_data[Where++]; + + j=((c1*256)+c2)*2; + k=((c3*256)+c4)*2; + if ( (((j*2) + k) <= l) && (j!=0) ) + { + LOOP_START_STATUS = ON; + c1 *= 2; + j = c2*2; + if ( j>256 ) + c1 += 1; + c2 *= 2; + } + + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + + fwrite ( &c3 , 1 , 1 , out ); + fwrite ( &c4 , 1 , 1 , out ); + } + + +/* printf ( "whole sample size : %ld\n" , WholeSampleSize );*/ +/* + if ( LOOP_START_STATUS == ON ) + printf ( "!! Loop start value was /4 !\n" ); +*/ + /* number of pattern */ + NumberOfPattern = in_data[Where++]; + fwrite ( &NumberOfPattern , 1 , 1 , out ); + + /* noisetracker byte */ + c1 = 0x7f; + fwrite ( &c1 , 1 , 1 , out ); + Where += 1; + + /* Pattern table */ + fwrite ( &in_data[Where] , 128 , 1 , out ); + Where += 128; + + /* get highest pattern number */ + for ( i=0 ; i<128 ; i++ ) + { + if ( in_data[PW_Start_Address+952+i] > Max ) + Max = in_data[PW_Start_Address+952+i]; + } + Max += 1; /* coz first is $00 */ + + c1 = 'M'; + c2 = '.'; + c3 = 'K'; + fwrite ( &c1 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + fwrite ( &c3 , 1 , 1 , out ); + fwrite ( &c2 , 1 , 1 , out ); + + /* verify UNIC ID */ + Where = PW_Start_Address + 1080; + if ( (strncmp ( (char *)&in_data[Where] , "M.K." , 4 ) == 0) || + (strncmp ( (char *)&in_data[Where] , "UNIC" , 4 ) == 0) || + ((in_data[Where]==0x00)&&(in_data[Where+1]==0x00)&&(in_data[Where+2]==0x00)&&(in_data[Where+3]==0x00))) + Where = PW_Start_Address + 1084l; + else + Where = PW_Start_Address + 1080l; + + + /* pattern data */ + for ( i=0 ; i>2) & 0x10) | ((in_data[Where+j*3+1]>>4)&0x0f); + Note = in_data[Where+j*3]&0x3f; + Fx = in_data[Where+j*3+1]&0x0f; + FxVal = in_data[Where+j*3+2]; + + if ( Fx == 0x0d ) /* pattern break */ + { +/* printf ( "!! [%x] -> " , FxVal );*/ + c4 = FxVal%10; + c3 = FxVal/10; + FxVal = 16; + FxVal *= c3; + FxVal += c4; +/* printf ( "[%x]\n" , FxVal );*/ + } + + Pattern[j*4] = (Smp&0xf0); + Pattern[j*4] |= poss[Note][0]; + Pattern[j*4+1] = poss[Note][1]; + Pattern[j*4+2] = ((Smp<<4)&0xf0)|Fx; + Pattern[j*4+3] = FxVal; + } + fwrite ( Pattern , 1024 , 1 , out ); + Where += 768; + } + + + + /* sample data */ + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + + + Crap ( " UNIC Tracker " , BAD , BAD , out ); + /* + fseek ( out , 830 , SEEK_SET ); + fprintf ( out , " -[Converted with]- " ); + fseek ( out , 860 , SEEK_SET ); + fprintf ( out , " -[UNIC Tracker]- " ); + fseek ( out , 890 , SEEK_SET ); + fprintf ( out , " -[2 ProTracker]- " ); + fseek ( out , 920 , SEEK_SET ); + fprintf ( out , " -[by Asle /ReDoX]- " ); + */ + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} + diff --git a/prowizard/depack/unic2.c b/prowizard/depack/unic2.c new file mode 100755 index 00000000..cdf1a56f --- /dev/null +++ b/prowizard/depack/unic2.c @@ -0,0 +1,195 @@ +/* + * Unic_Tracker_2.c 1997 (c) Asle / ReDoX + * + * + * Unic tracked 2 MODs to Protracker + ******************************************************** + * 13 april 1999 : Update + * - no more open() of input file ... so no more fread() !. + * It speeds-up the process quite a bit :). + * 28 nov 1999 : + * - Overall Speed and Size optimizings. +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +/*#define ON 1 +#define OFF 2*/ + +void Depack_UNIC2 ( void ) +{ + Uchar poss[37][2]; + Uchar Smp,Note,Fx,FxVal; + Uchar *Whatever; +/* Uchar LOOP_START_STATUS=OFF;*/ /* standard /2 */ + long i=0,j=0,k=0,l=0; + long WholeSampleSize=0; + long Where=PW_Start_Address; /* main pointer to prevent fread() */ + FILE *out; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + if ( Save_Status == BAD ) + return; + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* title */ + Whatever = (Uchar *) malloc (1028); + BZERO ( Whatever , 1028 ); + fwrite ( Whatever , 20 , 1 , out ); + + for ( i=0 ; i<31 ; i++ ) + { + /* sample name */ + fwrite ( &in_data[Where] , 20 , 1 , out ); + fwrite ( &Whatever[32] , 2 , 1 , out ); + + /* fine on ? */ + j = (in_data[Where+20]*256)+in_data[Where+21]; + if ( j != 0 ) + { + if ( j < 256 ) + Whatever[48] = 0x10-in_data[Where+21]; + else + Whatever[48] = 0x100-in_data[Where+21]; + } + + /* smp size */ + fwrite ( &in_data[Where+22] , 2 , 1 , out ); + l = ((in_data[Where+22]*256)+in_data[Where+23])*2; + WholeSampleSize += l; + + /* fine */ + fwrite ( &Whatever[48] , 1 , 1 , out ); + + /* vol */ + fwrite ( &in_data[Where+25] , 1 , 1 , out ); + + /* loop start */ + Whatever[64] = in_data[Where+26]; + Whatever[65] = in_data[Where+27]; + + /* loop size */ + j=((Whatever[64]*256)+Whatever[65])*2; + k=((in_data[Where+28]*256)+in_data[Where+29])*2; + if ( (((j*2) + k) <= l) && (j!=0) ) + { +/* LOOP_START_STATUS = ON;*/ + Whatever[64] *= 2; + j = Whatever[65]*2; + if ( j>256 ) + Whatever[64] += 1; + Whatever[65] *= 2; + } + + fwrite ( &Whatever[64] , 2 , 1 , out ); + + fwrite ( &in_data[Where+28] , 2 , 1 , out ); + + Where += 30; + } + + + /*printf ( "whole sample size : %ld\n" , WholeSampleSize );*/ +/* + if ( LOOP_START_STATUS == ON ) + printf ( "!! Loop start value was /4 !\n" ); +*/ + /* number of pattern */ + fwrite ( &in_data[Where++] , 1 , 1 , out ); + + /* noisetracker byte */ + Whatever[32] = 0x7f; + fwrite ( &Whatever[32] , 1 , 1 , out ); + Where += 1; + + /* Pattern table */ + fwrite ( &in_data[Where] , 128 , 1 , out ); + Where += 128; + + /* get highest pattern number */ + for ( i=0 ; i<128 ; i++ ) + { + if ( in_data[PW_Start_Address+932+i] > Whatever[1026] ) + Whatever[1026] = in_data[PW_Start_Address+932+i]; + } + /*printf ( "Number of Pattern : %d\n" , Whatever[1026]+1 );*/ + + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + + /* pattern data */ + for ( i=0 ; i<=Whatever[1026] ; i++ ) + { + for ( j=0 ; j<256 ; j++ ) + { + Smp = ((in_data[Where+j*3]>>2) & 0x10) | ((in_data[Where+j*3+1]>>4)&0x0f); + Note = in_data[Where+j*3]&0x3f; + Fx = in_data[Where+j*3+1]&0x0f; + FxVal = in_data[Where+j*3+2]; + if ( Fx == 0x0d ) /* pattern break */ + { +/* printf ( "!! [%x] -> " , FxVal );*/ + Whatever[1024] = FxVal%10; + Whatever[1025] = FxVal/10; + FxVal = 16; + FxVal *= Whatever[1025]; + FxVal += Whatever[1024]; +/* printf ( "[%x]\n" , FxVal );*/ + } + + Whatever[j*4] = (Smp&0xf0); + Whatever[j*4] |= poss[Note][0]; + Whatever[j*4+1] = poss[Note][1]; + Whatever[j*4+2] = ((Smp<<4)&0xf0)|Fx; + Whatever[j*4+3] = FxVal; + } + fwrite ( Whatever , 1024 , 1 , out ); + Where += 768; + } + free ( Whatever ); + + + /* sample data */ + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + Crap ( " UNIC Tracker 2 " , BAD , BAD , out ); + /* + fseek ( out , 830 , SEEK_SET ); + fprintf ( out , " -[Converted with]- " ); + fseek ( out , 860 , SEEK_SET ); + fprintf ( out , " -[UNIC Tracker 2]- " ); + fseek ( out , 890 , SEEK_SET ); + fprintf ( out , " -[2 ProTracker]- " ); + fseek ( out , 920 , SEEK_SET ); + fprintf ( out , " -[by Asle /ReDoX]- " ); + */ + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} + diff --git a/prowizard/depack/wn.c b/prowizard/depack/wn.c new file mode 100755 index 00000000..52d7877f --- /dev/null +++ b/prowizard/depack/wn.c @@ -0,0 +1,123 @@ +/* + * Wanton_Packer.c 1997 (c) Asle / ReDoX + * + * Converts MODs converted with Wanton packer + ******************************************************** + * 13 april 1999 : Update + * - no more open() of input file ... so no more fread() !. + * It speeds-up the process quite a bit :). + * 28 nov 1999 : Update + * - small size optimizing. +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_WN ( void ) +{ + Uchar poss[37][2]; + Uchar *Whatever; + long WholeSampleSize=0; + long i=0,j=0; + long Where=PW_Start_Address; /* main pointer to prevent fread() */ + FILE *out; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + if ( Save_Status == BAD ) + return; + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* read header */ + fwrite ( &in_data[Where] , 950 , 1 , out ); + + /* get whole sample size */ + for ( i=0 ; i<31 ; i++ ) + WholeSampleSize += (((in_data[Where+42+i*30]*256)+in_data[Where+43+i*30])*2); +/* printf ( "Whole sample size : %ld\n" , WholeSampleSize );*/ + + /* read size of pattern list */ + Where += 950; + fwrite ( &in_data[Where] , 1 , 1 , out ); + Where += 1; + + i = Where; + fwrite ( &in_data[Where] , 129 , 1 , out ); + Where += 129; + + /* write ptk's ID */ + Whatever = (Uchar *) malloc (5); + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* get highest pattern number */ + Whatever[4] = 0x00; + for ( i=0 ; i<128 ; i++ ) + { + if ( in_data[PW_Start_Address + 952 + i] > Whatever[4] ) + Whatever[4] = in_data[PW_Start_Address + 952 + i]; + } +/* printf ( "Max : %d\n" , Whatever[4] );*/ + + /* pattern data */ + Where = PW_Start_Address + 1084; + for ( i=0 ; i<=Whatever[4] ; i++ ) + { + for ( j=0 ; j<256 ; j++ ) + { + Whatever[0] = in_data[Where+1] & 0xf0; + Whatever[0] |= poss[(in_data[Where]/2)][0]; + Whatever[1] = poss[(in_data[Where]/2)][1]; + Whatever[2] = (in_data[Where+1]<<4)&0xf0; + Whatever[2] |= in_data[Where+2]; + Whatever[3] = in_data[Where+3]; + + fwrite ( Whatever , 4 , 1 , out ); + Where += 4; + } +/* printf ( "+" );*/ + } +/* printf ( "\n" );*/ + free ( Whatever ); + + /* sample data */ + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + /* crap */ + Crap ( " Wanton Packer " , BAD , BAD , out ); + /* + fseek ( out , 830 , SEEK_SET ); + fprintf ( out , " -[Converted with]- " ); + fseek ( out , 860 , SEEK_SET ); + fprintf ( out , "-[Wanton Packer to]-" ); + fseek ( out , 890 , SEEK_SET ); + fprintf ( out , " -[ProTracker]- " ); + fseek ( out , 920 , SEEK_SET ); + fprintf ( out , " -[by Asle /ReDoX]- " ); + */ + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/depack/xann.c b/prowizard/depack/xann.c new file mode 100755 index 00000000..f50a3a2f --- /dev/null +++ b/prowizard/depack/xann.c @@ -0,0 +1,317 @@ +/* + * XANN_Packer.c 1997 (c) Asle / ReDoX + * + * XANN Packer to Protracker. + * + * + * 13 april 1999 : Update + * - no more open() of input file ... so no more fread() !. + * It speeds-up the process quite a bit :). + * 28 Nov 1999 : Update + * - Speed & Size optimizings + * Another Update : 26 nov 2003 + * - used htonl() so that use of addy is now portable on 68k archs +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +#define SMP_DESC_ADDRESS 0x206 +#define PAT_DATA_ADDRESS 0x43C + +void Depack_XANN ( void ) +{ + Uchar c1=0x00,c2=0x00; + Uchar poss[37][2]; + Uchar Max=0x00; + Uchar Note,Smp,Fx,FxVal; + Uchar *Whatever; + long i=0,j=0,l=0,z; + long WholeSampleSize=0; + long Where=PW_Start_Address; /* main pointer to prevent fread() */ + FILE *out; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + if ( Save_Status == BAD ) + return; + + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* title */ + Whatever = (Uchar *) malloc (1024); + BZERO ( Whatever , 1024 ); + fwrite ( Whatever , 20 , 1 , out ); + + /* 31 samples */ + Where = PW_Start_Address + SMP_DESC_ADDRESS; + for ( i=0 ; i<31 ; i++ ) + { + /* sample name */ + fwrite ( &Whatever[2] , 22 , 1 , out ); + + /* read loop start address */ + j=(in_data[Where+2]*256*256*256)+ + (in_data[Where+3]*256*256)+ + (in_data[Where+4]*256)+ + in_data[Where+5]; + + /* read sample address */ + l=(in_data[Where+8]*256*256*256)+ + (in_data[Where+9]*256*256)+ + (in_data[Where+10]*256)+ + in_data[Where+11]; + + /* read & write sample size */ + fwrite ( &in_data[Where+12] , 2 , 1 , out ); + WholeSampleSize += (((in_data[Where+12]*256)+in_data[Where+13])*2); + + /* calculate loop start value */ + j = j-l; + + /* write fine & vol */ + fwrite ( &in_data[Where] , 2 , 1 , out ); + + /* write loop start */ + /* use of htonl() suggested by Xigh !.*/ + j/=2; + z = htonl(j); + Whatever[0] = *((Uchar *)&z+2); + Whatever[1] = *((Uchar *)&z+3); + fwrite ( Whatever , 2 , 1 , out ); + + /* write loop size */ + fwrite ( &in_data[Where+6] , 2 , 1 , out ); + + Where += 16; + } + /*printf ( "Whole sample size : %ld\n" , WholeSampleSize );*/ + + /* pattern table */ + Max = 0x00; + Where = PW_Start_Address; + for ( c1=0 ; c1<128 ; c1++ ) + { + l=(in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3]; + Where += 4; + if ( l == 0 ) + break; + Whatever[c1] = ((l-0x3c)/1024)-1; + if ( Whatever[c1] > Max ) + Max = Whatever[c1]; + } + Max += 1; /* starts at $00 */ + /*printf ( "number of pattern : %d\n" , Max );*/ + + /* write number of pattern */ + fwrite ( &c1 , 1 , 1 , out ); + + /* write noisetracker byte */ + c1 = 0x7f; + fwrite ( &c1 , 1 , 1 , out ); + + /* write pattern list */ + fwrite ( Whatever , 128 , 1 , out ); + + /* write Protracker's ID */ + Whatever[0] = 'M'; + Whatever[1] = '.'; + Whatever[2] = 'K'; + Whatever[3] = '.'; + fwrite ( Whatever , 4 , 1 , out ); + + /* pattern data */ + Where = PW_Start_Address + PAT_DATA_ADDRESS; + for ( i=0 ; i>3)&0x1f; + Note = in_data[Where+j*4+1]; + Fx = in_data[Where+j*4+2]; + FxVal = in_data[Where+j*4+3]; + switch ( Fx ) + { + case 0x00: /* no Fx */ + Fx = 0x00; + break; + + case 0x04: /* arpeggio */ + Fx = 0x00; + break; + + case 0x08: /* portamento up */ + Fx = 0x01; + break; + + case 0x0C: /* portamento down */ + Fx = 0x02; + break; + + case 0x10: /* tone portamento with no FxVal */ + Fx = 0x03; + break; + + case 0x14: /* tone portamento */ + Fx = 0x03; + break; + + case 0x18: /* vibrato with no FxVal */ + Fx = 0x04; + break; + + case 0x1C: /* vibrato */ + Fx = 0x04; + break; + + case 0x24: /* tone portamento + vol slide DOWN */ + Fx = 0x05; + break; + + case 0x28: /* vibrato + volume slide UP */ + Fx = 0x06; + c1 = (FxVal << 4)&0xf0; + c2 = (FxVal >> 4)&0x0f; + FxVal = c1|c2; + break; + + case 0x2C: /* vibrato + volume slide DOWN */ + Fx = 0x06; + break; + + case 0x38: /* sample offset */ + Fx = 0x09; + break; + + case 0x3C: /* volume slide up */ + Fx = 0x0A; + c1 = (FxVal << 4)&0xf0; + c2 = (FxVal >> 4)&0x0f; + FxVal = c1|c2; + break; + + case 0x40: /* volume slide down */ + Fx = 0x0A; + break; + + case 0x44: /* position jump */ + Fx = 0x0B; + break; + + case 0x48: /* set volume */ + Fx = 0x0C; + break; + + case 0x4C: /* pattern break */ + Fx = 0x0D; + break; + + case 0x50: /* set speed */ + Fx = 0x0F; + break; + + case 0x58: /* set filter */ + Fx = 0x0E; + FxVal = 0x01; + break; + + case 0x5C: /* fine slide up */ + Fx = 0x0E; + FxVal |= 0x10; + break; + + case 0x60: /* fine slide down */ + Fx = 0x0E; + FxVal |= 0x20; + break; + + case 0x74: /* set loop start */ + case 0x78: /* set loop value */ + Fx = 0x0E; + FxVal |= 0x60; + break; + + case 0x84: /* retriger */ + Fx = 0x0E; + FxVal |= 0x90; + break; + + case 0x88: /* fine volume slide up */ + Fx = 0x0E; + FxVal |= 0xa0; + break; + + case 0x8C: /* fine volume slide down */ + Fx = 0x0E; + FxVal |= 0xb0; + break; + + case 0x94: /* note delay */ + Fx = 0x0E; + FxVal |= 0xd0; + break; + + case 0x98: /* pattern delay */ + Fx = 0x0E; + FxVal |= 0xe0; + break; + + default: + printf ( "%x : at %ld (out:%ld)\n" , Fx , Where+(j*4),ftell(out) ); + Fx = 0x00; + break; + } + Whatever[j*4] = (Smp & 0xf0); + Whatever[j*4] |= poss[(Note/2)][0]; + Whatever[j*4+1] = poss[(Note/2)][1]; + Whatever[j*4+2] = ((Smp<<4)&0xf0); + Whatever[j*4+2] |= Fx; + Whatever[j*4+3] = FxVal; + } + Where += 1024; + fwrite ( Whatever , 1024 , 1 , out ); +/* printf ( "pattern %ld written\n" , i );*/ + } + free ( Whatever ); + + /* sample data */ + fwrite ( &in_data[Where] , WholeSampleSize , 1 , out ); + + Crap ( " XANN Packer " , BAD , BAD , out ); + /* + fseek ( out , 830 , SEEK_SET ); + fprintf ( out , " -[Converted with]- " ); + fseek ( out , 860 , SEEK_SET ); + fprintf ( out , " -[XANN packer to]- " ); + fseek ( out , 890 , SEEK_SET ); + fprintf ( out , " -[ProTracker]- " ); + fseek ( out , 920 , SEEK_SET ); + fprintf ( out , " -[by Asle /ReDoX]- " ); + */ + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} + diff --git a/prowizard/depack/zen.c b/prowizard/depack/zen.c new file mode 100755 index 00000000..5f713758 --- /dev/null +++ b/prowizard/depack/zen.c @@ -0,0 +1,237 @@ +/* + * Zen_Packer.c 1998 (c) Asle / ReDoX + * + * Converts ZEN packed MODs back to PTK MODs + ******************************************************** + * 13 april 1999 : Update + * - no more open() of input file ... so no more fread() !. + * It speeds-up the process quite a bit :). + * 28 Nov 1999 : Update + * - Speed an size optimizings. + * 03 april 2000 : Update + * - small bug correction (harmless) + * again pointed out by Thomas Neumann + * Another Update : 26 nov 2003 + * - used htonl() so that use of addy is now portable on 68k archs +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Depack_ZEN ( void ) +{ + Uchar PatPos; + Uchar *Whatever; + Uchar PatMax; + Uchar poss[37][2]; + Uchar Note,Smp,Fx,FxVal; + long WholeSampleSize=0; + long Pattern_Address[128]; + long Pattern_Address_Real[128]; + long Pattern_Table_Address; + long Sample_Data_Address=999999l; + long i,j,k,z; + long Where=PW_Start_Address; /* main pointer to prevent fread() */ + FILE *out; + +#ifdef DOS + #include "..\include\ptktable.h" +#endif + +#ifdef UNIX + #include "../include/ptktable.h" +#endif + + if ( Save_Status == BAD ) + return; + + BZERO ( Pattern_Address , 128*4); + BZERO ( Pattern_Address_Real , 128*4); + sprintf ( Depacked_OutName , "%ld.mod" , Cpt_Filename-1 ); + out = mr_fopen ( Depacked_OutName , "w+b" ); + if (!out) + return; + + /* read pattern table address */ + Pattern_Table_Address = (in_data[Where]*256*256*256)+ + (in_data[Where+1]*256*256)+ + (in_data[Where+2]*256)+ + in_data[Where+3]; + Where += 4; + + /* read patmax */ + PatMax = in_data[Where++]; + + /* read size of pattern table */ + PatPos = in_data[Where++]; + /*printf ( "Size of pattern list : %d\n" , PatPos );*/ + + /* write title */ + Whatever = (Uchar *) malloc (1024); + BZERO ( Whatever , 1024 ); + fwrite ( Whatever , 20 , 1 , out ); + + for ( i=0 ; i<31 ; i++ ) + { + fwrite ( Whatever , 22 , 1 , out ); + + /* read sample size */ + WholeSampleSize += (((in_data[Where+4]*256)+in_data[Where+5])*2); + fwrite ( &in_data[Where+4] , 2 , 1 , out ); + + /* write fine */ + Whatever[32] = ((in_data[Where]*256)+in_data[Where+1])/0x48; + fwrite ( &Whatever[32] , 1 , 1 , out ); + + /* write volume */ + fwrite ( &in_data[Where+3] , 1 , 1 , out ); + + /* read sample start address */ + k = (in_data[Where+8]*256*256*256)+ + (in_data[Where+9]*256*256)+ + (in_data[Where+10]*256)+ + in_data[Where+11]; + + if ( k>4)&0x0f); + Fx = in_data[Where+2]&0x0f; + +/*fprintf ( info , "<-- note:%-2x smp:%-2x fx:%-2x fxval:%-2x\n" + , Note,Smp,Fx,FxVal );*/ + + k=in_data[Where]; + Whatever[k*4] = Smp&0xf0; + Whatever[k*4] |= poss[Note][0]; + Whatever[k*4+1] = poss[Note][1]; + Whatever[k*4+2] = Fx | ((Smp<<4)&0xf0); + Whatever[k*4+3] = FxVal; + j = in_data[Where]; + Where += 4; + } + fwrite ( Whatever , 1024 , 1 , out ); + /*printf ( "." );*/ + } + free ( Whatever ); + /*printf ( " ok\n" );*/ + + + /* sample data */ + fwrite ( &in_data[PW_Start_Address+Sample_Data_Address] , WholeSampleSize , 1 , out ); + + /* crap ... */ + Crap ( " ZEN Packer " , BAD , BAD , out ); + /* + fseek ( out , 830 , SEEK_SET ); + fprintf ( out , "[ Converted with ]" ); + fseek ( out , 860 , SEEK_SET ); + fprintf ( out , "[ Zen Packer ]" ); + fseek ( out , 890 , SEEK_SET ); + fprintf ( out , "[ to Protraker ]" ); + fseek ( out , 920 , SEEK_SET ); + fprintf ( out , "[ by Asle /ReDoX ]" ); + */ + fflush ( out ); + fclose ( out ); + + printf ( "done\n" ); + return; /* useless ... but */ +} diff --git a/prowizard/docs/COPYING b/prowizard/docs/COPYING new file mode 100755 index 00000000..60549be5 --- /dev/null +++ b/prowizard/docs/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + 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 + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/prowizard/docs/CREDITS b/prowizard/docs/CREDITS new file mode 100755 index 00000000..e5b5b786 --- /dev/null +++ b/prowizard/docs/CREDITS @@ -0,0 +1,19 @@ +Thanks to: + Nicolas Franck (Gryzor) for his marvellous Pro-Wizard 2 + and numerous packed files !. + + Mickael Doering for the *nix port and the constructives comments !. + + Thomas Neumann for pointing out a lot of bugs !. + your help was valuable !. + + Markus Jaegermeister for pointing out bugs too, and for providing + invaluable information regarding "exotic formats" !. + + Laurent Clévy for numerous synth descriptions !. + + Xigh for the Mingwin32 port/compiling, and for a couple of tips + with the source code. + + all the people who pointed out bugs (recontact me for I've lost + your names with the uncountable crash I've had lately..) diff --git a/prowizard/docs/KNOWN_FORMATS b/prowizard/docs/KNOWN_FORMATS new file mode 100755 index 00000000..5d308ee2 --- /dev/null +++ b/prowizard/docs/KNOWN_FORMATS @@ -0,0 +1,238 @@ +Known formats +------------- + + Note: The order is alphabetically arranged with the extensions. + + Note: the string between "()" is the default extension used by + Pro-Wizard (for PeeCee) when a music is ripped. + + Note: "CPU" is the computer on which the format can be found + + Note: "DETECTION" and "SIZE CALC" describe how easy it is to detect the + format and to calcutate its size. From the easiest to the hardest : + "child's play","easy","some job","good job","hard job". + Heh, that's MY point of view ... others might say otherwise for + some formats ... . + +| EXT | NAME OF THE FORMAT | CPU | DETECTION | SIZE CALC | +|=======|====================================|=====|===========|============| +| (40A) |The Player 4.0A |Amiga| easy | some job | +|-------|------------------------------------|-----|-----------|------------| +| (40B) |The Player 4.0B |Amiga| easy | some job | +|-------|------------------------------------|-----|-----------|------------| +| (41A) |The Player 4.1A |Amiga| easy | some job | +|-------|------------------------------------|-----|-----------|------------| +| (50A) |The Player 5.0A |Amiga| good job! | easy | +|-------|------------------------------------|-----|-----------|------------| +| (60A) |The Player 6.0A (no sample pack) |Amiga| good job! | easy | +|-------|------------------------------------|-----|-----------|------------| +| (61A) |The Player 6.1A (no sample pack) |Amiga| good job! | easy | +|-------|------------------------------------|-----|-----------|------------| +| (AC1) |AC1D packer |Amiga| easy |child's play| +|-------|------------------------------------|-----|-----------|------------| +| (CRB) |Heatseeker mc1.0 |Amiga| some job | hard job ! | +|-------|------------------------------------|-----|-----------|------------| +| (DI) |Digital Illusion |Amiga| good job! |child's play| +|-------|------------------------------------|-----|-----------|------------| +| (EU) |Eureka packer |Amiga| good job! |child's play| +|-------|------------------------------------|-----|-----------|------------| +| (FCM) |FC-M packer |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (FT ) |Fuchs Tracker |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (FUZ) |Fuzzac packer |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (GMC) |Game Music Creator |Amiga| some job | easy | +|-------|------------------------------------|-----|-----------|------------| +| (GNU) |GnuPlayer |Amiga| easy | some job | +|-------|------------------------------------|-----|-----------|------------| +| (GPM) |GPMO (Crunch Player) |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (HRT) |Hornet packer |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (KRS) |Kris Tracker (Chip Tracker) |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (KSM) |Kefrens Sound Machine |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (MED) |MED - MMD0/MMD1 |Amiga| easy |child's play| +|-------|------------------------------------|-----|-----------|------------| +| (MOD) |Protracker |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (MOD) |SoundTracker |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (MOD) |StarTrekker |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (MP ) |Module protector |Amiga| good job! | easy | +|-------|------------------------------------|-----|-----------|------------| +| (NEW) |Newtron packer |Amiga| easy |child's play| +|-------|------------------------------------|-----|-----------|------------| +| (NRU) |Noiserunner |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (NP1) |NoisePacker v1 |Amiga| some job | easy | +|-------|------------------------------------|-----|-----------|------------| +| (NP2) |NoisePacker v2 |Amiga| some job | easy | +|-------|------------------------------------|-----|-----------|------------| +| (NP3) |NoisePacker v3 |Amiga| some job | easy | +|-------|------------------------------------|-----|-----------|------------| +| (P10) |ProPacker v1.0 |Amiga| some job | easy | +|-------|------------------------------------|-----|-----------|------------| +| (P21) |ProPacker v2.1 |Amiga| good job! | some job | +|-------|------------------------------------|-----|-----------|------------| +| (P30) |ProPacker v3.0 |Amiga| good job! | some job | +|-------|------------------------------------|-----|-----------|------------| +| (PHA) |PHA Packer |Amiga| some job | hard job ! | +|-------|------------------------------------|-----|-----------|------------| +| (PM) |Optimod's Power Music |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (PM0) |Promizer 0.1 |Amiga| good job! |child's play| +|-------|------------------------------------|-----|-----------|------------| +| (PM1) |Promizer 1.0c |Amiga| easy |child's play| +|-------|------------------------------------|-----|-----------|------------| +| (PMZ) |Promizer 1.8a |Amiga| easy |child's play| +|-------|------------------------------------|-----|-----------|------------| +| (PM2) |Promizer 2.0 |Amiga| easy |child's play| +|-------|------------------------------------|-----|-----------|------------| +| (PM4) |Promizer 4.0 |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (POL) |Polka packer |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (PR1) |ProRunner v1 |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (PR2) |ProRunner v2 |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (QC ) |Quadra Composer |Amiga| easy |Child's play| +|-------|------------------------------------|-----|-----------|------------| +| (SFX) |Sound FX 1.3 |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (SKT) |SKYT packer |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (STI) |STIM (Slamtilt) |Amiga| easy | some job | +|-------|------------------------------------|-----|-----------|------------| +| (STP) |StarTrekker pack |Amiga| good job! |child's play| +|-------|------------------------------------|-----|-----------|------------| +| (TDD) |The Dark Demon |Amiga| some job | easy | +|-------|------------------------------------|-----|-----------|------------| +| (TP1) |Tracker Packer v1 |Amiga| easy |child's play| +|-------|------------------------------------|-----|-----------|------------| +| (TP2) |Tracker Packer v2 |Amiga| easy | hard job ! | +|-------|------------------------------------|-----|-----------|------------| +| (TP3) |Tracker Packer v3 |Amiga| easy | hard job ! | +|-------|------------------------------------|-----|-----------|------------| +| (UN1) |UNIC Tracker v1 |Amiga| hard job! | easy | +|-------|------------------------------------|-----|-----------|------------| +| (UN2) |UNIC Tracker v2 |Amiga| hard job! | easy | +|-------|------------------------------------|-----|-----------|------------| +| (WN) |Wanton Packer |Amiga| easy |child's play| +|-------|------------------------------------|-----|-----------|------------| +| (XAN) |Xann Packer |Amiga| some job | some job | +|-------|------------------------------------|-----|-----------|------------| +| (ZEN) |Zen Packer |Amiga| some job |child's play| +|-------|------------------------------------|-----|-----------|------------| + + * that's 58 formats now :) + + + there, now some Synthetic ... + +| EXT | NAME OF THE FORMAT | CPU | DETECTION | SIZE CALC | +|=======|====================================|=====|===========|============| +| (BP*) |Sound Monitor v2/v3 |Amiga| easy | some job | +|-------|------------------------------------|-----|-----------|------------| +| (BFC) |BSI Future Composer |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (FC3) |Future Composer 1.3 |Amiga| easy | easy | +|-------|------------------------------------|-----|-----------|------------| +| (FC4) |Future Composer 1.4 |Amiga| easy | some job | +|-------|------------------------------------|-----|-----------|------------| +| (JAM) |JamCracker / Pro |Amiga| easy | some job | +|-------|------------------------------------|-----|-----------|------------| +| (SFX) |Sound FX 1.3/1.8 |Amiga| easy | some job | +|-------|------------------------------------|-----|-----------|------------| + + * only 7 ... I'm working on that. + + + Also, the data/exe files : + +| EXT | NAME OF THE FORMAT | CPU | DETECTION | SIZE CALC | +|=======|=======================================|=====|===========|============| +| (1AM) |Amnesty Design Data Packer (data) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (2AM) |Amnesty Design Data Packer (data) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (89A) |$08090A08 Data Cruncher (data) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (ARC) |arcD Data Cruncher (data) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (BK ) |ByteKiller 1.3/2.0/3.0/Pro 1.0 (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (CRM) |Crunchmania / Normal (data) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (CRM) |Crunchmania Adress (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (CRN) |CRND Data Cruncher (data) |Amiga| easy | easy | +|-------|---------------------------------------|-----|-----------|------------| +| (DBL) |Double Action 1.0 (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (DJM) |Defjam Cruncher 3.2 / 3.2 pro (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (FIR) |FIRE (RNC clone) Cruncher (data) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (HQC) |HQC Cruncher 2.0 (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (ICE) |Ice! Cruncher (data) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (IMP) |Imploder (data) (ATN!-IMP!-CHFI) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (MAX) |Max Packer 1.2 (exe) |Amiga| easy | some job | +|-------|---------------------------------------|-----|-----------|------------| +| (MC ) |Master Cruncher 3.0 address (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (MC ) |Mega Cruncher 1.0/1.2/Obj (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (PAR )|PARA Data Cruncher (data) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (PP*) |Powerpacker 2.3/3.0/4.0/4.0 lib (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (PP ) |AMOS Powerpacker Bank "PPbk" (data) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (RNC) |Propack (Rob Northern Cruncher) (data) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (RI ) |RelokIt 1.0 (exe) |Amiga| easy | some job | +|-------|---------------------------------------|-----|-----------|------------| +| (SB ) |=SB= Data Cruncher (data) |Amiga| easy |child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (SF ) |SF Data Cruncher (data) |Amiga| easy |child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (SPK) |Spike Cruncher (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (STC) |StoneCracker 2.70 (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (STC) |StoneCracker 4.04/4.01/4.03/3.10 (data)|Amiga| easy |Child's play| +| |StoneCracker 3.00 (data) | | | | +|-------|---------------------------------------|-----|-----------|------------| +| (STC) |StoneCracker 2.99d/2.99b/3.10 (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (SP ) |Syncro Packer 4.6 (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (SC ) |Super Cruncher 2.7 (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (T**) |Tetrapack 1.02/2.2/2.1 (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (TIC) |Try-It Cruncher 1.01 (exe) |Amiga| easy | easy | +|-------|---------------------------------------|-----|-----------|------------| +| (TC ) |Time Cruncher 1.7 (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (TNM) |TNM Cruncher 1.1 (exe) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (TIC) |TurboCruncher 6.1 (exe) |Amiga| easy | easy | +|-------|---------------------------------------|-----|-----------|------------| +| (VDC) |Virtual Dreams (VDCO) data cruncher |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| +| (XPK) |XPK-ed (data) |Amiga| easy |Child's play| +|-------|---------------------------------------|-----|-----------|------------| + + * didn't want to do that in the first place ... but there it is and that's + about 57 formats recognized now !. + + diff --git a/prowizard/docs/MISC b/prowizard/docs/MISC new file mode 100755 index 00000000..15e5e5e3 --- /dev/null +++ b/prowizard/docs/MISC @@ -0,0 +1,126 @@ +Hot thanks +---------- + - Nicolas Franck (Gryzor) for his marvellous (c) Pro-Wizard-2 :). + + - Mickael Doering for the *nix port and the constructives comments !. + + - Philippe Anel (Xigh) for compiling the WIN32 version + + - Slight for believeing in this wild project !. Wassup bro ?. + + - Thomas Neumann for pointing out a lot of bugs !. + + - Michael Trier, XtC and many others who sent me stuff to work with :). + + - Laurent Clevy for the numerous Synth Formats descriptions !. + + - Everyone who'll write to me about this program :). + + + +Some words +---------- + So, yet here is another version with still some debugging done !. Seems I'll +never see the end of it :). Anyway, Since I've some spare time these days, +I come back on this prog. Though, I put my efforts onto the 'synth' part. +Also, I'm a-working on some rather old/never used EXE packers. + + here are some things one ought to know about possible 'failure' of +Pro-Wizard-1 (for PeeCee) ... meaning this prog might overlook or mistake +some formats. The "sensibles" formats are : + - Noisepacker v1 and v2 + (these two formats are VERY similars ... a NP1 can be recognised as a NP2. + Rather harmless I should says, but ..) + - Unic tracker v1 and v2 + (These two formats can be recognised as the other ... or even as a ptk but + this very case has 0.01% chance to happen :). The first case, however, is + most probable ... . The difference isn't that important, mind .. a title !) + - The Player 6.0A and 6.1A with packed samples are on hold. Jarno *did* + answer my old email (thx man !) and sent me a torough description on + how to depack samples. Sadly, I've no time at all to do that these days. + + Most of the depackers included are still real gibberish code. I've rewritten +quite a few yet, but I've found it's very expensive in time to rewritte +lame old code :(. Not sure I'll finnish this ... . + + I've depacked NoiseTracker pack a long time ago ... but I wont include this +format in ProWiz bcoz my depacker isn't 100% reliable :(. The fact is that +if there are Arpeggii in the music, I cant find any single way to detect it. +contact me for more infos :), I'll send you the description I've made .. +reliable this one !. + + One word about StoneCracker v4.04 data files ... . I've included this format +and several others because I'm fed-up doing it handly with Hex-ed !. +The ripped files are STILL packed !, and you'll need to depack them with tools +like XfdDecrunch. If you know how to depack these, you're welcome to send +me some source code (68k or not). + Also, I've expanded this to other fairly well used packers. Yet, I still +dont know how to depack this by myself. Extracting that way saves hours of +Hex-work .. at least for me :). + + One word about JamCracker. Xag version (JamCracker Pro 1.0A) saves a 19 bytes +title at the end of the module. Prowiz for PC doesn't rip it since it's NOT +in the original format. That's the only difference in the two versions (even +if Xag's doc says there's no diff ...). So, if you want the title, just check +the 19 bytes after the module. + + About Sound FX format, v1.3 and v1.8 are the same. Note that I attempted a +conversion to ptk ... but most of the effects are not supported ... simply +because I dont know what they do .. (doc please !). So, the conversion is +only at a beta stage ... the rip is ok though :). + + + + +Hellos and Messages +------------------- + Slight : Les nouvelles se font (toujours) rares :(. + + Gryzor : hum ... ca fait une paye !. + + Xann : Contacte moi SVP !!!!!. J'ai, encore une fois, perdu ton addresse !. + J'ai retrouve une intro de Silents codee par toi (91 ou 92 je crois) + mais le format de la zik est zarb ... ca ressemble a ton "celebre" + XANN player, mais ca colle pas vraiment. Tu as fais plusieurs + version ? ou est-ce ce "fameux" Xann packer (le vrai) ???. + + Buzz : Keep up the GOOOD work on Exotica. + + Xigh : et ce tracker, bordel !?!?!?. + + + +Contact the author +------------------ + Several ways to contact me .. + + - Snail mail (new !!) + Chipaux "asle" Sylvain + 55 rue des grands champs + 75020 Paris + France + + - E-Mail + asle@free.fr + (can get attached binary files). + or catch me on Exotica Forum !. + + + - WWW + http://asle.free.fr/prowiz/ + there's always the latest src version on there + + + - Tel + none at now + + + +Last word +--------- + I'll welcome ANY comment that might arise from this program. Also, new +formats or bug reports (with Pro-Wizard (for PeeCee) version number !). + + + + Sylvain "asle" Chipaux. diff --git a/prowizard/docs/TODO b/prowizard/docs/TODO new file mode 100755 index 00000000..79ae458e --- /dev/null +++ b/prowizard/docs/TODO @@ -0,0 +1,17 @@ +Things to do +------------ + - Adding the other formats I've depacked so far :). + -> Channel Player 1,2,3 (wont be easy ..) + + - Adding the whole lot of other ptk-compatible formats I still dont have + decrunched yet :(. + -> Pygmy packer + -> AMOS music bank (what a mess !) + -> an alien XANN packer ? (found in an old Silents intro :) + + - Adding some PC music format (S3M ...) + + - adding various synth formats since I got loads of tracker ! :). + + + diff --git a/prowizard/docs/changelog b/prowizard/docs/changelog new file mode 100755 index 00000000..d6357b6a --- /dev/null +++ b/prowizard/docs/changelog @@ -0,0 +1,339 @@ +CHANGE LOG +---------- + +Date format is DDMMYYYY. (from lattest to first) + + +24112003 Version 1.50.b3 + + More Double Action v1.0 to be found + _types_ files complete now + SKYT debugged (forgot to remove some code) + +23112003 Version 1.50.b2 + + Fixed TP1 patternlist handling. Should work with any TP1 now. + New supported (PTK clones) format : + - Noise From Heaven #2 musicdisk (Iris'2001) + - The Player 2.2a (thx to Exotica forum teams) + - The Player 3.0a (not really working in fact) + New supported (exe/data)format : + - StoneCracker 2.99/3.00 - with rebuilding + +23042003 Version 1.50.b1 + + Some bugs correction of previous release :( + A lot less fake Module Protector/P50a/PP10 should be found + Overall PhaPacker (Propacker 1.0) debugging. Should be ok now. + FC13/FC14 false test fixed .. all examples should be detected ok now. + Various optimizings + All RelokIt 1.0 will be ripped. + Found a solution for those 00h. Takes nearly no time now :) + New supported (PTK clones) formats : + - Newtron + - GPMO + - Polka Packer (Thx Michael Trier for the example !) + - GnuPlayer (Thx Kyz for the great description !) + - AmBk - Amos Bank (no converting back to Ptk yet) + New supported format : + - XM + New supported (exe/data)formats : + - Mega Cruncher Obj EXE packer (old old old :) - with rebuilding + - TurboSqueezer 6.1 (1989 !) - no rebuilding !. + - StoneCracker 2.99d/2.99b/3.10 - with rebuilding + +09062002 Version 1.49.4 (released on the 7th, mar 2003) + + Some other issues corrected (mem violations ...) + Removed the remaining bzero() ... forgot them :(. + Amiga port (Crown/Crb's request). + New supported (exe/data)formats : + - (Ace?) DataCruncher + +04052002 Version 1.49.3 + + Removed all printf() from rip/*.c to group that in misc/misc.c. + Broke the 3 chars limit for extensions of saved files. (thx xigh !) + +28122001 Version 1.49.2 (not released) + + Compiling on FreeBSD now, meaning all "hasardous" file reading + crashed the prog !. A lot have been corrected (all ?). + Removed the counter during search. Couldn't find an "easy" + solution :(. + +05052001 Version 1.49.1 + + More or less standard look-alike doc + Replaced bzero() with memset() + The Player 4.1a corrected (A cmd signed -> unsigned conversion) + Numerous bugfix (mostly to prevent readings outside of file) + in ProPacker 2.1, Noisepacker 3, Promizer 0.1. + added transco table for sample names in Kefrens Sound Machine modules. + New supported (exe/data)formats : + - Powerpacker 4.0 Library EXE packer (rare) + +20122000 Version 1.49.0 + + KRIS depacker/ripper debugged + Some useless code removed + New supported (synth) formats : + - MED (MMD0/MMD1) by Teijo Kinnunen (19??) + New supported (exe/data)formats : + - Crunchmania Address EXE packer (rather frequent) + +01072000 Version 1.48 + + New supported (exe/data)formats : + - Amnesty Design (1AM) data packer (very rare) + - Amnesty Design (2AM) data packer (very rare) + +23062000 Version 1.47 + + Two new effects added in XANN Packer format. + Added another UNIC tracker case ("UNIC" string ..) + New supported (exe/data)formats : + - BytekillerPro 1.0 - and rebuilding of header (very rare) + - HQC Cruncher 2.0 - no rebuild yet (very rare) + - Try-It Cruncher 1.01 - with rebuild (very rare) + (too few exemple to stick on this ripper ...) + New supported (synth) formats : + - Future Composer 1.3 (by Supersero / The Superions - 1990 ?) + - Future Composer 1.4 (by Supersero / The Superions - 1990) + +03042000 Version 1.46 + + mainly some small debugging in various tests. + all those corrected bugs where pointed out by Thomas Neumann + some other are not yet corrected though. I made all the quickies + before that hard stuff :). + +30111999 Version 1.45.c3 + + Finally editable extension are working ... even the last one. I'm + working on long extensions now, not only 3 chars. + New supported (exe/data)formats : + - CRND Data Cruncher (very rare) + - =SB= Data Cruncher (very rare) + - SF Data Cruncher (rare) + - Virtual Dreams (VDCO) Data Cruncher (very rare) + - SQ/SP Data Cruncher (missing SA/SC ..) + New supported (PTK Clone) formats : + - IceTracker 1.0 (IcePic) + - Soundtracker 2.6 (Mnemotron / Spreadpoint) + More optimizings by removing fopen() funcs. There's but a few + formats left to do. + Enhanced rebuilding of Time Crunched Binaries (24 last bytes) + Debugged Module Protector depacker + some internal rewritting ... mostly to speed-up and to + shorten more than quite a bit binaries. + +06061999 Version 1.44.005 + + Major rewritting ... a dozen or so files removed !. + Overall bugs corrections (mainly around sizes calculations) + A bug in UNIC2 ripper ... some unallocated value :(. + Aome debugging in Pha-ripper (still some job) + Aome bugs in UNIC1 tester ... stupid bugs, as usual :(. + Rrewrote some parts (restructured source code ... less lines) + Added another IAM packer (data) case ("ATM5") + Added some code to rewrite the header of EXE files with empty and/ + or no header. Usefull with oldish megademos :). That goes for + every supported EXE format. Get the list below. + Optimized PTK-depackers by removing the open() and read() + functions ... very high speed while depacking now :). done for + the following formats (Heh it takes time !!) : + - ProRunner v2.0 - SKYT packer - STIM (Slamtilt) packer + - Zen packer - Xann packer - Wanton packer + - Unic tracker v1/v2 - Tracker packer v3/v2 + Enhanced detection for the following formats : + - Digital Illusion detection (fake DI found) + - Startrekker pack (bugged) + - Zen packer (crashed the prog sometime) + - KRIS tracker (fake KRIS found) + - Pha Packer (bugged) + - SoundTracker (bugged) + - Tracker Packer 3 (bugged) + New supported (PTK Clone) formats : + - Quadra Composer + - The Dark Demon (group name) + - Fuchs Tracker (Andreas Fuchs - 1990) + New supported (synth) formats : + - SoundMonitor v3 (Brian Postma - 1993) + - JamCracker / Pro (M. Gemmel - 1989 / Xag of Betrayal - 1990) + - BSI Future Composer (Tony Bybell aka Slates of BSI - 1990-1996) + - Sound FX 1.3 (Battle Isle) by Christian Haller & Christian A. Weber + in 1988. V1.8 is samely copyrighted in 1989. + New supported (exe/data)formats : + - FIRE (RNC clone) Cruncher (rare) + - Max Packer 1.2 (exe rare) + - Ice! Cruncher (data ... rare) + - arcD Data Cruncher (very rare) + - PARA Data Cruncher (very rare) + - Propack (RNC) data (Rob Northern Cruncher ... Antic cruncher :) + found in a LOT of 88-93 games !. + - Double Action 1.0 (exe files) (in some rather old demos !) + - Powerpacker 2.3 / 3.0 / 4.0 (exe files) + - ByteKiller 2.0 / 3.0 (exe files) + - Tetrapack 1.02 (exe files) + - Master Cruncher 3.0 addr (exe files) + - Mega Cruncher 1.0/1.2 (exe files ... extremly old :) + - Spike Cruncher (exe files ... rare) + - StoneCracker 2.70 (exe files ... rare) + - StoneCracker 3.00 (data) + - Syncro Packer 4.6 (exe files ... rare) + - TNM Cruncher 1.1 (exe files ... rare) + - Super Cruncher 2.7 (exe files ... extremly rare) + - AMOS PowerPacker Bank "PPbk" (data) + - RelokIt 1.0 (exe files ... rare) + Following formats wont be supported : + - TPWM Cruncher (Battle Isle - Blue Byte) - Unrippable + - Powerpacker 2.0 (PP20) data - Unrippable + - StoneCracker 4.04/3.10 (exe file) bcoz it contains a S404 data + - Propack RNC (exe files) (RNC data inside) + - IAM packer 1.0 too (exe files) (ICE! or ATM5 data inside) + +26021999 Version 1.43 (not released) + + Module Protector and Heatseeker detections enhanced + (very look alike formats ..) + Fake ProPacker 3.0 were found ... corrected. + Fake UNIC tracker were found ... corrected. + Bad PP20 localisation corrected + Removed "converting to ptk" msg when ripping S404 files :) + Bug in Phapacker depacker corrected (still some job in there !) + Rewrote 20% of Promizer 1.8a depacker ... some problems with + the pattern list. + Many fake soundtracker were found ... removed a lot !. + Fake "damaged _TYPES_ file" error message corrected. + New filename when saving. alphabetical letters proved to be not + enough for some productions ... so, now, it's numbers !. (max:99999999) + good job to code that coz my sources were a bit shitty :) + New supported (EXE) format : + - Tetrapack 2.2/2.1 (Exe-files, not music file) + - Crunchmania / Crunchmania Normal (packed data files) + - Defjam Cruncher 3.2 / 3.2 pro (Exe-files) + - Stonecracker 4.01 / 4.03 / 3.10 (data) + - Byte Killer 1.3 (Exe-files) + - XPK-ed files (any format since it's all the same to get the size :) + - Imploder (data) + +13061998 Version 1.42 (not released) + + Protracker detection bug corrected + New supported format : + - SoundTracker (15 samples) + +20051998 Version 1.41 (20/05/98) + Save names not incrementing first letter when + ripping "not to be converted files" bug corrected + (e.g. PTK,BP,STC,StarTK) + New supported format : + - STIM (Slamtilt) + +22021998 Version 1.40 + + SIGSEGV error corrected (bad compiler option). + Digital Illusion detection bug corrected. + Game Music Creator detection bug corrected. + NoisePacker v1 detection bug corrected. + ProPacker v1 detection bug corrected. + UNIC tracker 2 detection bug corrected. + XANN packer detection bug corrected (Grrrr). + New depackers added (all in fact :) : + - AC1D packer + - Digital Illusion + - Eureka packer + - FC-M packer + - Fuzzac packer + - Game Music Creator + - Heatseeker mc1.0 + - Hornet packer + - Kris tracker (chip tracker) + - Kefrens Sound Machine + - Module Protector + - Noiserunner + - NoisePacker v1,v2 & v3 + - The Player 4.0A,4.0B,4.1A,5.0A,6.0A & 6.1A + - PhaPacker + - Promizer 0.1,1.0c,1.8a,2.0,4.0 + - Power Music + - ProPacker 1.0,2.1,3.0 + - ProRunner v1,v2 + - SKYT packer + - StarTrekker pack + - Tracker packer v1,v2,v3 + - UNIC tracker v1,v2 + - Wanton packer + - XANN packer + - ZEN packer + +15021998 Version 1.31 (not released) + + Enhanced tests for GMC modules. + Enhanced tests for Digital Illusion modules. + Enhanced tests for Eureka Packer modules. + Enhanced tests for UNIC 1/2 tracker modules. + P50A samples can be delta !!!. Argh (corrected). + P60A with packed samples cant be ripped for I dont know + how to calculate the packed sample sizes. + some P50A and P60A where not found bcoz of a lame test. + New supported formats : + - StarTrekker + - StoneCracker v4.04 Data (not a music file !!!) + - The Player 6.1A (yep !) + +21011998 Version 1.3 (not released) + + Complete rewrite of the package. + Enhanced tests for the XANN packer ... again (*SIGH*) + Added some sort of counter to display where we are in the file. + Somehow, it's useless but it tells the user the prog did not hang :), + the bad news is that it slows down a bit the prog :( ... and it's + ugly !. I'll try to do better sometime later. + New supported formats : + - Fuzzac packer + - Game Music Creator + - Heatseeker mc1.0 + - Kefrens Sound Machine + - Noiserunner + - NoisePacker v1 + - NoisePacker v2 + - NoisePacker v3 + - Promizer 4.0 + - ProPacker v1.0 + - The Player v4.0A + - The Player v4.0B + - The Player v4.1A + - The Player v5.0A + - The Player v6.0A + - Tracker Packer v1 + - Tracker Packer v2 + - Tracker Packer v3 + - Zen Packer + +12111997 Version 1.2 (not released) + + New supported formats : + - UNIC tracker v1 + - UNIC tracker v2 + - Protracker (forgot it :). + +11111997 Version 1.1 (not released) + + SoundMon size calculation bug corrected (synth smp ..) + Enhanced tests for the XANN packer. + Added the possibility to edit the default extensions. + New supported formats : + - AC1D packer + - Digital Illusion + - Eureka packer + - Module protector + - Pha packer + - Promizer v0.1 + - ProPacker v2.1 + - ProPacker v3.0 + - StarTrekker pack + +09111997 Version 1.0 (09/11/97) + First version (not released). diff --git a/prowizard/include/extern.h b/prowizard/include/extern.h new file mode 100755 index 00000000..a6866f83 --- /dev/null +++ b/prowizard/include/extern.h @@ -0,0 +1,313 @@ +/* + * extern.h + * + * part of Pro-Wizard-1 package + * (c) Sylvain "Asle" Chipaux +*/ + +/* tests */ +extern short testAmBk ( void ); +extern short testAC1D ( void ); +extern short testArcDDataCruncher ( void ); +extern short testSoundFX13 ( void ); +extern short testBP ( void ); +extern short testBSIFutureComposer ( void ); +extern short testByteKiller_13 ( void ); +extern short testByteKiller_20 ( void ); +extern short testByteKiller30 ( void ); +extern short testbytekillerpro10 ( void ); +extern short testcrunchmaniaAddr ( void ); +extern short testCRND ( void ); +extern short testDefjam32 ( void ); +extern short testDefjam32pro ( void ); +extern short testDI ( void ); +extern short testDigiBooster17 ( void ); +extern short testDoubleAction10 ( void ); +extern short testEUREKA ( void ); +extern short testFC_M ( void ); +extern short testFC13 ( void ); +extern short testFC14 ( void ); +extern short testFuchsTracker ( void ); +extern short testFUZZAC ( void ); +extern short testGnuPlayer ( void ); +extern short testGMC ( void ); +extern short testGPMO ( void ); +extern short testHEATSEEKER ( void ); +extern short testHQCCruncher2 ( void ); +extern short testHRT ( void ); +extern short testJamCracker ( void ); +extern short testKRIS ( void ); +extern short testKSM ( void ); +extern short testMasterCruncher30addr ( void ); +extern short testMaxPacker12 ( void ); +extern short testMegaCruncher10 ( void ); +extern short testMegaCruncher12 ( void ); +extern short testMegaCruncherObj ( void ); +extern short testMMD0 ( void ); +extern short testNewtron ( void ); +extern short testNFH ( void ); +extern short testNoiserunner ( void ); +extern short testNoisepacker1 ( void ); +extern short testNoisepacker2 ( void ); +extern short testNoisepacker3 ( void ); +extern short testMP_noID ( void ); +extern short testMP_withID ( void ); +extern short testP40A ( void ); +extern short testP41A ( void ); +extern short testP50A ( void ); +extern short testP60A_nopack ( void ); +extern short testP60A_pack ( void ); +extern short testP61A_nopack ( void ); +extern short testP61A_pack ( void ); +extern short testPHA ( void ); +extern short testPM ( void ); +extern short testPM01 ( void ); +extern short testPM10c ( void ); +extern short testPM2 ( void ); +extern short testPM40 ( void ); +extern short testPMZ ( void ); +extern short testPolka ( void ); +extern short testPowerpacker23 ( void ); +extern short testPowerpacker30 ( void ); +extern short testPowerpacker40 ( void ); +extern short testPowerpacker4lib ( void ); +extern short testPP10 ( void ); +extern short testPP21 ( void ); +extern short testPP30 ( void ); +extern short testPPbk ( void ); +extern short testPRUN1 ( void ); +extern short testPRUN2 ( void ); +extern short testPTK ( void ); +extern short testQuadraComposer ( void ); +extern short testRelokIt10 ( void ); +extern short testSKYT ( void ); +extern short testSoundTracker ( void ); +extern short testSpikeCruncher ( void ); +extern short testSTARPACK ( void ); +extern short testSTC299 ( void ); +extern short testSTC299b ( void ); +extern short testSTC299d ( void ); +extern short testSTC300 ( void ); +extern short testSTC310 ( void ); +extern short testSTK26 ( void ); +extern short testSTIM ( void ); +extern short testStoneCracker270 ( void ); +extern short testSuperCruncher27 ( void ); +extern short testSyncroPacker ( void ); +extern short testTetrapack102 ( void ); +extern short testTetrapack_2_1 ( void ); +extern short testTetrapack_2_2 ( void ); +extern short testTheDarkDemon ( void ); +extern short testTimeCruncher17 ( void ); +extern short testTNMCruncher11 ( void ); +extern short testTP1 ( void ); +extern short testTP2 ( void ); +extern short testTP3 ( void ); +extern short testTryIt101 ( void ); +extern short testTurboSqueezer61 ( void ); +extern short testUNIC_noID ( void ); +extern short testUNIC_withID ( void ); +extern short testUNIC_withemptyID ( void ); +extern short testUNIC2 ( void ); +extern short testWN ( void ); +extern short testXANN ( void ); +extern short testXM ( void ); +extern short testZEN ( void ); + +/* rips */ + +extern void Rip_AmBk ( void ); +extern void Rip_AC1D ( void ); +extern void Rip_SoundFX13 ( void ); +extern void Rip_BP ( void ); +extern void Rip_BSIFutureComposer ( void ); +extern void Rip_ByteKiller ( void ); +extern void Rip_ByteKiller30 ( void ); +extern void Rip_bytekillerpro10 ( void ); +extern void Rip_CrunchmaniaAddr ( void ); +extern void Rip_Defjam32 ( void ); +extern void Rip_DI ( void ); +extern void Rip_DigiBooster17 ( void ); +extern void Rip_DoubleAction10 ( void ); +extern void Rip_EUREKA ( void ); +extern void Rip_FC_M ( void ); +extern void Rip_FC13 ( void ); +extern void Rip_FC14 ( void ); +extern void Rip_FuchsTracker ( void ); +extern void Rip_Fuzzac ( void ); +extern void Rip_GnuPlayer ( void ); +extern void Rip_GMC ( void ); +extern void Rip_GPMO ( void ); +extern void Rip_HEATSEEKER ( void ); +extern void Rip_HQCCruncher2 ( void ); +extern void Rip_HRT ( void ); +extern void Rip_JamCracker ( void ); +extern void Rip_KRIS ( void ); +extern void Rip_KSM ( void ); +extern void Rip_MP_noID ( void ); +extern void Rip_MP_withID ( void ); +extern void Rip_Newtron ( void ); +extern void Rip_NFH ( void ); +extern void Rip_Noisepacker1 ( void ); +extern void Rip_Noisepacker2 ( void ); +extern void Rip_Noisepacker3 ( void ); +extern void Rip_Noiserunner ( void ); +extern void Rip_MasterCruncher30addr ( void ); +extern void Rip_MaxPacker12 ( void ); +extern void Rip_MegaCruncher ( void ); +extern void Rip_MegaCruncherObj ( void ); +extern void Rip_MMD0 ( void ); +extern void Rip_P22A ( void ); +extern void Rip_P30A ( void ); +extern void Rip_P40A ( void ); +extern void Rip_P40B ( void ); +extern void Rip_P41A ( void ); +extern void Rip_P50A ( void ); +extern void Rip_P60A ( void ); +extern void Rip_P61A ( void ); +extern void Rip_PHA ( void ); +extern void Rip_PM ( void ); +extern void Rip_PM01 ( void ); +extern void Rip_PM10c ( void ); +extern void Rip_PM18a ( void ); +extern void Rip_PM20 ( void ); +extern void Rip_PM40 ( void ); +extern void Rip_Polka ( void ); +extern void Rip_Powerpacker23 ( void ); +extern void Rip_Powerpacker30 ( void ); +extern void Rip_Powerpacker40 ( void ); +extern void Rip_Powerpacker4lib ( void ); +extern void Rip_PP10 ( void ); +extern void Rip_PP21 ( void ); +extern void Rip_PP30 ( void ); +extern void Rip_PPbk ( void ); +extern void Rip_PTK ( void ); +extern void Rip_QuadraComposer ( void ); +extern void Rip_RelokIt10 ( void ); +extern void Rip_SKYT ( void ); +extern void Rip_SpikeCruncher ( void ); +extern void Rip_SoundTracker ( void ); +extern void Rip_STARPACK ( void ); +extern void Rip_StarTrekker ( void ); +extern void Rip_STC299 ( void ); +extern void Rip_STC299b ( void ); +extern void Rip_STC299d ( void ); +extern void Rip_STC300 ( void ); +extern void Rip_STC310 ( void ); +extern void Rip_STK26 ( void ); +extern void Rip_STIM ( void ); +extern void Rip_StoneCracker270 ( void ); +extern void Rip_SuperCruncher27 ( void ); +extern void Rip_SyncroPacker ( void ); +extern void Rip_Tetrapack102 ( void ); +extern void Rip_Tetrapack_2_1 ( void ); +extern void Rip_Tetrapack_2_2 ( void ); +extern void Rip_TheDarkDemon ( void ); +extern void Rip_TimeCruncher17 ( void ); +extern void Rip_TNMCruncher11 ( void ); +extern void Rip_TP1 ( void ); +extern void Rip_TP2 ( void ); +extern void Rip_TP3 ( void ); +extern void Rip_TryIt101 ( void ); +extern void Rip_TurboSqueezer61 ( void ); +extern void Rip_PRUN2 ( void ); +extern void Rip_PRUN1 ( void ); +extern void Rip_UNIC_withID ( void ); +extern void Rip_UNIC_noID ( void ); +extern void Rip_UNIC2 ( void ); +extern void Rip_WN ( void ); +extern void Rip_XANN ( void ); +extern void Rip_XM ( void ); +extern void Rip_ZEN ( void ); + +/* depack */ + +extern void Depack_AmBk ( void ); +extern void Depack_AC1D ( void ); +extern void Depack_SoundFX13 ( void ); +extern void Depack_DI ( void ); +extern void Depack_EUREKA ( void ); +extern void Depack_FC_M ( void ); +extern void Depack_FuchsTracker ( void ); +extern void Depack_Fuzzac ( void ); +extern void Depack_GnuPlayer ( void ); +extern void Depack_GMC ( void ); +extern void Depack_GPMO ( void ); +extern void Depack_HEATSEEKER ( void ); +extern void Depack_HRT ( void ); +extern void Depack_KRIS ( void ); +extern void Depack_KSM ( void ); +extern void Depack_MP ( void ); +extern void Depack_Newtron ( void ); +extern void Depack_NFH ( void ); +extern void Depack_Noiserunner ( void ); +extern void Depack_Noisepacker1 ( void ); +extern void Depack_Noisepacker2 ( void ); +extern void Depack_Noisepacker3 ( void ); +extern void Depack_P22 ( void ); +extern void Depack_P30 ( void ); +extern void Depack_P40 ( void ); +extern void Depack_P41A ( void ); +extern void Depack_P50A ( void ); +extern void Depack_P60A ( void ); +extern void Depack_P61A ( void ); +extern void Depack_PHA ( void ); +extern void Depack_PM01 ( void ); +extern void Depack_PM10c ( void ); +extern void Depack_PM18a ( void ); +extern void Depack_PM20 ( void ); +extern void Depack_PM40 ( void ); +extern void Depack_PM ( void ); +extern void Depack_Polka ( void ); +extern void Depack_PP10 ( void ); +extern void Depack_PP21 ( void ); +extern void Depack_PP30 ( void ); +extern void Depack_PRUN1 ( void ); +extern void Depack_PRUN2 ( void ); +extern void Depack_QuadraComposer ( void ); +extern void Depack_SKYT ( void ); +extern void Depack_STARPACK ( void ); +extern void Depack_STK26 ( void ); +extern void Depack_STIM ( void ); +extern void Depack_TheDarkDemon ( void ); +extern void Depack_TP1 ( void ); +extern void Depack_TP2 ( void ); +extern void Depack_TP3 ( void ); +extern void Depack_UNIC ( void ); +extern void Depack_UNIC2 ( void ); +extern void Depack_WN ( void ); +extern void Depack_XANN ( void ); +extern void Depack_ZEN ( void ); + +/* misc */ + +extern void Support_Types ( void ); +extern void Support_Types_FileDefault ( void ); +extern void Save_Rip ( char *, int ); +extern void Save_Rip_Special ( char *, int, Uchar * , Ulong ); +extern void Crap ( char *, Uchar, Uchar, FILE *); +extern short testSpecialCruncherData ( long , long ); +extern void Rip_SpecialCruncherData ( char * , int , int ); +extern short test_1_start ( Ulong ); +extern short test_smps ( long, long, long, Uchar, Uchar ); +extern long GetFileSize ( char * ); + +/* globals */ +/* Some say it's badly coding when using Globals ... sure it is, now what's the solution ? */ + +extern FILE *PW_in,*PW_out; +extern long PW_Start_Address; +extern Ulong OutputSize; +extern long PW_in_size; +extern long Cpt_Filename; +extern Ulong PW_i; +extern Ulong PW_j,PW_k,PW_l,PW_m,PW_n,PW_o; +extern Uchar *in_data; +/*extern Uchar OutName[5];*/ +extern char OutName_final[33]; +extern char Depacked_OutName[33]; +extern Uchar Save_Status; +extern Ulong PW_WholeSampleSize; +extern char Extensions[_KNOWN_FORMATS+1][33]; +extern Uchar CONVERT; +extern Uchar Amiga_EXE_Header; diff --git a/prowizard/include/globals.h b/prowizard/include/globals.h new file mode 100755 index 00000000..2e2e0c5c --- /dev/null +++ b/prowizard/include/globals.h @@ -0,0 +1,176 @@ +/* + * ProWizard PC include file +*/ + +#include +#include +#include +#include +#include +#ifndef _WIN32 +#include +#endif +/*#include */ +#ifdef DOS +#include +#endif + +typedef unsigned char Uchar; +typedef unsigned long Ulong; +typedef unsigned short Ushort; + +/* modifications by TW */ + +#include "moduleripper.h" +#ifdef _WIN32 +__inline Ulong htonl (Ulong v) +{ + return (v >> 24) | ((v >> 8) & 0xff00) | (v << 24) | ((v << 8) & 0xff0000); +} +#endif + +extern void write_log (const char *,...); +#define printf write_log +#define mr_fopen moduleripper_fopen +#define mr2_fopen moduleripper2_fopen + +/* modifications end */ + +#define _KNOWN_FORMATS 120 +#define _TYPES_FILENAME "_types_" +#define _TYPES_LINE_LENGHT 256 +#define MINIMAL_FILE_LENGHT 64 +#define GOOD 0 +#define BAD 1 +#define BZERO(a,b) memset(a,0,b) + +enum +{ + AC1D_packer = 0, +/* version 2 / 3 */ + SoundMonitor, + FC_M_packer, + Hornet_packer, + KRIS_tracker, + Power_Music, + Promizer_10c, + Promizer_18a, + Promizer_20, + ProRunner_v1, + ProRunner_v2, + SKYT_packer, + Wanton_packer, + XANN_packer, + Module_protector, + Digital_illusion, + Pha_packer, + Promizer_01, + Propacker_21, + Propacker_30, + Eureka_packer, + Star_pack, + Protracker, + UNIC_v1, + UNIC_v2, + Fuzzac, + GMC, + Heatseeker, + KSM, + Noiserunner, + Noisepacker1, + Noisepacker2, + Noisepacker3, + P40A, + P40B, + P41A, + PM40, + PP10, + TP1, + TP2, + TP3, + ZEN, + P50A, + P60A, + StarTrekker, + /* stands for S404(data/exe),S401(data),S403(data) and S310,S300(data) */ + S404, + StoneCracker270, + P61A, + STIM, + SoundTracker, + TPACK22, +/* stands for CrM! & CrM2 and Crunchmania Address*/ + CRM1, +/* stands for both Defjam 3.2 & 3.2 pro */ + Defjam_32, + TPACK21, + ICE, +/* stands for version 1.3 , 2.0 , 3.0 and Pro 1.0*/ + ByteKiller, + XPK, + IMP, + RNC, + Double_Action, + Powerpacker3, + Powerpacker4, + Powerpacker23, + SpikeCruncher, + TPACK102, + TimeCruncher, + MasterCruncher, +/* stands also for Mega Cruncher 1.0/1.2 */ + MegaCruncher, + JamCracker, + BSIFC, + DigiBooster, + QuadraComposer, + TDD, + FuchsTracker, + SyncroPacker, + TNMCruncher, + SuperCruncher, +/* not for PP20 themselves :) ... only PP20 subfiles inside PPbk */ + PP20, + RelokIt, + STC292data, + FIRE, + MaxPacker, + SoundFX, + arcD, + PARA, + CRND, + SB_DataCruncher, + SF, + RLE, + VDCO, + SQ, + SP, + STK26, + IceTracker, + HQC, + TryIt, + FC13, + FC14, + AmnestyDesign1, + AmnestyDesign2, + MED, + ACECruncherData, + Newtron, + GPMO, + PolkaPacker, + GnuPlayer, + CJ_DataCruncher, + AmBk, + MasterCruncher3data, + XM, + MegaCruncherObj, + TurboSqueezer61, + STC299d, + STC310, + STC299b, + STC299, + STC300, + ThePlayer30a, + ThePlayer22a, + NoiseFromHeaven, +}; diff --git a/prowizard/include/ptktable.h b/prowizard/include/ptktable.h new file mode 100755 index 00000000..e7ffa4b7 --- /dev/null +++ b/prowizard/include/ptktable.h @@ -0,0 +1,49 @@ +/* + * ptk.pitchs + * + * part of Pro-Wizard-1 package + * (c) Sylvain "Asle" Chipaux + * +*/ + + poss[0][0]=0x00, poss[0][1]=0x00; + + poss[1][0]=0x03, poss[1][1]=0x58; + poss[2][0]=0x03, poss[2][1]=0x28; + poss[3][0]=0x02, poss[3][1]=0xfa; + poss[4][0]=0x02, poss[4][1]=0xd0; + poss[5][0]=0x02, poss[5][1]=0xa6; + poss[6][0]=0x02, poss[6][1]=0x80; /* 1 */ + poss[7][0]=0x02, poss[7][1]=0x5c; + poss[8][0]=0x02, poss[8][1]=0x3a; + poss[9][0]=0x02, poss[9][1]=0x1a; + poss[10][0]=0x01, poss[10][1]=0xfc; + poss[11][0]=0x01, poss[11][1]=0xe0; + poss[12][0]=0x01, poss[12][1]=0xc5; + + poss[13][0]=0x01, poss[13][1]=0xac; + poss[14][0]=0x01, poss[14][1]=0x94; + poss[15][0]=0x01, poss[15][1]=0x7d; + poss[16][0]=0x01, poss[16][1]=0x68; + poss[17][0]=0x01, poss[17][1]=0x53; + poss[18][0]=0x01, poss[18][1]=0x40; /* 2 */ + poss[19][0]=0x01, poss[19][1]=0x2e; + poss[20][0]=0x01, poss[20][1]=0x1d; + poss[21][0]=0x01, poss[21][1]=0x0d; + poss[22][0]=0x00, poss[22][1]=0xfe; + poss[23][0]=0x00, poss[23][1]=0xf0; + poss[24][0]=0x00, poss[24][1]=0xe2; + + poss[25][0]=0x00, poss[25][1]=0xd6; + poss[26][0]=0x00, poss[26][1]=0xca; + poss[27][0]=0x00, poss[27][1]=0xbe; + poss[28][0]=0x00, poss[28][1]=0xb4; + poss[29][0]=0x00, poss[29][1]=0xaa; + poss[30][0]=0x00, poss[30][1]=0xa0; /* 3 */ + poss[31][0]=0x00, poss[31][1]=0x97; + poss[32][0]=0x00, poss[32][1]=0x8f; + poss[33][0]=0x00, poss[33][1]=0x87; + poss[34][0]=0x00, poss[34][1]=0x7f; + poss[35][0]=0x00, poss[35][1]=0x78; + poss[36][0]=0x00, poss[36][1]=0x71; + diff --git a/prowizard/include/tuning.h b/prowizard/include/tuning.h new file mode 100755 index 00000000..1faa1e5e --- /dev/null +++ b/prowizard/include/tuning.h @@ -0,0 +1,58 @@ +/* period tables for each tuning + * + * part of Pro-Wizard package + * (c) Asle +*/ + + +short Tuning[16][36] = { + { 856,808,762,720,678,640,604,570,538,508,480,453, + 428,404,381,360,339,320,302,285,269,254,240,226, + 214,202,190,180,170,160,151,143,135,127,120,113 }, + { 850,802,757,715,674,637,601,567,535,505,477,450, + 425,401,379,357,337,318,300,284,268,253,239,225, + 213,201,189,179,169,159,150,142,134,126,119,113 }, + { 844,796,752,709,670,632,597,563,532,502,474,447, + 422,398,376,355,335,316,298,282,266,251,237,224, + 211,199,188,177,167,158,149,141,133,125,118,112 }, + { 838,791,746,704,665,628,592,559,528,498,470,444, + 419,395,373,352,332,314,296,280,264,249,235,222, + 209,198,187,176,166,157,148,140,132,125,118,111 }, + { 832,785,741,699,660,623,588,555,524,495,467,441, + 416,392,370,350,330,312,294,278,262,247,233,220, + 208,196,185,175,165,156,147,139,131,124,117,110 }, + { 826,779,736,694,655,619,584,551,520,491,463,437, + 413,390,368,347,328,309,292,276,260,245,232,219, + 206,195,184,174,164,155,146,138,130,123,116,109 }, + { 820,774,730,689,651,614,580,547,516,487,460,434, + 410,387,365,345,325,307,290,274,258,244,230,217, + 205,193,183,172,163,154,145,137,129,122,115,109 }, + { 814,768,725,684,646,610,575,543,513,484,457,431, + 407,384,363,342,323,305,288,272,256,242,228,216, + 204,192,181,171,161,152,144,136,128,121,114,108 }, + { 907,856,808,762,720,678,640,604,570,538,508,480, + 453,428,404,381,360,339,320,302,285,269,254,240, + 226,214,202,190,180,170,160,151,143,135,127,120 }, + { 900,850,802,757,715,675,636,601,567,535,505,477, + 450,425,401,379,357,337,318,300,284,268,253,238, + 225,212,200,189,179,169,159,150,142,134,126,119 }, + { 894,844,796,752,709,670,632,597,563,532,502,474, + 447,422,398,376,355,335,316,298,282,266,251,237, + 223,211,199,188,177,167,158,149,141,133,125,118 }, + { 887,838,791,746,704,665,628,592,559,528,498,470, + 444,419,395,373,352,332,314,296,280,264,249,235, + 222,209,198,187,176,166,157,148,140,132,125,118 }, + { 881,832,785,741,699,660,623,588,555,524,494,467, + 441,416,392,370,350,330,312,294,278,262,247,233, + 220,208,196,185,175,165,156,147,139,131,123,117 }, + { 875,826,779,736,694,655,619,584,551,520,491,463, + 437,413,390,368,347,328,309,292,276,260,245,232, + 219,206,195,184,174,164,155,146,138,130,123,116 }, + { 868,820,774,730,689,651,614,580,547,516,487,460, + 434,410,387,365,345,325,307,290,274,258,244,230, + 217,205,193,183,172,163,154,145,137,129,122,115 }, + { 862,814,768,725,684,646,610,575,543,513,484,457, + 431,407,384,363,342,323,305,288,272,256,242,228, + 216,203,192,181,171,161,152,144,136,128,121,114 } + }; + diff --git a/prowizard/include/vars.h b/prowizard/include/vars.h new file mode 100755 index 00000000..f69dfc47 --- /dev/null +++ b/prowizard/include/vars.h @@ -0,0 +1,24 @@ +/* + * "vars.h" + * + * Part of Pro-Wizard-1 Package + * (c) Sylvain "Asle" Chipaux +*/ + + +FILE *PW_in,*PW_out; +long PW_Start_Address=0; +Ulong OutputSize=0; +long PW_in_size; +long Cpt_Filename=0l; +Ulong PW_i; +Ulong PW_j,PW_k,PW_l,PW_m,PW_n,PW_o; +Uchar *in_data; +/*Uchar OutName[5]={'.','-','-','-',0x00};*/ +char OutName_final[33]; +char Depacked_OutName[33]; +Uchar Save_Status = GOOD; +Ulong PW_WholeSampleSize=0; +char Extensions[_KNOWN_FORMATS+1][33]; +Uchar CONVERT = BAD; +Uchar Amiga_EXE_Header = GOOD; diff --git a/prowizard/interf/INTERF.H b/prowizard/interf/INTERF.H new file mode 100755 index 00000000..8b137891 --- /dev/null +++ b/prowizard/interf/INTERF.H @@ -0,0 +1 @@ + diff --git a/prowizard/interf/INTFDUMB.C b/prowizard/interf/INTFDUMB.C new file mode 100755 index 00000000..76502c9d --- /dev/null +++ b/prowizard/interf/INTFDUMB.C @@ -0,0 +1,3 @@ +# here things for the dumb interface like dos or unix console +# will go in +# diff --git a/prowizard/interf/INTFGTK.C b/prowizard/interf/INTFGTK.C new file mode 100755 index 00000000..08fc6743 --- /dev/null +++ b/prowizard/interf/INTFGTK.C @@ -0,0 +1,2 @@ +# gtk interface. Yet to be done +# diff --git a/prowizard/makefile b/prowizard/makefile new file mode 100755 index 00000000..e1df7edf --- /dev/null +++ b/prowizard/makefile @@ -0,0 +1,98 @@ +# Makefile for Pro-Wizard 1 (for PeeCee) +# copyright 1997-2003 Sylvain "asle" Chipaux + +CFLAGS = -O6 -Wall -mpentiumpro -g2 -I/usr/local/include -DDMALLOC \ + -Wtraditional -Wshadow -Wcast-align -Wstrict-prototypes \ + -Wmissing-prototypes -Wredundant-decls -Wnested-externs \ + -save-temps +CC = gcc + +# + +OFILES = prowiz.o \ + tests/ac1d.o tests/bp.o tests/di.o tests/eureka.o \ + tests/fc_m.o tests/fuzzac.o tests/gmc.o tests/heatseek.o \ + tests/hrt.o tests/kris.o tests/ksm.o tests/mp.o \ + tests/noiserun.o tests/npd1.o tests/npd2.o tests/npd3.o \ + tests/p40a.o tests/p41a.o tests/p50a.o tests/p60a.o tests/p61a.o \ + tests/pha.o tests/pm.o tests/pm01.o tests/pm10c.o \ + tests/pm20.o tests/pm40.o tests/pmz.o tests/pp10.o \ + tests/pp21.o tests/pp30.o \ + tests/prun1.o tests/prun2.o tests/ptk.o tests/skyt.o \ + tests/soundtk.o tests/starpack.o tests/stim.o \ + tests/tp1.o tests/tp2.o tests/tp3.o \ + tests/unic.o tests/unic2.o tests/wn.o \ + tests/xann.o tests/zen.o \ + tests/defjam32.o tests/tpack22.o tests/tpack21.o tests/defja32p.o \ + tests/bytek13.o tests/dblatn.o tests/powerp30.o tests/powerp40.o \ + tests/powerp23.o tests/bytek20.o tests/spike.o tests/tpack102.o \ + tests/time17.o tests/mc30addr.o tests/jamcrack.o tests/bsifc.o \ + tests/digibst.o tests/mcrun10.o tests/mcrun12.o tests/qc.o \ + tests/tdd.o tests/fuchs.o tests/bytek30.o tests/syncro.o \ + tests/stc270.o tests/tnmc11.o tests/superc27.o tests/ppbk.o \ + tests/relokit.o tests/maxpac12.o tests/soundfx.o tests/arcd.o \ + tests/crnd.o tests/stk26.o tests/bytekp10.o tests/hqc2.o \ + tests/tryit101.o tests/fc13.o tests/fc14.o tests/crmaddr.o tests/mmd0.o \ + tests/powerp4l.o tests/newtron.o tests/gpmo.o tests/polka.o \ + tests/gnpl.o tests/ambk.o tests/xm.o tests/mcobj.o tests/turbosqueezer61.o \ + tests/stc299d.o tests/stc310.o tests/stc299b.o tests/stc299.o tests/stc300.o \ + tests/nfh.o \ + rips/ac1d.o rips/bp.o rips/di.o rips/eureka.o rips/fc_m.o \ + rips/fuzzac.o rips/hrt.o rips/kris.o rips/mp.o rips/pha.o \ + rips/pm.o rips/pm01.o rips/pm10c.o rips/pm20.o rips/pm18a.o \ + rips/pp21.o rips/pp30.o rips/prun1.o rips/prun2.o rips/ptk.o \ + rips/skyt.o rips/starpack.o rips/unic.o rips/unic2.o rips/wn.o \ + rips/xann.o rips/gmc.o rips/heatseek.o rips/ksm.o \ + rips/noiserun.o rips/npd1.o rips/npd2.o rips/npd3.o \ + rips/p40a.o rips/p40b.o rips/p41a.o rips/pm40.o rips/pp10.o \ + rips/tp1.o rips/tp2.o rips/tp3.o rips/zen.o rips/p50a.o \ + rips/p60a.o rips/startrek.o rips/p61a.o rips/stim.o \ + rips/soundtk.o rips/defjam32.o rips/tpack22.o rips/tpack21.o \ + rips/mcrun.o rips/bytekil.o rips/dblatn.o rips/powerp30.o \ + rips/powerp40.o rips/powerp23.o rips/spike.o rips/tpack102.o \ + rips/digibst.o rips/time17.o rips/mc30addr.o rips/jamcrack.o \ + rips/bsifc.o rips/qc.o rips/tdd.o rips/fuchs.o rips/bytek30.o \ + rips/syncro.o rips/stc270.o rips/tnmc11.o rips/superc27.o \ + rips/ppbk.o rips/relokit.o rips/maxpac12.o rips/soundfx.o \ + rips/stk26.o rips/bytekp10.o rips/hqc2.o rips/tryit101.o \ + rips/fc13.o rips/fc14.o rips/crmaddr.o rips/med.o rips/powerp4l.o \ + rips/newtron.o rips/gpmo.o rips/polka.o rips/gnpl.o rips/ambk.o \ + rips/xm.o rips/mcobj.o rips/turbosqueezer61.o rips/stc299d.o \ + rips/stc310.o rips/stc299b.o rips/stc299.o rips/stc300.o rips/p22a.o \ + rips/p30a.o rips/nfh.o \ + depack/ac1d.o depack/di.o depack/eureka.o depack/fc-m.o \ + depack/fuzzac.o depack/gmc.o depack/heatseek.o depack/hrt.o \ + depack/kris.o depack/ksm.o depack/mp.o depack/noiserun.o \ + depack/np1.o depack/np2.o depack/np3.o depack/p40.o depack/p41a.o \ + depack/p50a.o depack/p60a.o depack/p61a.o depack/pha.o \ + depack/pm01.o depack/pm10c.o depack/pm18a.o depack/pm20.o \ + depack/pm40.o depack/pm.o depack/pp10.o depack/pp21.o \ + depack/pp30.o depack/prun1.o depack/prun2.o depack/skyt.o \ + depack/starpack.o depack/tp1.o depack/tp2.o depack/tp3.o \ + depack/unic.o depack/unic2.o depack/wn.o depack/xann.o \ + depack/zen.o depack/stim.o depack/qc.o depack/tdd.o \ + depack/fuchs.o depack/soundfx.o depack/stk26.o depack/newtron.o \ + depack/gpmo.o depack/polka.o depack/gnpl.o depack/ambk.o \ + depack/p30a.o depack/p22a.o depack/nfh.o \ + misc/misc.o misc/testbag.o + +EXEFILE = prowiz.exe + +.c.o: + $(CC) -DUNIX $(CFLAGS) -c $< -o $@ + +prowiz: $(OFILES) + $(CC) -o $(EXEFILE) -L/usr/local/lib -ldmalloc $(OFILES) + +# +clean: clear + rm -f *.o + rm -f tests/*.o + rm -f rips/*.o + rm -f depack/*.o + rm -f misc/*.o + rm -f core *.core + +# +clear: + rm -f *~ *.*~ tests/*~ tests/*.*~ rips/*~ rips/*.*~ misc/*~ misc/*.*~ include/*~ include/*.*~ depack/*~ depack/*.*~ *.i *.s diff --git a/prowizard/makefile.amiga b/prowizard/makefile.amiga new file mode 100755 index 00000000..689507be --- /dev/null +++ b/prowizard/makefile.amiga @@ -0,0 +1,93 @@ +# Makefile for Pro-Wizard 1 (for PeeCee) +# copyright 1997-2002 Sylvain "asle" Chipaux +# Amiga port (05/2002) + +CFLAGS = -Wall -m68020 -IGNU:include +CC = gcc + +# + +OFILES = prowiz.o tests/ac1d.o tests/bp.o tests/di.o tests/eureka.o \ + tests/fc_m.o tests/fuzzac.o tests/hrt.o tests/kris.o \ + tests/mp.o tests/pha.o tests/pm.o tests/pm01.o tests/pm10c.o \ + tests/pm20.o tests/pmz.o tests/pp21.o tests/pp30.o \ + tests/prun1.o tests/prun2.o tests/ptk.o tests/skyt.o \ + tests/starpack.o tests/unic.o tests/unic2.o tests/wn.o \ + tests/xann.o tests/gmc.o tests/heatseek.o tests/ksm.o \ + tests/noiserun.o tests/npd1.o tests/npd2.o tests/npd3.o \ + tests/p40a.o tests/p41a.o tests/pm40.o tests/pp10.o \ + tests/tp1.o tests/tp2.o tests/tp3.o tests/zen.o tests/p50a.o \ + tests/p60a.o tests/p61a.o tests/stim.o tests/soundtk.o \ + tests/defjam32.o tests/tpack22.o tests/tpack21.o tests/defja32p.o \ + tests/bytek13.o tests/dblatn.o tests/powerp30.o tests/powerp40.o \ + tests/powerp23.o tests/bytek20.o tests/spike.o tests/tpack102.o \ + tests/time17.o tests/mc30addr.o tests/jamcrack.o tests/bsifc.o \ + tests/digibst.o tests/mcrun10.o tests/mcrun12.o tests/qc.o \ + tests/tdd.o tests/fuchs.o tests/bytek30.o tests/syncro.o \ + tests/stc270.o tests/tnmc11.o tests/superc27.o tests/ppbk.o \ + tests/relokit.o tests/maxpac12.o tests/soundfx.o tests/arcd.o \ + tests/crnd.o tests/stk26.o tests/bytekp10.o tests/hqc2.o \ + tests/tryit101.o tests/fc13.o tests/fc14.o tests/crmaddr.o tests/mmd0.o \ + tests/powerp4l.o tests/newtron.o tests/gpmo.o tests/polka.o \ + tests/gnpl.o tests/ambk.o tests/xm.o tests/mcobj.o tests/turbosqueezer61.o \ + tests/stc299d.o tests/stc310.o tests/stc299b.o tests/stc299.o tests/stc300.o \ + tests/nfh.o \ + rips/ac1d.o rips/bp.o rips/di.o rips/eureka.o rips/fc_m.o \ + rips/fuzzac.o rips/hrt.o rips/kris.o rips/mp.o rips/pha.o \ + rips/pm.o rips/pm01.o rips/pm10c.o rips/pm20.o rips/pm18a.o \ + rips/pp21.o rips/pp30.o rips/prun1.o rips/prun2.o rips/ptk.o \ + rips/skyt.o rips/starpack.o rips/unic.o rips/unic2.o rips/wn.o \ + rips/xann.o rips/gmc.o rips/heatseek.o rips/ksm.o \ + rips/noiserun.o rips/npd1.o rips/npd2.o rips/npd3.o \ + rips/p40a.o rips/p40b.o rips/p41a.o rips/pm40.o rips/pp10.o \ + rips/tp1.o rips/tp2.o rips/tp3.o rips/zen.o rips/p50a.o \ + rips/p60a.o rips/startrek.o rips/p61a.o rips/stim.o \ + rips/soundtk.o rips/defjam32.o rips/tpack22.o rips/tpack21.o \ + rips/mcrun.o rips/bytekil.o rips/dblatn.o rips/powerp30.o \ + rips/powerp40.o rips/powerp23.o rips/spike.o rips/tpack102.o \ + rips/digibst.o rips/time17.o rips/mc30addr.o rips/jamcrack.o \ + rips/bsifc.o rips/qc.o rips/tdd.o rips/fuchs.o rips/bytek30.o \ + rips/syncro.o rips/stc270.o rips/tnmc11.o rips/superc27.o \ + rips/ppbk.o rips/relokit.o rips/maxpac12.o rips/soundfx.o \ + rips/stk26.o rips/bytekp10.o rips/hqc2.o rips/tryit101.o \ + rips/fc13.o rips/fc14.o rips/crmaddr.o rips/med.o rips/powerp4l.o \ + rips/newtron.o rips/gpmo.o rips/polka.o rips/gnpl.o rips/ambk.o \ + rips/xm.o rips/mcobj.o rips/turbosqueezer61.o rips/stc299d.o \ + rips/stc310.o rips/stc299b.o rips/stc299.o rips/stc300.o rips/p22a.o \ + rips/p30a.o rips/nfh.o \ + depack/ac1d.o depack/di.o depack/eureka.o depack/fc-m.o \ + depack/fuzzac.o depack/gmc.o depack/heatseek.o depack/hrt.o \ + depack/kris.o depack/ksm.o depack/mp.o depack/noiserun.o \ + depack/np1.o depack/np2.o depack/np3.o depack/p40.o depack/p41a.o \ + depack/p50a.o depack/p60a.o depack/p61a.o depack/pha.o \ + depack/pm01.o depack/pm10c.o depack/pm18a.o depack/pm20.o \ + depack/pm40.o depack/pm.o depack/pp10.o depack/pp21.o \ + depack/pp30.o depack/prun1.o depack/prun2.o depack/skyt.o \ + depack/starpack.o depack/tp1.o depack/tp2.o depack/tp3.o \ + depack/unic.o depack/unic2.o depack/wn.o depack/xann.o \ + depack/zen.o depack/stim.o depack/qc.o depack/tdd.o \ + depack/fuchs.o depack/soundfx.o depack/stk26.o depack/newtron.o \ + depack/gpmo.o depack/polka.o depack/gnpl.o depack/ambk.o \ + depack/p30a.o depack/p22a.o depack/nfh.o \ + misc/misc.o misc/testbag.o + +EXEFILE = prowiz.exe + +.c.o: + $(CC) -DUNIX $(CFLAGS) -c $< -o zob:pr/$@ + +prowiz: $(OFILES) + $(CC) -o $(EXEFILE) $(OFILES) + +# +clean: clear + rm -f *.o + rm -f tests/*.o + rm -f rips/*.o + rm -f depack/*.o + rm -f misc/*.o + rm -f core *.core + +# +clear: + rm -f *~ *.*~ tests/*~ tests/*.*~ rips/*~ rips/*.*~ misc/*~ misc/*.*~ include/*~ include/*.*~ depack/*~ depack/*.*~ diff --git a/prowizard/makefile.dos b/prowizard/makefile.dos new file mode 100755 index 00000000..30c9524b --- /dev/null +++ b/prowizard/makefile.dos @@ -0,0 +1,145 @@ +# Makefile for Pro-Wizard 1 (for PeeCee) +# copyright 1997-2001 Sylvain "asle" Chipaux + +CFLAGS = -O6 -m486 -Wall -mpentiumpro +CC = gcc + +# + +CFILES = prowiz.o tests/ac1d.o tests/bp.o tests/di.o tests/eureka.o \ + tests/fc_m.o tests/fuzzac.o tests/hrt.o tests/kris.o \ + tests/mp.o tests/pha.o tests/pm.o tests/pm01.o tests/pm10c.o \ + tests/pm20.o tests/pmz.o tests/pp21.o tests/pp30.o \ + tests/prun1.o tests/prun2.o tests/ptk.o tests/skyt.o \ + tests/starpack.o tests/unic.o tests/unic2.o tests/wn.o \ + tests/xann.o tests/gmc.o tests/heatseek.o tests/ksm.o \ + tests/noiserun.o tests/npd1.o tests/npd2.o tests/npd3.o \ + tests/p40a.o tests/p41a.o tests/pm40.o tests/pp10.o \ + tests/tp1.o tests/tp2.o tests/tp3.o tests/zen.o tests/p50a.o \ + tests/p60a.o tests/p61a.o tests/stim.o tests/soundtk.o \ + tests/defjam32.o tests/tpack22.o tests/tpack21.o tests/defja32p.o \ + tests/bytek13.o tests/dblatn.o tests/powerp30.o tests/powerp40.o \ + tests/powerp23.o tests/bytek20.o tests/spike.o tests/tpack102.o \ + tests/time17.o tests/mc30addr.o tests/jamcrack.o tests/bsifc.o \ + tests/digibst.o tests/mcrun10.o tests/mcrun12.o tests/qc.o \ + tests/tdd.o tests/fuchs.o tests/bytek30.o tests/syncro.o \ + tests/stc270.o tests/tnmc11.o tests/superc27.o tests/ppbk.o \ + tests/relokit.o tests/maxpac12.o tests/soundfx.o tests/arcd.o \ + tests/crnd.o tests/stk26.o tests/bytekp10.o tests/hqc2.o \ + tests/tryit101.o tests/fc13.o tests/fc14.o tests/crmaddr.o tests/mmd0.o \ + tests/powerp4l.o tests/newtron.o tests/gpmo.o tests/polka.o \ + tests/gnpl.o tests/ambk.o tests/xm.o tests/mcobj.o tests/turbosqueezer61.o \ + tests/stc299d.o \ + rips/ac1d.o rips/bp.o rips/di.o rips/eureka.o rips/fc_m.o \ + rips/fuzzac.o rips/hrt.o rips/kris.o rips/mp.o rips/pha.o \ + rips/pm.o rips/pm01.o rips/pm10c.o rips/pm20.o rips/pm18a.o \ + rips/pp21.o rips/pp30.o rips/prun1.o rips/prun2.o rips/ptk.o \ + rips/skyt.o rips/starpack.o rips/unic.o rips/unic2.o rips/wn.o \ + rips/xann.o rips/gmc.o rips/heatseek.o rips/ksm.o \ + rips/noiserun.o rips/npd1.o rips/npd2.o rips/npd3.o \ + rips/p40a.o rips/p40b.o rips/p41a.o rips/pm40.o rips/pp10.o \ + rips/tp1.o rips/tp2.o rips/tp3.o rips/zen.o rips/p50a.o \ + rips/p60a.o rips/startrek.o rips/p61a.o rips/stim.o \ + rips/soundtk.o rips/defjam32.o rips/tpack22.o rips/tpack21.o \ + rips/mcrun.o rips/bytekil.o rips/dblatn.o rips/powerp30.o \ + rips/powerp40.o rips/powerp23.o rips/spike.o rips/tpack102.o \ + rips/digibst.o rips/time17.o rips/mc30addr.o rips/jamcrack.o \ + rips/bsifc.o rips/qc.o rips/tdd.o rips/fuchs.o rips/bytek30.o \ + rips/syncro.o rips/stc270.o rips/tnmc11.o rips/superc27.o \ + rips/ppbk.o rips/relokit.o rips/maxpac12.o rips/soundfx.o \ + rips/stk26.o rips/bytekp10.o rips/hqc2.o rips/tryit101.o \ + rips/fc13.o rips/fc14.o rips/crmaddr.o rips/med.o rips/powerp4l.o \ + rips/newtron.o rips/gpmo.o rips/polka.o rips/gnpl.o rips/ambk.o \ + rips/xm.o rips/mcobj.o rips/turbosqueezer61.o rips/stc299d.o \ + depack/ac1d.o depack/di.o depack/eureka.o depack/fc-m.o \ + depack/fuzzac.o depack/gmc.o depack/heatseek.o depack/hrt.o \ + depack/kris.o depack/ksm.o depack/mp.o depack/noiserun.o \ + depack/np1.o depack/np2.o depack/np3.o depack/p40.o depack/p41a.o \ + depack/p50a.o depack/p60a.o depack/p61a.o depack/pha.o \ + depack/pm01.o depack/pm10c.o depack/pm18a.o depack/pm20.o \ + depack/pm40.o depack/pm.o depack/pp10.o depack/pp21.o \ + depack/pp30.o depack/prun1.o depack/prun2.o depack/skyt.o \ + depack/starpack.o depack/tp1.o depack/tp2.o depack/tp3.o \ + depack/unic.o depack/unic2.o depack/wn.o depack/xann.o \ + depack/zen.o depack/stim.o depack/qc.o depack/tdd.o \ + depack/fuchs.o depack/soundfx.o depack/stk26.o depack/newtron.o \ + depack/gpmo.o depack/polka.o depack/gnpl.o depack/ambk.o \ + misc/misc.o misc/testbag.o + +OFILES = prowiz.o tests/ac1d.o tests/bp.o tests/di.o tests/eureka.o \ + tests/fc_m.o tests/fuzzac.o tests/hrt.o tests/kris.o \ + tests/mp.o tests/pha.o tests/pm.o tests/pm01.o tests/pm10c.o \ + tests/pm20.o tests/pmz.o tests/pp21.o tests/pp30.o \ + tests/prun1.o tests/prun2.o tests/ptk.o tests/skyt.o \ + tests/starpack.o tests/unic.o tests/unic2.o tests/wn.o \ + tests/xann.o tests/gmc.o tests/heatseek.o tests/ksm.o \ + tests/noiserun.o tests/npd1.o tests/npd2.o tests/npd3.o \ + tests/p40a.o tests/p41a.o tests/pm40.o tests/pp10.o \ + tests/tp1.o tests/tp2.o tests/tp3.o tests/zen.o tests/p50a.o \ + tests/p60a.o tests/p61a.o tests/stim.o tests/soundtk.o \ + tests/defjam32.o tests/tpack22.o tests/tpack21.o tests/defja32p.o \ + tests/bytek13.o tests/dblatn.o tests/powerp30.o tests/powerp40.o \ + tests/powerp23.o tests/bytek20.o tests/spike.o tests/tpack102.o \ + tests/time17.o tests/mc30addr.o tests/jamcrack.o tests/bsifc.o \ + tests/digibst.o tests/mcrun10.o tests/mcrun12.o tests/qc.o \ + tests/tdd.o tests/fuchs.o tests/bytek30.o tests/syncro.o \ + tests/stc270.o tests/tnmc11.o tests/superc27.o tests/ppbk.o \ + tests/relokit.o tests/maxpac12.o tests/soundfx.o tests/arcd.o \ + tests/crnd.o tests/stk26.o tests/bytekp10.o tests/hqc2.o \ + tests/tryit101.o tests/fc13.o tests/fc14.o tests/crmaddr.o tests/mmd0.o \ + tests/powerp4l.o tests/newtron.o tests/gpmo.o \ + rips/ac1d.o rips/bp.o rips/di.o rips/eureka.o rips/fc_m.o \ + rips/fuzzac.o rips/hrt.o rips/kris.o rips/mp.o rips/pha.o \ + rips/pm.o rips/pm01.o rips/pm10c.o rips/pm20.o rips/pm18a.o \ + rips/pp21.o rips/pp30.o rips/prun1.o rips/prun2.o rips/ptk.o \ + rips/skyt.o rips/starpack.o rips/unic.o rips/unic2.o rips/wn.o \ + rips/xann.o rips/gmc.o rips/heatseek.o rips/ksm.o \ + rips/noiserun.o rips/npd1.o rips/npd2.o rips/npd3.o \ + rips/p40a.o rips/p40b.o rips/p41a.o rips/pm40.o rips/pp10.o \ + rips/tp1.o rips/tp2.o rips/tp3.o rips/zen.o rips/p50a.o \ + rips/p60a.o rips/startrek.o rips/p61a.o rips/stim.o \ + rips/soundtk.o rips/defjam32.o rips/tpack22.o rips/tpack21.o \ + rips/mcrun.o rips/bytekil.o rips/dblatn.o rips/powerp30.o \ + rips/powerp40.o rips/powerp23.o rips/spike.o rips/tpack102.o \ + rips/digibst.o rips/time17.o rips/mc30addr.o rips/jamcrack.o \ + rips/bsifc.o rips/qc.o rips/tdd.o rips/fuchs.o rips/bytek30.o \ + rips/syncro.o rips/stc270.o rips/tnmc11.o rips/superc27.o \ + rips/ppbk.o rips/relokit.o rips/maxpac12.o rips/soundfx.o \ + rips/stk26.o rips/bytekp10.o rips/hqc2.o rips/tryit101.o \ + rips/fc13.o rips/fc14.o rips/crmaddr.o rips/med.o rips/powerp4l.o \ + rips/newtron.o rips/gpmo.o \ + depack/ac1d.o depack/di.o depack/eureka.o depack/fc-m.o \ + depack/fuzzac.o depack/gmc.o depack/heatseek.o depack/hrt.o \ + depack/kris.o depack/ksm.o depack/mp.o depack/noiserun.o \ + depack/np1.o depack/np2.o depack/np3.o depack/p40.o depack/p41a.o \ + depack/p50a.o depack/p60a.o depack/p61a.o depack/pha.o \ + depack/pm01.o depack/pm10c.o depack/pm18a.o depack/pm20.o \ + depack/pm40.o depack/pm.o depack/pp10.o depack/pp21.o \ + depack/pp30.o depack/prun1.o depack/prun2.o depack/skyt.o \ + depack/starpack.o depack/tp1.o depack/tp2.o depack/tp3.o \ + depack/unic.o depack/unic2.o depack/wn.o depack/xann.o \ + depack/zen.o depack/stim.o depack/qc.o depack/tdd.o \ + depack/fuchs.o depack/soundfx.o depack/stk26.o depack/newtron.o \ + depack/gpmo.o \ + misc/misc.o misc/testbag.o + +EXEFILE = prowiz.exe + +.c.o: + $(CC) -DDOS $(CFLAGS) -c $< -o $@ + +prowiz: $(OFILES) + $(CC) -o $(EXEFILE) $(OFILES) + +# +clean: clear + rm -f *.o + rm -f tests/*.o + rm -f rips/*.o + rm -f depack/*.o + rm -f misc/*.o + rm -f core + +# +clear: + rm -f *~ *.*~ tests/*~ tests/*.*~ rips/*~ rips/*.*~ misc/*~ misc/*.*~ include/*~ include/*.*~ depack/*~ depack/*.*~ diff --git a/prowizard/makefile.mingwin32 b/prowizard/makefile.mingwin32 new file mode 100755 index 00000000..9ce897f2 --- /dev/null +++ b/prowizard/makefile.mingwin32 @@ -0,0 +1,102 @@ +# Makefile for Pro-Wizard 1 (for PeeCee) +# copyright 1997-2003 Sylvain "asle" Chipaux +# Fixed for MinGWin32 by Xigh !... Thx + +CFLAGS = -O6 -Wall -march=pentiumpro +CC = gcc + +# + + +OFILES = prowiz.o tests/ac1d.o tests/bp.o tests/di.o tests/eureka.o \ + tests/fc_m.o tests/fuzzac.o tests/hrt.o tests/kris.o \ + tests/mp.o tests/pha.o tests/pm.o tests/pm01.o tests/pm10c.o \ + tests/pm20.o tests/pmz.o tests/pp21.o tests/pp30.o \ + tests/prun1.o tests/prun2.o tests/ptk.o tests/skyt.o \ + tests/starpack.o tests/unic.o tests/unic2.o tests/wn.o \ + tests/xann.o tests/gmc.o tests/heatseek.o tests/ksm.o \ + tests/noiserun.o tests/npd1.o tests/npd2.o tests/npd3.o \ + tests/p40a.o tests/p41a.o tests/pm40.o tests/pp10.o \ + tests/tp1.o tests/tp2.o tests/tp3.o tests/zen.o tests/p50a.o \ + tests/p60a.o tests/p61a.o tests/stim.o tests/soundtk.o \ + tests/defjam32.o tests/tpack22.o tests/tpack21.o tests/defja32p.o \ + tests/bytek13.o tests/dblatn.o tests/powerp30.o tests/powerp40.o \ + tests/powerp23.o tests/bytek20.o tests/spike.o tests/tpack102.o \ + tests/time17.o tests/mc30addr.o tests/jamcrack.o tests/bsifc.o \ + tests/digibst.o tests/mcrun10.o tests/mcrun12.o tests/qc.o \ + tests/tdd.o tests/fuchs.o tests/bytek30.o tests/syncro.o \ + tests/stc270.o tests/tnmc11.o tests/superc27.o tests/ppbk.o \ + tests/relokit.o tests/maxpac12.o tests/soundfx.o tests/arcd.o \ + tests/crnd.o tests/stk26.o tests/bytekp10.o tests/hqc2.o \ + tests/tryit101.o tests/fc13.o tests/fc14.o tests/crmaddr.o tests/mmd0.o \ + tests/powerp4l.o tests/newtron.o tests/gpmo.o tests/polka.o \ + tests/gnpl.o tests/ambk.o tests/xm.o tests/mcobj.o tests/turbosqueezer61.o \ + tests/stc299d.o tests/stc310.o tests/stc299b.o tests/nfh.o \ + rips/ac1d.o rips/bp.o rips/di.o rips/eureka.o rips/fc_m.o \ + rips/fuzzac.o rips/hrt.o rips/kris.o rips/mp.o rips/pha.o \ + rips/pm.o rips/pm01.o rips/pm10c.o rips/pm20.o rips/pm18a.o \ + rips/pp21.o rips/pp30.o rips/prun1.o rips/prun2.o rips/ptk.o \ + rips/skyt.o rips/starpack.o rips/unic.o rips/unic2.o rips/wn.o \ + rips/xann.o rips/gmc.o rips/heatseek.o rips/ksm.o \ + rips/noiserun.o rips/npd1.o rips/npd2.o rips/npd3.o \ + rips/p40a.o rips/p40b.o rips/p41a.o rips/pm40.o rips/pp10.o \ + rips/tp1.o rips/tp2.o rips/tp3.o rips/zen.o rips/p50a.o \ + rips/p60a.o rips/startrek.o rips/p61a.o rips/stim.o \ + rips/soundtk.o rips/defjam32.o rips/tpack22.o rips/tpack21.o \ + rips/mcrun.o rips/bytekil.o rips/dblatn.o rips/powerp30.o \ + rips/powerp40.o rips/powerp23.o rips/spike.o rips/tpack102.o \ + rips/digibst.o rips/time17.o rips/mc30addr.o rips/jamcrack.o \ + rips/bsifc.o rips/qc.o rips/tdd.o rips/fuchs.o rips/bytek30.o \ + rips/syncro.o rips/stc270.o rips/tnmc11.o rips/superc27.o \ + rips/ppbk.o rips/relokit.o rips/maxpac12.o rips/soundfx.o \ + rips/stk26.o rips/bytekp10.o rips/hqc2.o rips/tryit101.o \ + rips/fc13.o rips/fc14.o rips/crmaddr.o rips/med.o rips/powerp4l.o \ + rips/newtron.o rips/gpmo.o rips/polka.o rips/gnpl.o rips/ambk.o \ + rips/xm.o rips/mcobj.o rips/turbosqueezer61.o rips/stc299d.o \ + rips/stc310.o rips/stc299b.o rips/nfh.o \ + depack/ac1d.o depack/di.o depack/eureka.o depack/fc-m.o \ + depack/fuzzac.o depack/gmc.o depack/heatseek.o depack/hrt.o \ + depack/kris.o depack/ksm.o depack/mp.o depack/noiserun.o \ + depack/np1.o depack/np2.o depack/np3.o depack/p40.o depack/p41a.o \ + depack/p50a.o depack/p60a.o depack/p61a.o depack/pha.o \ + depack/pm01.o depack/pm10c.o depack/pm18a.o depack/pm20.o \ + depack/pm40.o depack/pm.o depack/pp10.o depack/pp21.o \ + depack/pp30.o depack/prun1.o depack/prun2.o depack/skyt.o \ + depack/starpack.o depack/tp1.o depack/tp2.o depack/tp3.o \ + depack/unic.o depack/unic2.o depack/wn.o depack/xann.o \ + depack/zen.o depack/stim.o depack/qc.o depack/tdd.o \ + depack/fuchs.o depack/soundfx.o depack/stk26.o depack/newtron.o \ + depack/gpmo.o depack/polka.o depack/gnpl.o depack/ambk.o \ + depack/nfh.o \ + misc/misc.o misc/testbag.o + +EXEFILE = prowiz.exe + +.c.o: + $(CC) -DDOS $(CFLAGS) -c $< -o $@ + +prowiz: $(OFILES) + $(CC) -o $(EXEFILE) $(OFILES) + +# +clean: clear + -CMD /c "DEL /F /Q *.o" + -CMD /c "DEL /F /Q tests\*.o" + -CMD /c "DEL /F /Q rips\*.o" + -CMD /c "DEL /F /Q depack\*.o" + -CMD /c "DEL /F /Q misc\*.o" + -CMD /c "DEL /F /Q core" + +# +clear: + -CMD /c "DEL /F /Q *.*~" + -CMD /c "DEL /F /Q tests\*~" + -CMD /c "DEL /F /Q tests\*.*~" + -CMD /c "DEL /F /Q rips\*~" + -CMD /c "DEL /F /Q rips\*.*~" + -CMD /c "DEL /F /Q misc\*~" + -CMD /c "DEL /F /Q misc\*.*~" + -CMD /c "DEL /F /Q include\*~" + -CMD /c "DEL /F /Q include\*.*~" + -CMD /c "DEL /F /Q depack\*~" + -CMD /c "DEL /F /Q depack\*.*~" diff --git a/prowizard/makefile.unix b/prowizard/makefile.unix new file mode 100755 index 00000000..3c768204 --- /dev/null +++ b/prowizard/makefile.unix @@ -0,0 +1,92 @@ +# Makefile for Pro-Wizard 1 (for PeeCee) +# copyright 1997-2001 Sylvain "asle" Chipaux + +CFLAGS = -O6 -Wall -mpentiumpro -g2 -I/usr/local/include -DDMALLOC +CC = gcc + +# + +OFILES = prowiz.o tests/ac1d.o tests/bp.o tests/di.o tests/eureka.o \ + tests/fc_m.o tests/fuzzac.o tests/hrt.o tests/kris.o \ + tests/mp.o tests/pha.o tests/pm.o tests/pm01.o tests/pm10c.o \ + tests/pm20.o tests/pmz.o tests/pp21.o tests/pp30.o \ + tests/prun1.o tests/prun2.o tests/ptk.o tests/skyt.o \ + tests/starpack.o tests/unic.o tests/unic2.o tests/wn.o \ + tests/xann.o tests/gmc.o tests/heatseek.o tests/ksm.o \ + tests/noiserun.o tests/npd1.o tests/npd2.o tests/npd3.o \ + tests/p40a.o tests/p41a.o tests/pm40.o tests/pp10.o \ + tests/tp1.o tests/tp2.o tests/tp3.o tests/zen.o tests/p50a.o \ + tests/p60a.o tests/p61a.o tests/stim.o tests/soundtk.o \ + tests/defjam32.o tests/tpack22.o tests/tpack21.o tests/defja32p.o \ + tests/bytek13.o tests/dblatn.o tests/powerp30.o tests/powerp40.o \ + tests/powerp23.o tests/bytek20.o tests/spike.o tests/tpack102.o \ + tests/time17.o tests/mc30addr.o tests/jamcrack.o tests/bsifc.o \ + tests/digibst.o tests/mcrun10.o tests/mcrun12.o tests/qc.o \ + tests/tdd.o tests/fuchs.o tests/bytek30.o tests/syncro.o \ + tests/stc270.o tests/tnmc11.o tests/superc27.o tests/ppbk.o \ + tests/relokit.o tests/maxpac12.o tests/soundfx.o tests/arcd.o \ + tests/crnd.o tests/stk26.o tests/bytekp10.o tests/hqc2.o \ + tests/tryit101.o tests/fc13.o tests/fc14.o tests/crmaddr.o tests/mmd0.o \ + tests/powerp4l.o tests/newtron.o tests/gpmo.o tests/polka.o \ + tests/gnpl.o tests/ambk.o tests/xm.o tests/mcobj.o tests/turbosqueezer61.o \ + tests/stc299d.o tests/stc310.o tests/stc299b.o tests/stc299.o tests/stc300.o \ + tests/nfh.o \ + rips/ac1d.o rips/bp.o rips/di.o rips/eureka.o rips/fc_m.o \ + rips/fuzzac.o rips/hrt.o rips/kris.o rips/mp.o rips/pha.o \ + rips/pm.o rips/pm01.o rips/pm10c.o rips/pm20.o rips/pm18a.o \ + rips/pp21.o rips/pp30.o rips/prun1.o rips/prun2.o rips/ptk.o \ + rips/skyt.o rips/starpack.o rips/unic.o rips/unic2.o rips/wn.o \ + rips/xann.o rips/gmc.o rips/heatseek.o rips/ksm.o \ + rips/noiserun.o rips/npd1.o rips/npd2.o rips/npd3.o \ + rips/p40a.o rips/p40b.o rips/p41a.o rips/pm40.o rips/pp10.o \ + rips/tp1.o rips/tp2.o rips/tp3.o rips/zen.o rips/p50a.o \ + rips/p60a.o rips/startrek.o rips/p61a.o rips/stim.o \ + rips/soundtk.o rips/defjam32.o rips/tpack22.o rips/tpack21.o \ + rips/mcrun.o rips/bytekil.o rips/dblatn.o rips/powerp30.o \ + rips/powerp40.o rips/powerp23.o rips/spike.o rips/tpack102.o \ + rips/digibst.o rips/time17.o rips/mc30addr.o rips/jamcrack.o \ + rips/bsifc.o rips/qc.o rips/tdd.o rips/fuchs.o rips/bytek30.o \ + rips/syncro.o rips/stc270.o rips/tnmc11.o rips/superc27.o \ + rips/ppbk.o rips/relokit.o rips/maxpac12.o rips/soundfx.o \ + rips/stk26.o rips/bytekp10.o rips/hqc2.o rips/tryit101.o \ + rips/fc13.o rips/fc14.o rips/crmaddr.o rips/med.o rips/powerp4l.o \ + rips/newtron.o rips/gpmo.o rips/polka.o rips/gnpl.o rips/ambk.o \ + rips/xm.o rips/mcobj.o rips/turbosqueezer61.o rips/stc299d.o \ + rips/stc310.o rips/stc299b.o rips/stc299.o rips/stc300.o \ + rips/nfh.o \ + depack/ac1d.o depack/di.o depack/eureka.o depack/fc-m.o \ + depack/fuzzac.o depack/gmc.o depack/heatseek.o depack/hrt.o \ + depack/kris.o depack/ksm.o depack/mp.o depack/noiserun.o \ + depack/np1.o depack/np2.o depack/np3.o depack/p40.o depack/p41a.o \ + depack/p50a.o depack/p60a.o depack/p61a.o depack/pha.o \ + depack/pm01.o depack/pm10c.o depack/pm18a.o depack/pm20.o \ + depack/pm40.o depack/pm.o depack/pp10.o depack/pp21.o \ + depack/pp30.o depack/prun1.o depack/prun2.o depack/skyt.o \ + depack/starpack.o depack/tp1.o depack/tp2.o depack/tp3.o \ + depack/unic.o depack/unic2.o depack/wn.o depack/xann.o \ + depack/zen.o depack/stim.o depack/qc.o depack/tdd.o \ + depack/fuchs.o depack/soundfx.o depack/stk26.o depack/newtron.o \ + depack/gpmo.o depack/polka.o depack/gnpl.o depack/ambk.o \ + depack/nfh.o \ + misc/misc.o misc/testbag.o + +EXEFILE = prowiz.exe + +.c.o: + $(CC) -DUNIX $(CFLAGS) -c $< -o $@ + +prowiz: $(OFILES) + $(CC) -o $(EXEFILE) -L/usr/local/lib -ldmalloc $(OFILES) + +# +clean: clear + rm -f *.o + rm -f tests/*.o + rm -f rips/*.o + rm -f depack/*.o + rm -f misc/*.o + rm -f core *.core + +# +clear: + rm -f *~ *.*~ tests/*~ tests/*.*~ rips/*~ rips/*.*~ misc/*~ misc/*.*~ include/*~ include/*.*~ depack/*~ depack/*.*~ diff --git a/prowizard/misc/misc.c b/prowizard/misc/misc.c new file mode 100755 index 00000000..d05fc605 --- /dev/null +++ b/prowizard/misc/misc.c @@ -0,0 +1,411 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +/* + * at now, when this fonction is called, no global var has been used ... + * and can be here :). (save for the input file pointer ...) +*/ +void Support_Types ( void ) +{ + long types_file_size, cpt; + char read_line[_TYPES_LINE_LENGHT]; + FILE *types_file; + + /* fill with $00 ... "Extension" is global */ + memset ( Extensions, 0, sizeof Extensions ); + + types_file = fopen ( _TYPES_FILENAME , "rb" ); + if ( types_file == NULL ) + { + printf ( "!!! couldn't find \"%s\" file !. Default extension used.\n" + , _TYPES_FILENAME ); + Support_Types_FileDefault (); + return; + } + + /* get "_TYPES_" size */ + types_file_size = GetFileSize ( _TYPES_FILENAME ); + fseek ( types_file , 0 , 0 ); /* just to be sure. put the fp back at the beginning */ + + PW_i = 0; /* will inc up to _KNOWN_FORMATS */ + while ( ftell ( types_file )+1 < types_file_size ) + { + memset ( read_line, 0, _TYPES_LINE_LENGHT ); + fgets ( read_line , _TYPES_LINE_LENGHT , types_file ); + if ( read_line[0] == '#' ) + continue; + if ( sizeof ( read_line ) < 2 ) + { + printf ( "!!! Damaged \"%s\" file at non-commented line %ld\n" + , _TYPES_FILENAME , PW_i+1 ); + PW_i = 99999l; + break; + } + cpt = 0; + while ( read_line[cpt] != 0x00 && read_line[cpt] != 0x0a && read_line[cpt] != 0x0d ) + { + Extensions[PW_i][cpt] = read_line[cpt]; + cpt += 1; + } + /*printf ( "[%ld]%ld:%s," , PW_i,ftell (types_file),read_line );*/ + PW_i += 1; + if ( PW_i == _KNOWN_FORMATS ) + break; + } + + if ( PW_i != _KNOWN_FORMATS ) + { + printf ( "!!! Damaged \"%s\" file. Missing up %ld extensions definitions\n" + , _TYPES_FILENAME , _KNOWN_FORMATS-(PW_i+1)); + Support_Types_FileDefault (); + return; + } + + fclose ( types_file ); +} + +/*Uchar *XighExtensions[_KNOWN_FORMATS+1];*/ + +/* + * fill the global "Extension" with default extensions if a pb happened + * while reading "_TYPES_" editable extensions file +*/ +void Support_Types_FileDefault ( void ) +{ + /* xigh examples */ + /* strdup( Extensions[0], "AC1" ); + strdup( Extensions[12], "MegaBixExtension" );*/ + + /* note: "_TYPES_" file first entry is 1 ! */ + strcpy ( Extensions[0] , "ac1d" ); + strcpy ( Extensions[1] , "bp" ); + strcpy ( Extensions[2] , "fc-m" ); + strcpy ( Extensions[3] , "hrt" ); + strcpy ( Extensions[4] , "kris" ); + strcpy ( Extensions[5] , "PowerMusic" ); + strcpy ( Extensions[6] , "Promizer10c" ); + strcpy ( Extensions[7] , "Promizer18a" ); + strcpy ( Extensions[8] , "Promizer20" ); + strcpy ( Extensions[9] , "ProRunner1" ); + strcpy ( Extensions[10] , "ProRunner2" ); + strcpy ( Extensions[11] , "skyt" ); + strcpy ( Extensions[12] , "WantonPacker" ); + strcpy ( Extensions[13] , "xann" ); + strcpy ( Extensions[14] , "ModuleProtector" ); + strcpy ( Extensions[15] , "DigitalIllusion" ); + strcpy ( Extensions[16] , "PhaPacker" ); + strcpy ( Extensions[17] , "Promizer01" ); + strcpy ( Extensions[18] , "ProPacker21" ); + strcpy ( Extensions[19] , "ProPacker30" ); + strcpy ( Extensions[20] , "Eureka" ); + strcpy ( Extensions[21] , "StarTrekkerPack" ); + strcpy ( Extensions[22] , "mod" ); + strcpy ( Extensions[23] , "unic1" ); + strcpy ( Extensions[24] , "unic2" ); + strcpy ( Extensions[25] , "Fuzzac" ); + strcpy ( Extensions[26] , "gmc" ); + strcpy ( Extensions[27] , "crb" ); + strcpy ( Extensions[28] , "ksm" ); + strcpy ( Extensions[29] , "Noiserunner" ); + strcpy ( Extensions[30] , "NoisePacker1" ); + strcpy ( Extensions[31] , "NoisePacker2" ); + strcpy ( Extensions[32] , "NoisePacker3" ); + strcpy ( Extensions[33] , "P40A" ); + strcpy ( Extensions[34] , "P40B" ); + strcpy ( Extensions[35] , "P41A" ); + strcpy ( Extensions[36] , "Promizer4" ); + strcpy ( Extensions[37] , "ProPacker1" ); + strcpy ( Extensions[38] , "TrackerPacker1" ); + strcpy ( Extensions[39] , "TrackerPacker2" ); + strcpy ( Extensions[40] , "TrackerPacker3" ); + strcpy ( Extensions[41] , "ZenPacker" ); + strcpy ( Extensions[42] , "P50A" ); + strcpy ( Extensions[43] , "P60A" ); + strcpy ( Extensions[44] , "mod" ); + strcpy ( Extensions[45] , "StoneCrackerData" ); + strcpy ( Extensions[46] , "StoneCracker270 " ); + strcpy ( Extensions[47] , "P61A" ); + strcpy ( Extensions[48] , "stim" ); + strcpy ( Extensions[49] , "mod" ); + strcpy ( Extensions[50] , "TetraPack22" ); + strcpy ( Extensions[51] , "CrunchmaniaData" ); + strcpy ( Extensions[52] , "DefjamCruncher" ); + strcpy ( Extensions[53] , "Tetrapack21" ); + strcpy ( Extensions[54] , "ice" ); + strcpy ( Extensions[55] , "ByteKiller" ); + strcpy ( Extensions[56] , "xpk" ); + strcpy ( Extensions[57] , "Imploder" ); + strcpy ( Extensions[58] , "rnc" ); + strcpy ( Extensions[59] , "DoubleAction" ); + strcpy ( Extensions[60] , "PowerPacker3" ); + strcpy ( Extensions[61] , "PowerPacker4" ); + strcpy ( Extensions[62] , "PowerPacker23" ); + strcpy ( Extensions[63] , "SpikeCruncher" ); + strcpy ( Extensions[64] , "Tetrapack102" ); + strcpy ( Extensions[65] , "TimeCruncher17" ); + strcpy ( Extensions[66] , "MasterCruncher" ); + strcpy ( Extensions[67] , "MegaCruncher" ); + strcpy ( Extensions[68] , "jam" ); + strcpy ( Extensions[69] , "BSI-FC" ); + strcpy ( Extensions[70] , "digi" ); + strcpy ( Extensions[71] , "qc" ); + strcpy ( Extensions[72] , "TheDarkDemon" ); + strcpy ( Extensions[73] , "FuchsTracker" ); + strcpy ( Extensions[74] , "SynchroPacker46" ); + strcpy ( Extensions[75] , "TNMCruncher11" ); + strcpy ( Extensions[76] , "SuperCruncher27" ); + strcpy ( Extensions[77] , "PPbk" ); + strcpy ( Extensions[78] , "RelokIt1" ); + strcpy ( Extensions[79] , "StoneCracker292data" ); + strcpy ( Extensions[80] , "fire" ); + strcpy ( Extensions[81] , "MacPacker12" ); + strcpy ( Extensions[82] , "SoundFX13" ); + strcpy ( Extensions[83] , "arcD" ); + strcpy ( Extensions[84] , "para" ); + strcpy ( Extensions[85] , "crnd" ); + strcpy ( Extensions[86] , "-sb-" ); + strcpy ( Extensions[87] , "sf" ); + strcpy ( Extensions[88] , "RLE" ); + strcpy ( Extensions[89] , "VDC0" ); + strcpy ( Extensions[90] , "sq" ); + strcpy ( Extensions[91] , "sp" ); + strcpy ( Extensions[92] , "ST26" ); + strcpy ( Extensions[93] , "IT10" ); + strcpy ( Extensions[94] , "HQCCruncher2" ); + strcpy ( Extensions[95] , "TtyItCruncher101" ); + strcpy ( Extensions[96] , "FC13" ); + strcpy ( Extensions[97] , "FC14" ); + strcpy ( Extensions[98] , "1AM" ); + strcpy ( Extensions[99] , "2AM" ); + strcpy ( Extensions[100], "med" ); + strcpy ( Extensions[101], "AceCruncherData" ); + strcpy ( Extensions[102], "Newtron" ); + strcpy ( Extensions[103], "GPMO" ); + strcpy ( Extensions[104], "PolkaPacker" ); + strcpy ( Extensions[105], "GnuPlayer" ); + strcpy ( Extensions[106], "CJ_DataCruncher" ); + strcpy ( Extensions[107], "AmBk" ); + strcpy ( Extensions[108], "MasterCruncher3data" ); + strcpy ( Extensions[109], "xm" ); + strcpy ( Extensions[110], "MegaCruncherObj" ); + strcpy ( Extensions[111], "TurboSqueezer61" ); + strcpy ( Extensions[112], "StoneCracker299d" ); + strcpy ( Extensions[113], "StoneCracker310" ); + strcpy ( Extensions[114], "StoneCracker299b" ); + strcpy ( Extensions[115], "StoneCracker299" ); + strcpy ( Extensions[116], "StoneCracker300" ); + strcpy ( Extensions[117], "ThePlayer30a" ); + strcpy ( Extensions[118], "ThePlayer22a" ); + strcpy ( Extensions[119], "NoiseFromHeaven" ); + strcpy ( Extensions[120], "---" ); +} + + + + +/* + * saving what's found. Mainly music file here. + * PW_Start_Address & OutputSize are global .. not everybody likes + * that :(. I just cant seem to manage it otherwise. +*/ +void Save_Rip ( char * format_to_save, int FMT_EXT ) +{ + Save_Status = BAD; + printf ( "%s found at %ld !. its size is : %ld\n", format_to_save , PW_Start_Address , OutputSize ); + if ( (PW_Start_Address + (long)OutputSize) > PW_in_size ) + { + printf ( "!!! Truncated, missing (%ld byte(s) !)\n" + , (PW_Start_Address+OutputSize)-PW_in_size ); + PW_i += 2 ; + return; + } + BZERO ( OutName_final, sizeof OutName_final); + sprintf ( OutName_final , "%ld.%s" , Cpt_Filename , Extensions[FMT_EXT] ); + printf ( " saving in file \"%s\" ... " , OutName_final ); + Cpt_Filename += 1; + PW_out = mr2_fopen ( OutName_final , "w+b", format_to_save); + if (!PW_out) + return; + fwrite ( &in_data[PW_Start_Address] , OutputSize , 1 , PW_out ); + fclose ( PW_out ); + printf ( "done\n" ); + if ( CONVERT == GOOD ) + { + printf ( " converting to Protracker ... " ); + } + fflush ( stdout ); + Save_Status = GOOD; +} + +/* + * Special cases for files with header to rebuild ... + * +*/ +void Save_Rip_Special ( char * format_to_save, int FMT_EXT, Uchar * Header_Block , Ulong Block_Size ) +{ + Save_Status = BAD; + printf ( "%s found at %ld !. its size is : %ld\n", format_to_save , PW_Start_Address , OutputSize ); + if ( (PW_Start_Address + (long)OutputSize) > PW_in_size ) + { + printf ( "!!! Truncated, missing (%ld byte(s) !)\n" + , (PW_Start_Address+OutputSize)-PW_in_size ); + PW_i += 2 ; + return; + } + BZERO (OutName_final, sizeof OutName_final); + sprintf ( OutName_final , "%ld.%s" , Cpt_Filename , Extensions[FMT_EXT] ); + printf ( " saving in file \"%s\" ... " , OutName_final ); + Cpt_Filename += 1; + PW_out = mr2_fopen ( OutName_final , "w+b", format_to_save ); + if (!PW_out) + return; + fwrite ( Header_Block , Block_Size , 1 , PW_out ); + fwrite ( &in_data[PW_Start_Address] , OutputSize , 1 , PW_out ); + fclose ( PW_out ); + printf ( "done\n" ); + if ( CONVERT == GOOD ) + { + printf ( " converting to Protracker ... " ); + } + printf ( " Header of this file was missing and has been rebuilt !\n" ); + fflush ( stdout ); + Amiga_EXE_Header = GOOD; + Save_Status = GOOD; +} + + + +/* writing craps in converted MODs */ +void Crap ( char *Format , Uchar Delta , Uchar Pack , FILE *out ) +{ + fseek ( out , 560 , SEEK_SET ); + fprintf ( out , "[ Converted with ]" ); + fseek ( out , 590 , SEEK_SET ); + fprintf ( out , "[ ProWizard for PC ]" ); + fseek ( out , 620 , SEEK_SET ); + fprintf ( out , "[ written by Asle! ]" ); + + fseek ( out , 680 , SEEK_SET ); + fprintf ( out , "[ Original Format: ]" ); + fseek ( out , 710 , SEEK_SET ); + fprintf ( out , "[%s]" , Format ); + + if ( Delta == GOOD ) + { + fseek ( out , 770 , SEEK_SET ); + fprintf ( out , "[! smp were DELTA ]" ); + } + if ( Pack == GOOD ) + { + fseek ( out , 800 , SEEK_SET ); + fprintf ( out , "[! smp were PACKED ]" ); + } +} + + +/* + * Special version of Test() for cruncher data (Ice! etc...) + * only one file and not hundreds ... +*/ +short testSpecialCruncherData ( long Pack_addy , long Unpack_addy ) +{ + PW_Start_Address = PW_i; + + /* a small test preventing hangover :) ... */ + /* e.g. addressing of unassigned data */ + if ( ( (long)PW_i + Pack_addy ) > PW_in_size ) + { +/*printf ( "#0\n" );*/ + return BAD; + } + + /* packed size */ + /* first byte is sometime used ... "SQ is an ex" */ + PW_l = ( (in_data[PW_Start_Address+Pack_addy+1]*256*256) + + (in_data[PW_Start_Address+Pack_addy+2]*256) + + in_data[PW_Start_Address+Pack_addy+3] ); + /* unpacked size */ + PW_k = ( (in_data[PW_Start_Address+Unpack_addy]*256*256*256) + + (in_data[PW_Start_Address+Unpack_addy+1]*256*256) + + (in_data[PW_Start_Address+Unpack_addy+2]*256) + + in_data[PW_Start_Address+Unpack_addy+3] ); + + if ( (PW_k <= 2) || (PW_l <= 2) ) + { +/*printf ( "#1\n" );*/ + return BAD; + } + + if ( PW_l > 0x989680 ) /* 10 mb */ + { +/*printf ( "#2\n" );*/ + return BAD; + } + + if ( PW_k <= PW_l ) + { +/*printf ( "#3\n" );*/ + return BAD; + } + + if ( PW_k > 0x989689 ) /* 10 Megs ! */ + { +/*printf ( "#4\n" );*/ + return BAD; + } + + return GOOD; +} + +/* + * Special version of Rip() for cruncher data (Ice! etc...) + * only one file and not hundreds ... +*/ +void Rip_SpecialCruncherData ( char *Packer_Name , int Header_Size , int Packer_Extension_Define ) +{ + /* PW_l IS the whole size -Header_Size */ + /* various Data crunchers need a little calculation beside the "+" or "-" */ + switch (Header_Size) + { + case 999991: /* SQ data cruncher */ + PW_l *= 4; + PW_l += 10; + OutputSize = PW_l; + break; + default: + OutputSize = PW_l + Header_Size; + } + + /* printf ( "\b\b\b\b\b\b\b\b%s file found at %ld !. its size is : %ld\n" , Packer_Name , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Packer_Extension_Define][0]; + OutName[2] = Extensions[Packer_Extension_Define][1]; + OutName[3] = Extensions[Packer_Extension_Define][2];*/ + + CONVERT = BAD; + Save_Rip ( Packer_Name, Packer_Extension_Define ); + + if ( Save_Status == GOOD ) +// PW_i += (OutputSize - 2); /* 0 should do but call it "just to be sure" :) */ + PW_i += (Header_Size + 1); /* test to overcome fake datas */ + PW_WholeSampleSize = 0; + +} + +/* yet again on Xigh's suggestion. How to handle 'correctly' a file size */ +long GetFileSize (char *infile) +{ + long i; + struct stat *Stat; + Stat = (struct stat *) malloc ( sizeof (struct stat)); + stat ( infile, Stat ); + i = (long)Stat->st_size; + free ( Stat ); + return i; +} diff --git a/prowizard/misc/testbag.c b/prowizard/misc/testbag.c new file mode 100755 index 00000000..006366a6 --- /dev/null +++ b/prowizard/misc/testbag.c @@ -0,0 +1,37 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +/* + * group of tests funcs that are common to most of test\*.c files +*/ + +/* start : if mod can possibly fit from the beginning of the file */ +/* e.g. M.K. before 1080th byte */ +short test_1_start ( Ulong LIMIT ) +{ + return ( PW_i < LIMIT) ? BAD : GOOD; +} + +short test_smps ( long smpsiz, long lstart, long lsiz, Uchar vol, Uchar fine ) +{ + if ( lstart > smpsiz ) + return BAD; + if ( lsiz > (smpsiz + 2) ) + return BAD; + if ( (lstart + lsiz) > smpsiz+2 ) + return BAD; + if ( (lstart != 0) && ( lsiz <= 2 ) ) + return BAD; + if ( ((lstart != 0) || (lsiz > 2)) && (smpsiz = 0) ) + return BAD; + if ( (vol > 0x40) || (fine > 0x0f) ) + return BAD; + return GOOD; +} diff --git a/prowizard/prowiz.c b/prowizard/prowiz.c new file mode 100755 index 00000000..5c6a5b57 --- /dev/null +++ b/prowizard/prowiz.c @@ -0,0 +1,2124 @@ +/* + * Pro-Wizard_1.c + * + * 1997-2003 (c) Sylvain "Asle" Chipaux + * +*/ + +#ifdef DOS +#include "include\globals.h" +#include "include\extern.h" +#include "include\vars.h" +#endif + + +#ifdef UNIX +#include "include/globals.h" +#include "include/extern.h" +#include "include/vars.h" +#endif + +#ifdef DMALLOC +#include "dmalloc.h" +#endif + +int prowizard_search (Uchar *in_data_p, int PW_in_size_p) +{ + Support_Types (); + in_data = in_data_p; + PW_in_size = PW_in_size_p; + /********************************************************************/ + /************************** SEARCH ******************************/ + /********************************************************************/ + for ( (long)PW_i=0 ; (long)PW_i<(PW_in_size-MINIMAL_FILE_LENGHT) ; (long)PW_i+=1 ) + { + /* display where we are every 10 Kbytes */ + /* if ( (PW_i%10240) == 0 )*/ + /* {*/ + /* ... and rewrites on itself. */ + /* printf ( "\r%ld", PW_i );*/ + /* force printing on stdout (i.e. the screen) */ + /* fflush ( stdout );*/ + /* }*/ + + /*******************************************************************/ + /* ok, now the real job starts here. So, we look for ID or Volume */ + /* values. A simple switch case follows .. based on Hex values of, */ + /* as foretold, ID or volume (not all file have ID ... few in fact */ + /* do ..). */ + /*******************************************************************/ + + if ( in_data[PW_i] <= 0x40 ) + { + /* try to get rid of those 00 hanging all the time everywhere :( + */ + if ( in_data[PW_i] == 0x00 ) + { + for ( PW_j = 0 ; PW_j= 1) && (in_data[PW_i-1] == 0x03) ) + { + if ( testPHA() != BAD ) + { + Rip_PHA (); + Depack_PHA (); + break; + } + } + break; + + + default: /* do nothing ... save continuing :) */ + break; + + } /* end of switch */ + } + return 0; +} + +#if 0 +int main ( int ac , char **av ) +{ + +#ifdef DOS + printf ( "\n\n-<([ Pro-Wizard v1.50.b3 (DOS) ])>-\n\n" ); +#endif + +#ifdef UNIX +#ifdef AMIGA + printf ( "\n\n-<([ Pro-Wizard v1.50.b3 (Amiga) ])>-\n\n" ); +#else + printf ( "\n\n-<([ Pro-Wizard v1.50.b3 (Unix) ])>-\n\n" ); +#endif +#endif + + + if ( ac != 2 ) + { + printf ( "%s \n" , av[0] ); + printf ( "Check for the documentation for more info !\n" ); + exit ( 0 ); + } + + PW_in = fopen ( av[1] , "rb" ); + if ( PW_in == NULL ) + { + printf ( "cant find \"%s\" !\n" , av[1] ); + exit ( 0 ); + } + + /* take care of the editable extensions */ + /*printf ( "%x,%x,%x\n" , Extensions[70][0], Extensions[70][1], Extensions[70][2] );*/ + + /* get input file size */ + fseek ( PW_in , 0 , 2 ); /* SEEK_END */ + PW_in_size = ftell ( PW_in ); + fseek ( PW_in , 0 , 0 ); + printf ( "input file size : %ld\n" , PW_in_size ); + if ( PW_in_size < MINIMAL_FILE_LENGHT ) + { + printf ( "! input file size is too small ...\n" ); + fclose ( PW_in ); + exit ( 1 ); + } + + /* alloc mem */ + in_data = (Uchar *) malloc ( PW_in_size ); + if ( in_data == NULL ) + { + perror ( "Couldn't allocate memory" ); + exit ( 0 ); + } + fread ( in_data , PW_in_size , 1 , PW_in ); + fclose ( PW_in ); + + prowizard_search (in_data, PW_in_size); + + free ( in_data ); + printf ( "\n" ); + printf ( " 1997-2003 (c) Sylvain \"Asle\" Chipaux (asle@free.fr)\n\n"); + exit ( 0 ); +} +#endif \ No newline at end of file diff --git a/prowizard/rips/ac1d.c b/prowizard/rips/ac1d.c new file mode 100755 index 00000000..ed080425 --- /dev/null +++ b/prowizard/rips/ac1d.c @@ -0,0 +1,34 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +void Rip_AC1D ( void ) +{ + PW_WholeSampleSize = 0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+8+PW_j*8]*256)+in_data[PW_Start_Address+9+PW_j*8])*2); + PW_k = (in_data[PW_Start_Address+4]*256*256*256)+ + (in_data[PW_Start_Address+5]*256*256)+ + (in_data[PW_Start_Address+6]*256)+ + in_data[PW_Start_Address+7]; + + OutputSize = PW_WholeSampleSize + PW_k; + /* printf ( "\b\b\b\b\b\b\b\bAC1D Packed module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[AC1D_packer][0]; + OutName[2] = Extensions[AC1D_packer][1]; + OutName[3] = Extensions[AC1D_packer][2];*/ + + CONVERT = GOOD; + Save_Rip ( "AC1D Packed module", AC1D_packer ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 4); /* 3 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/ambk.c b/prowizard/rips/ambk.c new file mode 100755 index 00000000..f6931123 --- /dev/null +++ b/prowizard/rips/ambk.c @@ -0,0 +1,24 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +void Rip_AmBk ( void ) +{ + /* PW_k is already the whole file size */ + + OutputSize = PW_k; + + CONVERT = GOOD; + Save_Rip ( "AMOS Bank (AmBk)", AmBk ); + + if ( Save_Status == GOOD ) + PW_i += 4; +} + diff --git a/prowizard/rips/bp.c b/prowizard/rips/bp.c new file mode 100755 index 00000000..ad5b7d3a --- /dev/null +++ b/prowizard/rips/bp.c @@ -0,0 +1,25 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_BP ( void ) +{ + OutputSize += ((PW_j*48) + (PW_l*16) + 512); + /* printf ( "\b\b\b\b\b\b\b\bSound Monitor v2 / v3 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[SoundMonitor][0]; + OutName[2] = Extensions[SoundMonitor][1]; + OutName[3] = Extensions[SoundMonitor][2];*/ + + CONVERT = BAD; + Save_Rip ( "Sound Monitor v2 / v3 module", SoundMonitor ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 27); /* 26 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/bsifc.c b/prowizard/rips/bsifc.c new file mode 100755 index 00000000..95022e7c --- /dev/null +++ b/prowizard/rips/bsifc.c @@ -0,0 +1,36 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_BSIFutureComposer ( void ) +{ + /* get whole sample size */ + PW_WholeSampleSize = 0; + for ( PW_j=0 ; PW_j<63 ; PW_j++ ) + { + PW_o =((in_data[PW_Start_Address+17420+(PW_j*16)]*256*256*256)+ + (in_data[PW_Start_Address+17421+(PW_j*16)]*256*256)+ + (in_data[PW_Start_Address+17422+(PW_j*16)]*256)+ + in_data[PW_Start_Address+17423+(PW_j*16)] ); + PW_WholeSampleSize += PW_o; + } + + OutputSize = PW_WholeSampleSize + 18428; + + /* printf ( "\b\b\b\b\b\b\b\bBSI Future Composer module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[BSIFC][0]; + OutName[2] = Extensions[BSIFC][1]; + OutName[3] = Extensions[BSIFC][2];*/ + + CONVERT = BAD; + Save_Rip ( "BSI Future Composer module", BSIFC ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* 0 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/bytek30.c b/prowizard/rips/bytek30.c new file mode 100755 index 00000000..98d591c4 --- /dev/null +++ b/prowizard/rips/bytek30.c @@ -0,0 +1,59 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_ByteKiller30 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bByteKiller 3.0 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[ByteKiller][0]; + OutName[2] = Extensions[ByteKiller][1]; + OutName[3] = Extensions[ByteKiller][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + Save_Rip_Special ( "ByteKiller 3.0 Exe-file", ByteKiller, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 32; + Save_Rip ( "ByteKiller 3.0 Exe-file", ByteKiller ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 36); /* 32 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/bytekil.c b/prowizard/rips/bytekil.c new file mode 100755 index 00000000..35ff87d6 --- /dev/null +++ b/prowizard/rips/bytekil.c @@ -0,0 +1,93 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_ByteKiller ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bByteKiller 1.3/2.0 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[ByteKiller][0]; + OutName[2] = Extensions[ByteKiller][1]; + OutName[3] = Extensions[ByteKiller][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 36; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 36 ); + BZERO ( Amiga_EXE_Header_Block , 36 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[30] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x02; + Amiga_EXE_Header_Block[19] = 0x01; + Amiga_EXE_Header_Block[27] = 0x01; + Amiga_EXE_Header_Block[31] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 60; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[32] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[33] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[34] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[35] = *Whatever; + + /* also the last 24 bytes are 'removed' frequently ... Here they are */ + in_data[PW_Start_Address+OutputSize-24] = 0x00; + in_data[PW_Start_Address+OutputSize-23] = 0x00; + in_data[PW_Start_Address+OutputSize-22] = 0x03; + in_data[PW_Start_Address+OutputSize-21] = 0xEC; + + in_data[PW_Start_Address+OutputSize-20] = 0x00; + in_data[PW_Start_Address+OutputSize-19] = 0x00; + in_data[PW_Start_Address+OutputSize-18] = 0x00; + in_data[PW_Start_Address+OutputSize-17] = 0x00; + + in_data[PW_Start_Address+OutputSize-16] = 0x00; + in_data[PW_Start_Address+OutputSize-15] = 0x00; + in_data[PW_Start_Address+OutputSize-14] = 0x03; + in_data[PW_Start_Address+OutputSize-13] = 0xF2; + + in_data[PW_Start_Address+OutputSize-12] = 0x00; + in_data[PW_Start_Address+OutputSize-11] = 0x00; + in_data[PW_Start_Address+OutputSize-10] = 0x03; + in_data[PW_Start_Address+OutputSize-9] = 0xEB; + + in_data[PW_Start_Address+OutputSize-8] = 0x00; + in_data[PW_Start_Address+OutputSize-7] = 0x00; + in_data[PW_Start_Address+OutputSize-6] = 0x00; + in_data[PW_Start_Address+OutputSize-5] = 0x01; + + in_data[PW_Start_Address+OutputSize-4] = 0x00; + in_data[PW_Start_Address+OutputSize-3] = 0x00; + in_data[PW_Start_Address+OutputSize-2] = 0x03; + in_data[PW_Start_Address+OutputSize-1] = 0xF2; + + Save_Rip_Special ( "ByteKiller 1.3/2.0 Exe-file", ByteKiller, Amiga_EXE_Header_Block , 36 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 36; + Save_Rip ( "ByteKiller 1.3/2.0 Exe-file", ByteKiller ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 173); /* 171 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/bytekp10.c b/prowizard/rips/bytekp10.c new file mode 100755 index 00000000..9053297b --- /dev/null +++ b/prowizard/rips/bytekp10.c @@ -0,0 +1,93 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_bytekillerpro10 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bByteKillerPro 1.0 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[ByteKiller][0]; + OutName[2] = Extensions[ByteKiller][1]; + OutName[3] = Extensions[ByteKiller][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 50; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 36 ); + BZERO ( Amiga_EXE_Header_Block , 36 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[30] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x02; + Amiga_EXE_Header_Block[19] = 0x01; + Amiga_EXE_Header_Block[27] = 0x01; + Amiga_EXE_Header_Block[31] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 60; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[32] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[33] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[34] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[35] = *Whatever; + + /* also the last 24 bytes are 'removed' frequently ... Here they are */ + in_data[PW_Start_Address+OutputSize-24] = 0x00; + in_data[PW_Start_Address+OutputSize-23] = 0x00; + in_data[PW_Start_Address+OutputSize-22] = 0x03; + in_data[PW_Start_Address+OutputSize-21] = 0xEC; + + in_data[PW_Start_Address+OutputSize-20] = 0x00; + in_data[PW_Start_Address+OutputSize-19] = 0x00; + in_data[PW_Start_Address+OutputSize-18] = 0x00; + in_data[PW_Start_Address+OutputSize-17] = 0x00; + + in_data[PW_Start_Address+OutputSize-16] = 0x00; + in_data[PW_Start_Address+OutputSize-15] = 0x00; + in_data[PW_Start_Address+OutputSize-14] = 0x03; + in_data[PW_Start_Address+OutputSize-13] = 0xF2; + + in_data[PW_Start_Address+OutputSize-12] = 0x00; + in_data[PW_Start_Address+OutputSize-11] = 0x00; + in_data[PW_Start_Address+OutputSize-10] = 0x03; + in_data[PW_Start_Address+OutputSize-9] = 0xEB; + + in_data[PW_Start_Address+OutputSize-8] = 0x00; + in_data[PW_Start_Address+OutputSize-7] = 0x00; + in_data[PW_Start_Address+OutputSize-6] = 0x00; + in_data[PW_Start_Address+OutputSize-5] = 0x01; + + in_data[PW_Start_Address+OutputSize-4] = 0x00; + in_data[PW_Start_Address+OutputSize-3] = 0x00; + in_data[PW_Start_Address+OutputSize-2] = 0x03; + in_data[PW_Start_Address+OutputSize-1] = 0xF2; + + Save_Rip_Special ( "ByteKillerPro 1.0 Exe-file", ByteKiller, Amiga_EXE_Header_Block , 50 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 50; + Save_Rip ( "ByteKillerPro 1.0 Exe-file", ByteKiller ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 54); /* 51 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/crmaddr.c b/prowizard/rips/crmaddr.c new file mode 100755 index 00000000..c18e4836 --- /dev/null +++ b/prowizard/rips/crmaddr.c @@ -0,0 +1,59 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_CrunchmaniaAddr ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bCrunchmania Address Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[CRM1][0]; + OutName[2] = Extensions[CRM1][1]; + OutName[3] = Extensions[CRM1][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + PW_Start_Address += 4; + Save_Rip_Special ( "Crunchmania Address Exe-file", CRM1, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 28; + Save_Rip ( "Crunchmania Address Exe-file", CRM1 ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 16); +} diff --git a/prowizard/rips/dblatn.c b/prowizard/rips/dblatn.c new file mode 100755 index 00000000..f45ddf77 --- /dev/null +++ b/prowizard/rips/dblatn.c @@ -0,0 +1,50 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_DoubleAction10 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bDouble Action 1.0 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Double_Action][0]; + OutName[2] = Extensions[Double_Action][1]; + OutName[3] = Extensions[Double_Action][2];*/ + + CONVERT = BAD; + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 24; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 24 ); + BZERO ( Amiga_EXE_Header_Block , 24 ); + Amiga_EXE_Header_Block[2] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[20] = in_data[PW_Start_Address+4]; + Amiga_EXE_Header_Block[21] = in_data[PW_Start_Address+5]; + Amiga_EXE_Header_Block[22] = in_data[PW_Start_Address+6]; + Amiga_EXE_Header_Block[23] = in_data[PW_Start_Address+7]; + + Save_Rip_Special ( "Double Action 1.0 Exe-file", Double_Action, Amiga_EXE_Header_Block , 24 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 24; + Save_Rip ( "Double Action 1.0 Exe-file", Double_Action ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 149); /* 147 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/defjam32.c b/prowizard/rips/defjam32.c new file mode 100755 index 00000000..a7c225e1 --- /dev/null +++ b/prowizard/rips/defjam32.c @@ -0,0 +1,65 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_Defjam32 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bDefjam Cruncher 3.2 / pro Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Defjam_32][0]; + OutName[2] = Extensions[Defjam_32][1]; + OutName[3] = Extensions[Defjam_32][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + + /* also the last 4 bytes are 'removed' frequently ... Here they are */ + in_data[PW_Start_Address+OutputSize-4] = 0x00; + in_data[PW_Start_Address+OutputSize-3] = 0x00; + in_data[PW_Start_Address+OutputSize-2] = 0x03; + in_data[PW_Start_Address+OutputSize-1] = 0xF2; + + Save_Rip_Special ( "Defjam Cruncher 3.2 / pro Exe-file", Defjam_32, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 32; + Save_Rip ( "Defjam Cruncher 3.2 / pro Exe-file", Defjam_32 ); + } + + if ( Save_Status == GOOD ) + PW_i += 36; +} diff --git a/prowizard/rips/di.c b/prowizard/rips/di.c new file mode 100755 index 00000000..73fdac93 --- /dev/null +++ b/prowizard/rips/di.c @@ -0,0 +1,27 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_DI ( void ) +{ + /*PW_WholeSampleSize is already the whole sample size */ + + PW_j = (in_data[PW_Start_Address+10]*256*256*256) + +(in_data[PW_Start_Address+11]*256*256) + +(in_data[PW_Start_Address+12]*256) + +in_data[PW_Start_Address+13]; + + OutputSize = PW_WholeSampleSize + PW_j; + + CONVERT = GOOD; + Save_Rip ( "Digital Illusion Packed music", Digital_illusion ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 15); /* 14 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/digibst.c b/prowizard/rips/digibst.c new file mode 100755 index 00000000..aabf4f16 --- /dev/null +++ b/prowizard/rips/digibst.c @@ -0,0 +1,29 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_DigiBooster17 ( void ) +{ + /* PW_m is the number of pattern saved -1 */ + /* PW_WholeSampleSize is the whole sample size :) */ + /* PW_k is the module size saves the samples data */ + + OutputSize = PW_WholeSampleSize + PW_k; + + /* printf ( "\b\b\b\b\b\b\b\bDigiBooster 1.7 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[DigiBooster][0]; + OutName[2] = Extensions[DigiBooster][1]; + OutName[3] = Extensions[DigiBooster][2];*/ + + CONVERT = BAD; + Save_Rip ( "DigiBooster 1.7 module", DigiBooster ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* 0 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/eureka.c b/prowizard/rips/eureka.c new file mode 100755 index 00000000..6db70670 --- /dev/null +++ b/prowizard/rips/eureka.c @@ -0,0 +1,31 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_EUREKA ( void ) +{ + /* PW_l is still the sample data address */ + + /*PW_WholeSampleSize is already the whole sample size */ + /*for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+42+PW_j*30]*256)+in_data[PW_Start_Address+43+PW_j*30])*2);*/ + + OutputSize = PW_WholeSampleSize + PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bEureka Packed module file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Eureka_packer][0]; + OutName[2] = Extensions[Eureka_packer][1]; + OutName[3] = Extensions[Eureka_packer][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Eureka Packed module", Eureka_packer ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 46); /* 45 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/fc13.c b/prowizard/rips/fc13.c new file mode 100755 index 00000000..0c388e3a --- /dev/null +++ b/prowizard/rips/fc13.c @@ -0,0 +1,29 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_FC13 ( void ) +{ + /* PW_m is the addy of the 1st sample */ + + /* whole sample size */ + PW_WholeSampleSize =((in_data[PW_Start_Address+36]*256*256*256)+ + (in_data[PW_Start_Address+37]*256*256)+ + (in_data[PW_Start_Address+38]*256)+ + in_data[PW_Start_Address+39] ); + + OutputSize = PW_WholeSampleSize + PW_m; + + CONVERT = BAD; + Save_Rip ( "Future Composer 1.3 module", FC13 ); + + if ( Save_Status == GOOD ) + PW_i += 4; /* after SMOD tag */ +} + diff --git a/prowizard/rips/fc14.c b/prowizard/rips/fc14.c new file mode 100755 index 00000000..04ca95ae --- /dev/null +++ b/prowizard/rips/fc14.c @@ -0,0 +1,30 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_FC14 ( void ) +{ + /* PW_l is already the 1st waveform addy */ + + /* get Waveforms len */ + PW_k = 0; + for ( PW_j=100 ; PW_j<180 ; PW_j++ ) + { + PW_k += in_data[PW_Start_Address+PW_j]; + } + + OutputSize = PW_l + (PW_k*2); + + CONVERT = BAD; + Save_Rip ( "Future Composer 1.4 module", FC14 ); + + if ( Save_Status == GOOD ) + PW_i += 4; /* after FC14 tag */ +} + diff --git a/prowizard/rips/fc_m.c b/prowizard/rips/fc_m.c new file mode 100755 index 00000000..c820c0de --- /dev/null +++ b/prowizard/rips/fc_m.c @@ -0,0 +1,37 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_FC_M ( void ) +{ + /* OutName[1] = Extensions[FC_M_packer][0]; + OutName[2] = Extensions[FC_M_packer][1]; + OutName[3] = Extensions[FC_M_packer][2];*/ + + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+34+PW_k*8]*256)+in_data[PW_Start_Address+35+PW_k*8])*2); + PW_j = in_data[PW_Start_Address+286]; + PW_l = 0; + for ( PW_k=0 ; PW_k PW_l ) + PW_l = in_data[PW_Start_Address+292+PW_k]; + } + PW_l += 1; + OutputSize = (PW_l*1024) + PW_WholeSampleSize + 292 + PW_j + 8; + /* printf ( "\b\b\b\b\b\b\b\bFC-M packed module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + + CONVERT = GOOD; + Save_Rip ( "FC-M packed module", FC_M_packer ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 1); /* 0 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/fuchs.c b/prowizard/rips/fuchs.c new file mode 100755 index 00000000..46271352 --- /dev/null +++ b/prowizard/rips/fuchs.c @@ -0,0 +1,32 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_FuchsTracker ( void ) +{ + /* PW_m is the size of all samples (in descriptions) */ + /* PW_k is the pattern data size */ + + /* 204 = 200 (header) + 4 ("INST" id) */ +/*printf ( "sample size : %ld\n" , PW_m );*/ +/*printf ( "patt data size : %ld\n" , PW_k );*/ + OutputSize = PW_m + PW_k + 204; + + /* printf ( "\b\b\b\b\b\b\b\bFuchs Tracker module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[FuchsTracker][0]; + OutName[2] = Extensions[FuchsTracker][1]; + OutName[3] = Extensions[FuchsTracker][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Fuchs Tracker module", FuchsTracker ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 195); /* 192 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/fuzzac.c b/prowizard/rips/fuzzac.c new file mode 100755 index 00000000..e8592a57 --- /dev/null +++ b/prowizard/rips/fuzzac.c @@ -0,0 +1,29 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_Fuzzac ( void ) +{ + /* PW_WholeSampleSize IS still the whole sample size */ + + PW_j = in_data[PW_Start_Address+2114]; + PW_k = in_data[PW_Start_Address+2115]; + OutputSize = PW_WholeSampleSize + (PW_j*16) + (PW_k*256) + 2118 + 4; + /* printf ( "\b\b\b\b\b\b\b\bFuzzac packer module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Fuzzac][0]; + OutName[2] = Extensions[Fuzzac][1]; + OutName[3] = Extensions[Fuzzac][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Fuzzac packer module", Fuzzac ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* -1 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/gmc.c b/prowizard/rips/gmc.c new file mode 100755 index 00000000..95acc1ba --- /dev/null +++ b/prowizard/rips/gmc.c @@ -0,0 +1,24 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_GMC ( void ) +{ + /* PW_l is still the number of pattern to play */ + /* PW_WholeSampleSize is already the whole sample size */ + + OutputSize = PW_WholeSampleSize + (PW_l*1024) + 444; + + CONVERT = GOOD; + Save_Rip ( "Game Music Creator module", GMC ); + + if ( Save_Status == GOOD ) + PW_i += 444; /* after header */ +} + diff --git a/prowizard/rips/gnpl.c b/prowizard/rips/gnpl.c new file mode 100755 index 00000000..44963530 --- /dev/null +++ b/prowizard/rips/gnpl.c @@ -0,0 +1,43 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +void Rip_GnuPlayer ( void ) +{ + /*PW_WholeSampleSize is the whole sample size */ + /*but it seems to be a fake sample values */ + + /* size of 1st track + header */ + PW_k = (in_data[PW_Start_Address + 0x96]*256)+in_data[PW_Start_Address + 0x97] + 0x96; + /* size of 2nd track */ + PW_j = (in_data[PW_k]*256) + in_data[PW_k+1] + PW_k; + /* PW_j points now to the first sample size */ + /*printf ( "\nWhere before 1st sample : %ld\n" , PW_j);*/ + + /* real sample sizes */ + PW_m = 0; + while ( PW_m < PW_o ) + { + PW_k = (in_data[PW_Start_Address+PW_j]*256) + in_data[PW_Start_Address+PW_j+1]; + PW_j += (PW_k + 2); + PW_m += 1; + /*printf ( "sample %ld : siz:%ld where:%ld\n", PW_m,PW_k,PW_j ); + fflush (stdout);*/ + } + + OutputSize = PW_j; + + CONVERT = GOOD; + Save_Rip ( "GnuPlayer module", GnuPlayer ); + + if ( Save_Status == GOOD ) + PW_i += 0x96; +} + diff --git a/prowizard/rips/gpmo.c b/prowizard/rips/gpmo.c new file mode 100755 index 00000000..b0ebdc5c --- /dev/null +++ b/prowizard/rips/gpmo.c @@ -0,0 +1,32 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_GPMO ( void ) +{ + /* PW_k is still the nbr of pattern */ + + PW_WholeSampleSize = 0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+42+PW_j*30]*256)+in_data[PW_Start_Address+43+PW_j*30])*2); + + OutputSize = PW_WholeSampleSize + (PW_k*1024) + 1084; + + /* printf ( "\b\b\b\b\b\b\b\bProtracker mocule found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Protracker][0]; + OutName[2] = Extensions[Protracker][1]; + OutName[3] = Extensions[Protracker][2];*/ + + CONVERT = BAD; + Save_Rip ( "GPMO (Crunch Player) module", GPMO ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 1081); /* 1080 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/heatseek.c b/prowizard/rips/heatseek.c new file mode 100755 index 00000000..466e98de --- /dev/null +++ b/prowizard/rips/heatseek.c @@ -0,0 +1,26 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_HEATSEEKER ( void ) +{ + /* OutName[1] = Extensions[Heatseeker][0]; + OutName[2] = Extensions[Heatseeker][1]; + OutName[3] = Extensions[Heatseeker][2];*/ + + OutputSize = PW_k + PW_WholeSampleSize + 378; + /* printf ( "\b\b\b\b\b\b\b\bHeatseeker module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + + CONVERT = GOOD; + Save_Rip ( "Heatseeker module", Heatseeker ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 4); /* 3 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/hqc2.c b/prowizard/rips/hqc2.c new file mode 100755 index 00000000..6abe11e7 --- /dev/null +++ b/prowizard/rips/hqc2.c @@ -0,0 +1,97 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_HQCCruncher2 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bHQC Cruncher 2.0 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[HQC][0]; + OutName[2] = Extensions[HQC][1]; + OutName[3] = Extensions[HQC][2];*/ + + CONVERT = BAD; + + /*---------------------------------------------------*/ + /* not used yet coz I still dont know hoz to rebuild */ + /* 3 chunks EXE cases ... */ + /* so, the code below IS useless AND wrong !!!!! */ + /*---------------------------------------------------*/ + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 50; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 36 ); + BZERO ( Amiga_EXE_Header_Block , 36 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[30] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x02; + Amiga_EXE_Header_Block[19] = 0x01; + Amiga_EXE_Header_Block[27] = 0x01; + Amiga_EXE_Header_Block[31] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 60; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[32] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[33] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[34] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[35] = *Whatever; + + /* also the last 24 bytes are 'removed' frequently ... Here they are */ + in_data[PW_Start_Address+OutputSize-24] = 0x00; + in_data[PW_Start_Address+OutputSize-23] = 0x00; + in_data[PW_Start_Address+OutputSize-22] = 0x03; + in_data[PW_Start_Address+OutputSize-21] = 0xEC; + + in_data[PW_Start_Address+OutputSize-20] = 0x00; + in_data[PW_Start_Address+OutputSize-19] = 0x00; + in_data[PW_Start_Address+OutputSize-18] = 0x00; + in_data[PW_Start_Address+OutputSize-17] = 0x00; + + in_data[PW_Start_Address+OutputSize-16] = 0x00; + in_data[PW_Start_Address+OutputSize-15] = 0x00; + in_data[PW_Start_Address+OutputSize-14] = 0x03; + in_data[PW_Start_Address+OutputSize-13] = 0xF2; + + in_data[PW_Start_Address+OutputSize-12] = 0x00; + in_data[PW_Start_Address+OutputSize-11] = 0x00; + in_data[PW_Start_Address+OutputSize-10] = 0x03; + in_data[PW_Start_Address+OutputSize-9] = 0xEB; + + in_data[PW_Start_Address+OutputSize-8] = 0x00; + in_data[PW_Start_Address+OutputSize-7] = 0x00; + in_data[PW_Start_Address+OutputSize-6] = 0x00; + in_data[PW_Start_Address+OutputSize-5] = 0x01; + + in_data[PW_Start_Address+OutputSize-4] = 0x00; + in_data[PW_Start_Address+OutputSize-3] = 0x00; + in_data[PW_Start_Address+OutputSize-2] = 0x03; + in_data[PW_Start_Address+OutputSize-1] = 0xF2; + + Save_Rip_Special ( "HQC Cruncher 2.0 Exe-file", HQC, Amiga_EXE_Header_Block , 50 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + Save_Rip ( "HQC Cruncher 2.0 Exe-file", HQC ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 65); /* 64 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/hrt.c b/prowizard/rips/hrt.c new file mode 100755 index 00000000..51bdbc55 --- /dev/null +++ b/prowizard/rips/hrt.c @@ -0,0 +1,38 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_HRT ( void ) +{ + /* OutName[1] = Extensions[Hornet_packer][0]; + OutName[2] = Extensions[Hornet_packer][1]; + OutName[3] = Extensions[Hornet_packer][2];*/ + + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+42+PW_k*30]*256)+in_data[PW_Start_Address+43+PW_k*30])*2); + PW_j = in_data[PW_Start_Address+950]; + PW_l=0; + for ( PW_k=0 ; PW_k<128 ; PW_k++ ) + { + if ( in_data[PW_Start_Address+952+PW_k] > PW_l ) + PW_l = in_data[PW_Start_Address+952+PW_k]; + } + PW_l += 1; + PW_k = 1084 + PW_l * 1024; + OutputSize = PW_k + PW_WholeSampleSize; + /* printf ( "\b\b\b\b\b\b\b\bHORNET packed module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + + CONVERT = GOOD; + Save_Rip ( "HORNET packed module", Hornet_packer ); + + if ( Save_Status == GOOD ) + PW_i += 1084; +} + diff --git a/prowizard/rips/jamcrack.c b/prowizard/rips/jamcrack.c new file mode 100755 index 00000000..8f2be135 --- /dev/null +++ b/prowizard/rips/jamcrack.c @@ -0,0 +1,54 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_JamCracker ( void ) +{ + /* PW_j is the number of sample */ + /* PW_WholeSampleSize is the whole sample size :) */ + /* PW_l is the number of pattern saved */ + /* PW_m is the size of the pattern list */ + + /* first, get rid of header size (til end of pattern list) */ + PW_n = 6 + (PW_j*40) + 2; + OutputSize = PW_n + (PW_l*6) + 2 + (PW_m*2); + + /* PW_n points now at the beginning of pattern descriptions */ + /* now, let's calculate pattern data size */ + /* first address : */ + PW_o =((in_data[PW_Start_Address+PW_n+2]*256*256*256)+ + (in_data[PW_Start_Address+PW_n+3]*256*256)+ + (in_data[PW_Start_Address+PW_n+4]*256)+ + in_data[PW_Start_Address+PW_n+5] ); + PW_n += (PW_l*6); + PW_k =((in_data[PW_Start_Address+PW_n-4]*256*256*256)+ + (in_data[PW_Start_Address+PW_n-3]*256*256)+ + (in_data[PW_Start_Address+PW_n-2]*256)+ + in_data[PW_Start_Address+PW_n-1] ); + PW_k -= PW_o; + /* PW_k shoulb be the track data size by now ... save the last pattern ! */ + /* let's get its number of lines */ + PW_o = in_data[PW_Start_Address+PW_n-5]; + PW_o *= 4; /* 4 voices */ + PW_o *= 8; /* 8 bytes per note */ + + OutputSize += PW_WholeSampleSize + PW_k + PW_o; + + /* printf ( "\b\b\b\b\b\b\b\bJamCracker / Pro module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[JamCracker][0]; + OutName[2] = Extensions[JamCracker][1]; + OutName[3] = Extensions[JamCracker][2];*/ + + CONVERT = BAD; + Save_Rip ( "JamCracker / Pro module", JamCracker ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* 0 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/kris.c b/prowizard/rips/kris.c new file mode 100755 index 00000000..8746aecc --- /dev/null +++ b/prowizard/rips/kris.c @@ -0,0 +1,41 @@ +/* + * Update: 20/12/2000 + * - debug .. correct size calculated now. +*/ + + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_KRIS ( void ) +{ + /* OutName[1] = Extensions[KRIS_tracker][0]; + OutName[2] = Extensions[KRIS_tracker][1]; + OutName[3] = Extensions[KRIS_tracker][2];*/ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+44+PW_k*30]*256)+in_data[PW_Start_Address+45+PW_k*30])*2); + PW_l = 0; + for ( PW_k=0 ; PW_k<512 ; PW_k++ ) + { + if ( (in_data[PW_Start_Address+958+PW_k*2]*256)+in_data[PW_Start_Address+959+PW_k*2] > PW_l ) + PW_l = (in_data[PW_Start_Address+958+PW_k*2]*256)+in_data[PW_Start_Address+959+PW_k*2]; + } + PW_k = 1984 + PW_l + 256; + OutputSize = PW_k + PW_WholeSampleSize; + /* printf ( "\b\b\b\b\b\b\b\bKRIS Tracker module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + + CONVERT = GOOD; + Save_Rip ( "KRIS Tracker module", KRIS_tracker ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 954); /* 953 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/ksm.c b/prowizard/rips/ksm.c new file mode 100755 index 00000000..b9586ac2 --- /dev/null +++ b/prowizard/rips/ksm.c @@ -0,0 +1,31 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_KSM ( void ) +{ + /* PW_j is the highest track number */ + + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<15 ; PW_k++ ) + PW_WholeSampleSize += ((in_data[PW_Start_Address+52+PW_k*32]*256)+in_data[PW_Start_Address+53+PW_k*32]); + + OutputSize = ((PW_j+1)*192) + PW_WholeSampleSize + 1536; + /* printf ( "\b\b\b\b\b\b\b\bKefrens Sound Machine module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[KSM][0]; + OutName[2] = Extensions[KSM][1]; + OutName[3] = Extensions[KSM][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Kefrens Sound Machine module", KSM ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* -1 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/maxpac12.c b/prowizard/rips/maxpac12.c new file mode 100755 index 00000000..b77d1879 --- /dev/null +++ b/prowizard/rips/maxpac12.c @@ -0,0 +1,59 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_MaxPacker12 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bMax Packer 1.2 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[MaxPacker][0]; + OutName[2] = Extensions[MaxPacker][1]; + OutName[3] = Extensions[MaxPacker][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + Save_Rip_Special ( "Max Packer 1.2 Exe-file", MaxPacker, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 32; + Save_Rip ( "Max Packer 1.2 Exe-file", MaxPacker ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 36); /* 32 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/mc30addr.c b/prowizard/rips/mc30addr.c new file mode 100755 index 00000000..8f77ce7e --- /dev/null +++ b/prowizard/rips/mc30addr.c @@ -0,0 +1,55 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_MasterCruncher30addr ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bMaster Cruncher 3.0 address Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[MasterCruncher][0]; + OutName[2] = Extensions[MasterCruncher][1]; + OutName[3] = Extensions[MasterCruncher][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 36; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 36 ); + BZERO ( Amiga_EXE_Header_Block , 36 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[30] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x02; + Amiga_EXE_Header_Block[19] = 0x01; + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[35] = 0x6A; + Amiga_EXE_Header_Block[31] = 0xE9; + + Amiga_EXE_Header_Block[24] = in_data[PW_Start_Address+428]; + Amiga_EXE_Header_Block[25] = in_data[PW_Start_Address+429]; + Amiga_EXE_Header_Block[26] = in_data[PW_Start_Address+430]; + Amiga_EXE_Header_Block[27] = in_data[PW_Start_Address+431]; + Save_Rip_Special ( "Master Cruncher 3.0 address Exe-file", MasterCruncher, Amiga_EXE_Header_Block , 36 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 36; + Save_Rip ( "Master Cruncher 3.0 address Exe-file", MasterCruncher ); + } + + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 38); /* 36 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/mcobj.c b/prowizard/rips/mcobj.c new file mode 100755 index 00000000..81fe96ac --- /dev/null +++ b/prowizard/rips/mcobj.c @@ -0,0 +1,77 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_MegaCruncherObj ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 36; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 36 ); + BZERO ( Amiga_EXE_Header_Block , 36 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[30] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x02; + Amiga_EXE_Header_Block[19] = 0x01; + Amiga_EXE_Header_Block[27] = 0x01; + Amiga_EXE_Header_Block[31] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 204; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[32] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[33] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[34] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[35] = *Whatever; + + /* also the last 16 bytes are 'removed' frequently ... Here they are */ + in_data[PW_Start_Address+OutputSize-16] = 0x00; + in_data[PW_Start_Address+OutputSize-15] = 0x00; + in_data[PW_Start_Address+OutputSize-14] = 0x03; + in_data[PW_Start_Address+OutputSize-13] = 0xF2; + + in_data[PW_Start_Address+OutputSize-12] = 0x00; + in_data[PW_Start_Address+OutputSize-11] = 0x00; + in_data[PW_Start_Address+OutputSize-10] = 0x03; + in_data[PW_Start_Address+OutputSize-9] = 0xEB; + + in_data[PW_Start_Address+OutputSize-8] = 0x00; + in_data[PW_Start_Address+OutputSize-7] = 0x00; + in_data[PW_Start_Address+OutputSize-6] = 0x00; + in_data[PW_Start_Address+OutputSize-5] = 0x01; + + in_data[PW_Start_Address+OutputSize-4] = 0x00; + in_data[PW_Start_Address+OutputSize-3] = 0x00; + in_data[PW_Start_Address+OutputSize-2] = 0x03; + in_data[PW_Start_Address+OutputSize-1] = 0xF2; + + Save_Rip_Special ( "Mega Cruncher Obj", MegaCruncherObj, Amiga_EXE_Header_Block , 36 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 36; + Save_Rip ( "Mega Cruncher Obj", MegaCruncherObj ); + } + + if ( Save_Status == GOOD ) + PW_i += 40; /* beside header */ +} diff --git a/prowizard/rips/mcrun.c b/prowizard/rips/mcrun.c new file mode 100755 index 00000000..5806b6a7 --- /dev/null +++ b/prowizard/rips/mcrun.c @@ -0,0 +1,61 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_MegaCruncher ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bMega Cruncher 1.0/1.2 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[MasterCruncher][0]; + OutName[2] = Extensions[MasterCruncher][1]; + OutName[3] = Extensions[MasterCruncher][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 36; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 36 ); + BZERO ( Amiga_EXE_Header_Block , 36 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[30] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x02; + Amiga_EXE_Header_Block[19] = 0x01; + Amiga_EXE_Header_Block[27] = 0x01; + Amiga_EXE_Header_Block[31] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 60; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[32] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[33] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[34] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[35] = *Whatever; + Save_Rip_Special ( "Mega Cruncher 1.0/1.2 Exe-file", MegaCruncher, Amiga_EXE_Header_Block , 36 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 36; + Save_Rip ( "Mega Cruncher 1.0/1.2 Exe-file", MegaCruncher ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 42); /* 36 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/med.c b/prowizard/rips/med.c new file mode 100755 index 00000000..d5ec72d7 --- /dev/null +++ b/prowizard/rips/med.c @@ -0,0 +1,33 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_MMD0 ( void ) +{ + /* PW_k is the module size */ + + OutputSize = PW_k; + /* if ( in_data[PW_i+3] == '0' ) + printf ( "\b\b\b\b\b\b\b\bMED (MMD0) module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize ); + if ( in_data[PW_i+3] == '1' ) + printf ( "\b\b\b\b\b\b\b\bOctaMED (MMD1) module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[MED][0]; + OutName[2] = Extensions[MED][1]; + OutName[3] = Extensions[MED][2];*/ + + CONVERT = BAD; + if ( in_data[PW_i+3] == '0' ) + Save_Rip ( "MED (MMD0) module", MED ); + if ( in_data[PW_i+3] == '1' ) + Save_Rip ( "OctaMED (MMD1) module", MED ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* 0 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/mp.c b/prowizard/rips/mp.c new file mode 100755 index 00000000..2b7b5e01 --- /dev/null +++ b/prowizard/rips/mp.c @@ -0,0 +1,79 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_MP_noID ( void ) +{ + /*PW_WholeSampleSize is the whole sample size*/ + + PW_j = in_data[PW_Start_Address+248]; + PW_l = 0; + for ( PW_k=0 ; PW_k PW_l ) + PW_l = in_data[PW_Start_Address+250+PW_k]; + + PW_k = (in_data[PW_Start_Address+378]*256*256*256)+ + (in_data[PW_Start_Address+379]*256*256)+ + (in_data[PW_Start_Address+380]*256)+ + in_data[PW_Start_Address+381]; + + PW_l += 1; + OutputSize = PW_WholeSampleSize + (PW_l*1024) + 378; + if ( PW_k == 0 ) + OutputSize += 4; + /* printf ( "\b\b\b\b\b\b\b\bModule Protector Packed music found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Module_protector][0]; + OutName[2] = Extensions[Module_protector][1]; + OutName[3] = Extensions[Module_protector][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Module Protector Packed music", Module_protector ); + + if ( Save_Status == GOOD ) + PW_i += 0x57E; + /*PW_i += (OutputSize - 5); -- 4 should do but call it "just to be sure" :) */ +} + + +void Rip_MP_withID ( void ) +{ + PW_WholeSampleSize = 0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+4+PW_j*8]*256)+in_data[PW_Start_Address+5+PW_j*8])*2); + PW_j = in_data[PW_Start_Address+252]; + PW_l = 0; + for ( PW_k=0 ; PW_k PW_l ) + PW_l = in_data[PW_Start_Address+254+PW_k]; + + PW_k = (in_data[PW_Start_Address+382]*256*256*256)+ + (in_data[PW_Start_Address+383]*256*256)+ + (in_data[PW_Start_Address+384]*256)+ + in_data[PW_Start_Address+385]; + + PW_l += 1; + OutputSize = PW_WholeSampleSize + (PW_l*1024) + 382; + + /* not sure for the following test because I've never found */ + /* any MP file with "TRK1" ID. I'm basing all this on Gryzor's */ + /* statement in his Hex-dump exemple ... */ + if ( PW_k == 0 ) + OutputSize += 4; + /* printf ( "\b\b\b\b\b\b\b\bModule Protector Packed music found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Module_protector][0]; + OutName[2] = Extensions[Module_protector][1]; + OutName[3] = Extensions[Module_protector][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Module Protector Packed music", Module_protector ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 5); /* 4 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/newtron.c b/prowizard/rips/newtron.c new file mode 100755 index 00000000..f666eb2b --- /dev/null +++ b/prowizard/rips/newtron.c @@ -0,0 +1,25 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_Newtron ( void ) +{ + /* PW_WholeSampleSize is the whole sample size :) */ + + PW_k = (in_data[PW_Start_Address+2]*256) + in_data[PW_Start_Address+3]; + + OutputSize = PW_k + PW_WholeSampleSize + 4; + + CONVERT = GOOD; + Save_Rip ( "Newtron module", Newtron ); + + if ( Save_Status == GOOD ) + PW_i += 7; +} + diff --git a/prowizard/rips/nfh.c b/prowizard/rips/nfh.c new file mode 100755 index 00000000..36eba9f1 --- /dev/null +++ b/prowizard/rips/nfh.c @@ -0,0 +1,34 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +/* noise from heaven chiptune mag by Iris'01 */ + +void Rip_NFH ( void ) +{ + /* PW_WholeSampleSize id still the whole sample size */ + + PW_l=0; + for ( PW_k=0 ; PW_k<128 ; PW_k++ ) + if ( in_data[PW_Start_Address+952+PW_k] > PW_l ) + PW_l = in_data[PW_Start_Address+952+PW_k]; + PW_l += 1; + OutputSize = (PW_l*1024) + 1084 + PW_WholeSampleSize; + /* printf ( "\b\b\b\b\b\b\b\bProrunner 1 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[ProRunner_v1][0]; + OutName[2] = Extensions[ProRunner_v1][1]; + OutName[3] = Extensions[ProRunner_v1][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Noise From Heaven module", NoiseFromHeaven ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 1083); /* 1080 could be enough */ +} + diff --git a/prowizard/rips/noiserun.c b/prowizard/rips/noiserun.c new file mode 100755 index 00000000..da214ff5 --- /dev/null +++ b/prowizard/rips/noiserun.c @@ -0,0 +1,28 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_Noiserunner ( void ) +{ + /* PW_k is still the nbr of pattern */ + + OutputSize = PW_WholeSampleSize + (PW_k*1024) + 1084; + + /* printf ( "\b\b\b\b\b\b\b\bNoiserunner music file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Noiserunner][0]; + OutName[2] = Extensions[Noiserunner][1]; + OutName[3] = Extensions[Noiserunner][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Noiserunner music", Noiserunner ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 1081); /* 1080 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/npd1.c b/prowizard/rips/npd1.c new file mode 100755 index 00000000..6e82cd1b --- /dev/null +++ b/prowizard/rips/npd1.c @@ -0,0 +1,26 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_Noisepacker1 ( void ) +{ + /* OutName[1] = Extensions[Noisepacker1][0]; + OutName[2] = Extensions[Noisepacker1][1]; + OutName[3] = Extensions[Noisepacker1][2];*/ + + OutputSize = PW_k + PW_WholeSampleSize + PW_l; + /* printf ( "\b\b\b\b\b\b\b\bNoisePacker v1 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + + CONVERT = GOOD; + Save_Rip ( "NoisePacker v1 module", Noisepacker1 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 16); /* 15 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/npd2.c b/prowizard/rips/npd2.c new file mode 100755 index 00000000..f4d2557d --- /dev/null +++ b/prowizard/rips/npd2.c @@ -0,0 +1,26 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_Noisepacker2 ( void ) +{ + /* OutName[1] = Extensions[Noisepacker2][0]; + OutName[2] = Extensions[Noisepacker2][1]; + OutName[3] = Extensions[Noisepacker2][2];*/ + + OutputSize = PW_k + PW_WholeSampleSize + PW_l; + /* printf ( "\b\b\b\b\b\b\b\bNoisePacker v2 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + + CONVERT = GOOD; + Save_Rip ( "NoisePacker v2 module", Noisepacker2 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 16); /* 15 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/npd3.c b/prowizard/rips/npd3.c new file mode 100755 index 00000000..89acb671 --- /dev/null +++ b/prowizard/rips/npd3.c @@ -0,0 +1,26 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_Noisepacker3 ( void ) +{ + /* OutName[1] = Extensions[Noisepacker3][0]; + OutName[2] = Extensions[Noisepacker3][1]; + OutName[3] = Extensions[Noisepacker3][2];*/ + + OutputSize = PW_k + PW_WholeSampleSize + PW_l; + /* printf ( "\b\b\b\b\b\b\b\bNoisePacker v3 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + + CONVERT = GOOD; + Save_Rip ( "NoisePacker v3 module", Noisepacker3 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 16); /* 15 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/p22a.c b/prowizard/rips/p22a.c new file mode 100755 index 00000000..b83e3654 --- /dev/null +++ b/prowizard/rips/p22a.c @@ -0,0 +1,45 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_P22A ( void ) +{ + /* PW_k is the number of sample */ + + PW_l = ( (in_data[PW_Start_Address+16]*256*256*256) + + (in_data[PW_Start_Address+17]*256*256) + + (in_data[PW_Start_Address+18]*256) + + in_data[PW_Start_Address+19] ); + + /* get whole sample size */ + /* starting from the highest addy and adding the sample size */ + PW_o = 0; + for ( PW_j=0 ; PW_j PW_o ) + { + PW_o = PW_m; + PW_n = ( (in_data[PW_Start_Address+24+PW_j*16]*256) + + in_data[PW_Start_Address+25+PW_j*16] ); + } + } + + OutputSize = PW_l + PW_o + (PW_n*2) + 4; + + CONVERT = GOOD; + Save_Rip ( "The Player 2.2A module", ThePlayer22a ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* 1 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/p30a.c b/prowizard/rips/p30a.c new file mode 100755 index 00000000..d38a4eae --- /dev/null +++ b/prowizard/rips/p30a.c @@ -0,0 +1,45 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_P30A ( void ) +{ + /* PW_k is the number of sample */ + + PW_l = ( (in_data[PW_Start_Address+16]*256*256*256) + + (in_data[PW_Start_Address+17]*256*256) + + (in_data[PW_Start_Address+18]*256) + + in_data[PW_Start_Address+19] ); + + /* get whole sample size */ + /* starting from the highest addy and adding the sample size */ + PW_o = 0; + for ( PW_j=0 ; PW_j PW_o ) + { + PW_o = PW_m; + PW_n = ( (in_data[PW_Start_Address+24+PW_j*16]*256) + + in_data[PW_Start_Address+25+PW_j*16] ); + } + } + + OutputSize = PW_l + PW_o + (PW_n*2) + 4; + + CONVERT = GOOD; + Save_Rip ( "The Player 3.0A module", ThePlayer30a ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* 1 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/p40a.c b/prowizard/rips/p40a.c new file mode 100755 index 00000000..eb5812a9 --- /dev/null +++ b/prowizard/rips/p40a.c @@ -0,0 +1,50 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_P40A ( void ) +{ + /* PW_k is the number of sample */ + + /* OutName[1] = Extensions[P40A][0]; + OutName[2] = Extensions[P40A][1]; + OutName[3] = Extensions[P40A][2];*/ + + PW_l = ( (in_data[PW_Start_Address+16]*256*256*256) + + (in_data[PW_Start_Address+17]*256*256) + + (in_data[PW_Start_Address+18]*256) + + in_data[PW_Start_Address+19] ); + + /* get whole sample size */ + PW_o = 0; + for ( PW_j=0 ; PW_j PW_o ) + { + PW_o = PW_m; + PW_n = ( (in_data[PW_Start_Address+24+PW_j*16]*256) + + in_data[PW_Start_Address+25+PW_j*16] ); + } + } + + OutputSize = PW_l + PW_o + (PW_n*2) + 4; + + /* printf ( "\b\b\b\b\b\b\b\bThe Player 4.0A module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + + CONVERT = GOOD; + Save_Rip ( "The Player 4.0A module", P40A ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* 1 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/p40b.c b/prowizard/rips/p40b.c new file mode 100755 index 00000000..a4744495 --- /dev/null +++ b/prowizard/rips/p40b.c @@ -0,0 +1,50 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_P40B ( void ) +{ + /* PW_k is the number of sample */ + + /* OutName[1] = Extensions[P40B][0]; + OutName[2] = Extensions[P40B][1]; + OutName[3] = Extensions[P40B][2];*/ + + PW_l = ( (in_data[PW_Start_Address+16]*256*256*256) + + (in_data[PW_Start_Address+17]*256*256) + + (in_data[PW_Start_Address+18]*256) + + in_data[PW_Start_Address+19] ); + + /* get whole sample size */ + PW_o = 0; + for ( PW_j=0 ; PW_j PW_o ) + { + PW_o = PW_m; + PW_n = ( (in_data[PW_Start_Address+24+PW_j*16]*256) + + in_data[PW_Start_Address+25+PW_j*16] ); + } + } + + OutputSize = PW_l + PW_o + (PW_n*2) + 4; + + /* printf ( "\b\b\b\b\b\b\b\bThe Player 4.0B module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + + CONVERT = GOOD; + Save_Rip ( "The Player 4.0B module", P40B ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* 1 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/p41a.c b/prowizard/rips/p41a.c new file mode 100755 index 00000000..614e65b3 --- /dev/null +++ b/prowizard/rips/p41a.c @@ -0,0 +1,50 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_P41A ( void ) +{ + /* PW_k is the number of sample */ + + /* OutName[1] = Extensions[P41A][0]; + OutName[2] = Extensions[P41A][1]; + OutName[3] = Extensions[P41A][2];*/ + + PW_l = ( (in_data[PW_Start_Address+16]*256*256*256) + + (in_data[PW_Start_Address+17]*256*256) + + (in_data[PW_Start_Address+18]*256) + + in_data[PW_Start_Address+19] ); + + /* get whole sample size */ + PW_o = 0; + for ( PW_j=0 ; PW_j PW_o ) + { + PW_o = PW_m; + PW_n = ( (in_data[PW_Start_Address+24+PW_j*16]*256) + + in_data[PW_Start_Address+25+PW_j*16] ); + } + } + + OutputSize = PW_l + PW_o + (PW_n*2) + 4; + + /* printf ( "\b\b\b\b\b\b\b\bThe Player 4.1A module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + + CONVERT = GOOD; + Save_Rip ( "The Player 4.1A module", P41A ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* 1 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/p50a.c b/prowizard/rips/p50a.c new file mode 100755 index 00000000..01e176b7 --- /dev/null +++ b/prowizard/rips/p50a.c @@ -0,0 +1,30 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_P50A ( void ) +{ + /* PW_j is the number of sample */ + /* PW_WholeSampleSize is the whole sample data size */ + + /* OutName[1] = Extensions[P50A][0]; + OutName[2] = Extensions[P50A][1]; + OutName[3] = Extensions[P50A][2];*/ + + OutputSize = PW_j + PW_WholeSampleSize; + + /* printf ( "\b\b\b\b\b\b\b\bThe Player 5.0A module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + + CONVERT = GOOD; + Save_Rip ( "The Player 5.0A module", P50A ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 8); /* 7 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/p60a.c b/prowizard/rips/p60a.c new file mode 100755 index 00000000..793893d2 --- /dev/null +++ b/prowizard/rips/p60a.c @@ -0,0 +1,30 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_P60A ( void ) +{ + /* PW_j is the number of sample */ + /* PW_WholeSampleSize is the whole sample data size */ + + /* OutName[1] = Extensions[P60A][0]; + OutName[2] = Extensions[P60A][1]; + OutName[3] = Extensions[P60A][2];*/ + + OutputSize = PW_j + PW_WholeSampleSize; + + /* printf ( "\b\b\b\b\b\b\b\bThe Player 6.0A module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + + CONVERT = GOOD; + Save_Rip ( "The Player 6.0A module", P60A ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 12); /* 7 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/p61a.c b/prowizard/rips/p61a.c new file mode 100755 index 00000000..487f86b2 --- /dev/null +++ b/prowizard/rips/p61a.c @@ -0,0 +1,31 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +void Rip_P61A ( void ) +{ + /* PW_j is the number of sample */ + /* PW_WholeSampleSize is the whole sample data size */ + + /* OutName[1] = Extensions[P61A][0]; + OutName[2] = Extensions[P61A][1]; + OutName[3] = Extensions[P61A][2];*/ + + OutputSize = PW_j + PW_WholeSampleSize; + + /* printf ( "\b\b\b\b\b\b\b\bThe Player 6.1A module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + + CONVERT = GOOD; + Save_Rip ( "The Player 6.1A module", P61A ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 12); /* 7 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/pha.c b/prowizard/rips/pha.c new file mode 100755 index 00000000..65cfd1d2 --- /dev/null +++ b/prowizard/rips/pha.c @@ -0,0 +1,52 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_PHA ( void ) +{ + /* PW_k is still the highest pattern address ... so, 'all' we */ + /* have to do, here, is to depack the last pattern to get its */ + /* size ... that's all we need. */ + /* NOTE: we dont need to calculate the whole sample size, so */ + PW_m = 0; + + /* printf ( "(pha)Where : %ld\n" + "(pha)PW_Start_Address : %ld " + "(pha)PW_k : %ld\n" + , PW_i, PW_Start_Address, PW_k ); + fflush (stdout);*/ + for ( PW_j=0 ; PW_j<256 ; PW_j++ ) + { + /* 192 = 1100-0000 ($C0) */ + if ( in_data[PW_Start_Address+PW_k+PW_m] < 192 ) + { + PW_m += 4; + continue; + } + else + { + PW_l = 255 - in_data[PW_Start_Address+PW_k+PW_m+1]; + PW_m += 2; + PW_j += (PW_l-1); + } + } + OutputSize = PW_m + PW_k; + + /* printf ( "\b\b\b\b\b\b\b\bPHA Packed music found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Pha_packer][0]; + OutName[2] = Extensions[Pha_packer][1]; + OutName[3] = Extensions[Pha_packer][2];*/ + + CONVERT = GOOD; + Save_Rip ( "PHA Packed music", Pha_packer ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 12); /* 11 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/pm.c b/prowizard/rips/pm.c new file mode 100755 index 00000000..4c11f5ac --- /dev/null +++ b/prowizard/rips/pm.c @@ -0,0 +1,39 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_PM ( void ) +{ + /* OutName[1] = Extensions[Power_Music][0]; + OutName[2] = Extensions[Power_Music][1]; + OutName[3] = Extensions[Power_Music][2];*/ + + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+42+PW_k*30]*256)+in_data[PW_Start_Address+43+PW_k*30])*2); + + PW_j = in_data[PW_Start_Address+950]; + PW_l=0; + for ( PW_k=0 ; PW_k<128 ; PW_k++ ) + { + if ( in_data[PW_Start_Address+952+PW_k] > PW_l ) + PW_l = in_data[PW_Start_Address+952+PW_k]; + } + PW_l += 1; + PW_k = 1084 + (PW_l * 1024); + OutputSize = PW_k + PW_WholeSampleSize; + /* printf ( "\b\b\b\b\b\b\b\bPower Music module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + + CONVERT = GOOD; + Save_Rip ( "Power Music module", Power_Music ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 1083); /* 1080 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/pm01.c b/prowizard/rips/pm01.c new file mode 100755 index 00000000..d040738a --- /dev/null +++ b/prowizard/rips/pm01.c @@ -0,0 +1,35 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_PM01 ( void ) +{ + PW_WholeSampleSize = 0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+PW_j*8]*256)+in_data[PW_Start_Address+1+PW_j*8])*2); + + PW_k = (in_data[PW_Start_Address+762]*256*256*256) + +(in_data[PW_Start_Address+763]*256*256) + +(in_data[PW_Start_Address+764]*256) + +in_data[PW_Start_Address+765]; + + OutputSize = PW_WholeSampleSize + PW_k + 766; + + /* printf ( "\b\b\b\b\b\b\b\bPromizer 0.1 music found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Promizer_01][0]; + OutName[2] = Extensions[Promizer_01][1]; + OutName[3] = Extensions[Promizer_01][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Promizer 0.1 music", Promizer_01 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 4); /* 3 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/pm10c.c b/prowizard/rips/pm10c.c new file mode 100755 index 00000000..db20410c --- /dev/null +++ b/prowizard/rips/pm10c.c @@ -0,0 +1,29 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_PM10c ( void ) +{ + /* we NEED this 'PW_j' value found while testing !,so we keep it :) */ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+4460+8*PW_k]*256)+in_data[PW_Start_Address+4461+8*PW_k])*2); + OutputSize = 4456 + PW_j + PW_WholeSampleSize; + /* printf ( "\b\b\b\b\b\b\b\bPromizer 1.0c module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Promizer_10c][0]; + OutName[2] = Extensions[Promizer_10c][1]; + OutName[3] = Extensions[Promizer_10c][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Promizer 1.0c module", Promizer_10c ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* 1 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/pm18a.c b/prowizard/rips/pm18a.c new file mode 100755 index 00000000..bd4e2238 --- /dev/null +++ b/prowizard/rips/pm18a.c @@ -0,0 +1,29 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_PM18a ( void ) +{ + /* we NEED this 'PW_j' value found while testing !,so we keep it :) */ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+4464+8*PW_k]*256)+in_data[PW_Start_Address+4465+8*PW_k])*2); + OutputSize = 4460 + PW_j + PW_WholeSampleSize; + /* printf ( "\b\b\b\b\b\b\b\bPromizer 1.8a module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Promizer_18a][0]; + OutName[2] = Extensions[Promizer_18a][1]; + OutName[3] = Extensions[Promizer_18a][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Promizer 1.8a module", Promizer_18a ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* 1 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/pm20.c b/prowizard/rips/pm20.c new file mode 100755 index 00000000..9c2a085c --- /dev/null +++ b/prowizard/rips/pm20.c @@ -0,0 +1,29 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_PM20 ( void ) +{ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+5458+PW_k*8]*256)+in_data[PW_Start_Address+5459+PW_k*8])*2); + PW_j = (in_data[PW_Start_Address+5706]*256*256*256)+(in_data[PW_Start_Address+5707]*256*256)+(in_data[PW_Start_Address+5708]*256)+in_data[PW_Start_Address+5709]; + OutputSize = PW_WholeSampleSize + 5198 + PW_j; + /* printf ( "\b\b\b\b\b\b\b\bPromizer 2.0 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Promizer_20][0]; + OutName[2] = Extensions[Promizer_20][1]; + OutName[3] = Extensions[Promizer_20][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Promizer 2.0 module", Promizer_20 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* 1 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/pm40.c b/prowizard/rips/pm40.c new file mode 100755 index 00000000..926dfecf --- /dev/null +++ b/prowizard/rips/pm40.c @@ -0,0 +1,31 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_PM40 ( void ) +{ + /* PW_l is the sample data address */ + + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+264+PW_k*8]*256)+in_data[PW_Start_Address+265+PW_k*8])*2); + + OutputSize = PW_WholeSampleSize + PW_l + 4; + /* printf ( "\b\b\b\b\b\b\b\bPromizer 4.0 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[PM40][0]; + OutName[2] = Extensions[PM40][1]; + OutName[3] = Extensions[PM40][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Promizer 4.0 module", PM40 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* 1 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/polka.c b/prowizard/rips/polka.c new file mode 100755 index 00000000..d897aff7 --- /dev/null +++ b/prowizard/rips/polka.c @@ -0,0 +1,23 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_Polka ( void ) +{ + /* PW_WholeSampleSize is the whole sample size */ + /* PW_k is the highest pattern number */ + + OutputSize = PW_WholeSampleSize + (PW_k*1024) + 0x43c; + + CONVERT = GOOD; + Save_Rip ( "Polka Packed music", PolkaPacker ); + + if ( Save_Status == GOOD ) + PW_i += 0x43C; /* put back pointer after header*/ +} diff --git a/prowizard/rips/powerp23.c b/prowizard/rips/powerp23.c new file mode 100755 index 00000000..bfb491b3 --- /dev/null +++ b/prowizard/rips/powerp23.c @@ -0,0 +1,52 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_Powerpacker23 ( void ) +{ + /* PW_l is still the whole size */ + + + Uchar * Amiga_EXE_Header_Block; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bPowerpacker 2.3 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Powerpacker23][0]; + OutName[2] = Extensions[Powerpacker23][1]; + OutName[3] = Extensions[Powerpacker23][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 36; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 36 ); + BZERO ( Amiga_EXE_Header_Block , 36 ); + + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[30] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x02; + Amiga_EXE_Header_Block[19] = 0x01; + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[35] = 0x83; + Amiga_EXE_Header_Block[31] = 0xE9; + + Save_Rip_Special ( "Powerpacker 2.3 Exe-file", Powerpacker23, Amiga_EXE_Header_Block , 36 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 36; + Save_Rip ( "Powerpacker 2.3 Exe-file", Powerpacker23 ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 40); /* 36 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/powerp30.c b/prowizard/rips/powerp30.c new file mode 100755 index 00000000..7c3ff54c --- /dev/null +++ b/prowizard/rips/powerp30.c @@ -0,0 +1,53 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +void Rip_Powerpacker30 ( void ) +{ + /* PW_l is still the whole size */ + + + Uchar * Amiga_EXE_Header_Block; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bPowerpacker 3.0 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Powerpacker3][0]; + OutName[2] = Extensions[Powerpacker3][1]; + OutName[3] = Extensions[Powerpacker3][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 36; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 36 ); + BZERO ( Amiga_EXE_Header_Block , 36 ); + + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[30] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x02; + Amiga_EXE_Header_Block[19] = 0x01; + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[35] = 0x89; + Amiga_EXE_Header_Block[31] = 0xE9; + + Save_Rip_Special ( "Powerpacker 3.0 Exe-file", Powerpacker3, Amiga_EXE_Header_Block , 36 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 36; + Save_Rip ( "Powerpacker 3.0 Exe-file", Powerpacker3 ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 40); /* 36 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/powerp40.c b/prowizard/rips/powerp40.c new file mode 100755 index 00000000..19afc4fd --- /dev/null +++ b/prowizard/rips/powerp40.c @@ -0,0 +1,52 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_Powerpacker40 ( void ) +{ + /* PW_l is still the whole size */ + + + Uchar * Amiga_EXE_Header_Block; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bPowerpacker 4.0 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Powerpacker4][0]; + OutName[2] = Extensions[Powerpacker4][1]; + OutName[3] = Extensions[Powerpacker4][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 36; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 36 ); + BZERO ( Amiga_EXE_Header_Block , 36 ); + + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[30] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x02; + Amiga_EXE_Header_Block[19] = 0x01; + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[35] = 0x9E; + Amiga_EXE_Header_Block[31] = 0xE9; + + Save_Rip_Special ( "Powerpacker 4.0 Exe-file", Powerpacker4, Amiga_EXE_Header_Block , 36 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 36; + Save_Rip ( "Powerpacker 4.0 Exe-file", Powerpacker4 ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 40); /* 36 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/powerp4l.c b/prowizard/rips/powerp4l.c new file mode 100755 index 00000000..ce2b065a --- /dev/null +++ b/prowizard/rips/powerp4l.c @@ -0,0 +1,68 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_Powerpacker4lib ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bPowerpacker 4.0 library Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Powerpacker4][0]; + OutName[2] = Extensions[Powerpacker4][1]; + OutName[3] = Extensions[Powerpacker4][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 36; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 36 ); + BZERO ( Amiga_EXE_Header_Block , 36 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[30] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x02; + Amiga_EXE_Header_Block[19] = 0x01; + Amiga_EXE_Header_Block[27] = 0x01; + Amiga_EXE_Header_Block[31] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 60; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[32] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[33] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[34] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[35] = *Whatever; + + /* also the last 4 bytes could be 'removed' frequently ... Here they are */ + in_data[PW_Start_Address+OutputSize-4] = 0x00; + in_data[PW_Start_Address+OutputSize-3] = 0x00; + in_data[PW_Start_Address+OutputSize-2] = 0x03; + in_data[PW_Start_Address+OutputSize-1] = 0xF2; + + Save_Rip_Special ( "Powerpacker 4.0 library Exe-file", Powerpacker4, Amiga_EXE_Header_Block , 36 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 36; + Save_Rip ( "Powerpacker 4.0 library Exe-file", Powerpacker4 ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 37); /* 36 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/pp10.c b/prowizard/rips/pp10.c new file mode 100755 index 00000000..e696d275 --- /dev/null +++ b/prowizard/rips/pp10.c @@ -0,0 +1,29 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_PP10 ( void ) +{ + /* PW_k is still the size of the track data */ + /* PW_WholeSampleSize is still the sample data size */ + + OutputSize = PW_WholeSampleSize + PW_k + 762; + + /* printf ( "\b\b\b\b\b\b\b\bProPacker v1.0 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[PP10][0]; + OutName[2] = Extensions[PP10][1]; + OutName[3] = Extensions[PP10][2];*/ + + CONVERT = GOOD; + Save_Rip ( "ProPacker v1.0 Exe-file", PP10 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 4); /* 3 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/pp21.c b/prowizard/rips/pp21.c new file mode 100755 index 00000000..f4b9a742 --- /dev/null +++ b/prowizard/rips/pp21.c @@ -0,0 +1,29 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_PP21 ( void ) +{ + /* PW_k is still the size of the track "data" ! */ + /* PW_WholeSampleSize is still the whole sample size */ + + PW_l = (in_data[PW_Start_Address+762+PW_k]*256*256*256) + +(in_data[PW_Start_Address+763+PW_k]*256*256) + +(in_data[PW_Start_Address+764+PW_k]*256) + +in_data[PW_Start_Address+765+PW_k]; + + OutputSize = PW_WholeSampleSize + PW_k + PW_l + 766; + + CONVERT = GOOD; + Save_Rip ( "ProPacker v2.1 module", Propacker_21 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 4); /* 3 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/pp30.c b/prowizard/rips/pp30.c new file mode 100755 index 00000000..16fb82ef --- /dev/null +++ b/prowizard/rips/pp30.c @@ -0,0 +1,29 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_PP30 ( void ) +{ + /* PW_k is still the size of the track "data" ! */ + /* PW_WholeSampleSize is still the whole sample size */ + + PW_l = (in_data[PW_Start_Address+762+PW_k]*256*256*256) + +(in_data[PW_Start_Address+763+PW_k]*256*256) + +(in_data[PW_Start_Address+764+PW_k]*256) + +in_data[PW_Start_Address+765+PW_k]; + + OutputSize = PW_WholeSampleSize + PW_k + PW_l + 766; + + CONVERT = GOOD; + Save_Rip ( "ProPacker v3.0 module", Propacker_30 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 4); /* 3 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/ppbk.c b/prowizard/rips/ppbk.c new file mode 100755 index 00000000..e8496636 --- /dev/null +++ b/prowizard/rips/ppbk.c @@ -0,0 +1,30 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_PPbk ( void ) +{ + /* PW_l is still the whole size */ + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bAMOS PowerPacker Bank \"PPbk\" Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + printf ( " extracting PP20 subfile ...\n" ); + /* OutName[1] = Extensions[PP20][0]; + OutName[2] = Extensions[PP20][1]; + OutName[3] = Extensions[PP20][2];*/ + + CONVERT = BAD; + + PW_Start_Address += 16; + Save_Rip ( "AMOS PowerPacker Bank \"PPbk\" Data-file", PP20 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 40); /* 36 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/prun1.c b/prowizard/rips/prun1.c new file mode 100755 index 00000000..7240e59e --- /dev/null +++ b/prowizard/rips/prun1.c @@ -0,0 +1,33 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_PRUN1 ( void ) +{ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+42+30*PW_k]*256)+in_data[PW_Start_Address+43+30*PW_k])*2); + PW_l=0; + for ( PW_k=0 ; PW_k<128 ; PW_k++ ) + if ( in_data[PW_Start_Address+952+PW_k] > PW_l ) + PW_l = in_data[PW_Start_Address+952+PW_k]; + PW_l += 1; + OutputSize = (PW_l*1024) + 1084 + PW_WholeSampleSize; + /* printf ( "\b\b\b\b\b\b\b\bProrunner 1 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[ProRunner_v1][0]; + OutName[2] = Extensions[ProRunner_v1][1]; + OutName[3] = Extensions[ProRunner_v1][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Prorunner 1 module", ProRunner_v1 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 1083); /* 1080 could be enough */ +} + diff --git a/prowizard/rips/prun2.c b/prowizard/rips/prun2.c new file mode 100755 index 00000000..623eea73 --- /dev/null +++ b/prowizard/rips/prun2.c @@ -0,0 +1,29 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_PRUN2 ( void ) +{ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+8+PW_k*8]*256)+in_data[PW_Start_Address+9+PW_k*8])*2); + + OutputSize = PW_j + PW_WholeSampleSize; + /* printf ( "\b\b\b\b\b\b\b\bProrunner 2 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[ProRunner_v2][0]; + OutName[2] = Extensions[ProRunner_v2][1]; + OutName[3] = Extensions[ProRunner_v2][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Prorunner 2 module", ProRunner_v2 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 2); /* -1 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/ptk.c b/prowizard/rips/ptk.c new file mode 100755 index 00000000..676af516 --- /dev/null +++ b/prowizard/rips/ptk.c @@ -0,0 +1,24 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_PTK ( void ) +{ + /* PW_k is still the nbr of pattern */ + /* PW_WholeSampleSize is still the whole sample size */ + + OutputSize = PW_WholeSampleSize + (PW_k*1024) + 1084; + + CONVERT = BAD; + Save_Rip ( "Protracker module", Protracker ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 1081); /* 1080 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/qc.c b/prowizard/rips/qc.c new file mode 100755 index 00000000..4dd5cb9f --- /dev/null +++ b/prowizard/rips/qc.c @@ -0,0 +1,31 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_QuadraComposer ( void ) +{ + PW_l = (in_data[PW_Start_Address+4]*256*256*256)+ + (in_data[PW_Start_Address+5]*256*256)+ + (in_data[PW_Start_Address+6]*256)+ + in_data[PW_Start_Address+7]; + + OutputSize = PW_l + 8; + + /* printf ( "\b\b\b\b\b\b\b\bQuadra Composer module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[QuadraComposer][0]; + OutName[2] = Extensions[QuadraComposer][1]; + OutName[3] = Extensions[QuadraComposer][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Quadra Composer module", QuadraComposer ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 9); /* 8 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/relokit.c b/prowizard/rips/relokit.c new file mode 100755 index 00000000..53d56ebe --- /dev/null +++ b/prowizard/rips/relokit.c @@ -0,0 +1,82 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_RelokIt10 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bRelokIt 1.0 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[RelokIt][0]; + OutName[2] = Extensions[RelokIt][1]; + OutName[3] = Extensions[RelokIt][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 36; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 36 ); + BZERO ( Amiga_EXE_Header_Block , 36 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[30] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x02; + Amiga_EXE_Header_Block[19] = 0x01; + Amiga_EXE_Header_Block[27] = 0x01; + Amiga_EXE_Header_Block[31] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 204; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[32] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[33] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[34] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[35] = *Whatever; + + /* also the last 16 bytes are 'removed' frequently ... Here they are */ + in_data[PW_Start_Address+OutputSize-16] = 0x00; + in_data[PW_Start_Address+OutputSize-15] = 0x00; + in_data[PW_Start_Address+OutputSize-14] = 0x03; + in_data[PW_Start_Address+OutputSize-13] = 0xF2; + + in_data[PW_Start_Address+OutputSize-12] = 0x00; + in_data[PW_Start_Address+OutputSize-11] = 0x00; + in_data[PW_Start_Address+OutputSize-10] = 0x03; + in_data[PW_Start_Address+OutputSize-9] = 0xEB; + + in_data[PW_Start_Address+OutputSize-8] = 0x00; + in_data[PW_Start_Address+OutputSize-7] = 0x00; + in_data[PW_Start_Address+OutputSize-6] = 0x00; + in_data[PW_Start_Address+OutputSize-5] = 0x01; + + in_data[PW_Start_Address+OutputSize-4] = 0x00; + in_data[PW_Start_Address+OutputSize-3] = 0x00; + in_data[PW_Start_Address+OutputSize-2] = 0x03; + in_data[PW_Start_Address+OutputSize-1] = 0xF2; + + Save_Rip_Special ( "RelokIt 1.0 Exe-file", RelokIt, Amiga_EXE_Header_Block , 36 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 36; + Save_Rip ( "RelokIt 1.0 Exe-file", RelokIt ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 40); /* 36 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/skyt.c b/prowizard/rips/skyt.c new file mode 100755 index 00000000..6c434890 --- /dev/null +++ b/prowizard/rips/skyt.c @@ -0,0 +1,38 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_SKYT ( void ) +{ + /* PW_WholeSampleSize is still the whole sample size */ + + PW_l=0; + PW_j = in_data[PW_Start_Address+260]+1; + for ( PW_k=0 ; PW_k<(PW_j*4) ; PW_k++ ) + { + PW_m = (in_data[PW_Start_Address+262+PW_k*2]); + if ( PW_m > PW_l ) + { + PW_l = PW_m; + } + /*printf ( "[%ld]:%ld\n",PW_k,PW_m);*/ + } + OutputSize = (PW_l*256) + 262 + PW_WholeSampleSize + (PW_j*8); + /*printf ( "\b\b\b\b\b\b\b\bSKYT Packed module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[SKYT_packer][0]; + OutName[2] = Extensions[SKYT_packer][1]; + OutName[3] = Extensions[SKYT_packer][2];*/ + + CONVERT = GOOD; + Save_Rip ( "SKYT Packed module", SKYT_packer ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 261); /* 260 could be enough */ +} + diff --git a/prowizard/rips/soundfx.c b/prowizard/rips/soundfx.c new file mode 100755 index 00000000..2017a194 --- /dev/null +++ b/prowizard/rips/soundfx.c @@ -0,0 +1,33 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_SoundFX13 ( void ) +{ + /* PW_k is still the nbr of pattern */ + /* PW_WholeSampleSize is the WholeSampleSize :) */ + + OutputSize = PW_WholeSampleSize + (PW_k*1024) + 0x294; + + /*printf ( "\b\b\b\b\b\b\b\bSound FX 1.3 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[SoundFX][0]; + OutName[2] = Extensions[SoundFX][1]; + OutName[3] = Extensions[SoundFX][2];*/ + +#ifdef UNIX + CONVERT = BAD; +#else + CONVERT = GOOD; +#endif + Save_Rip ( "Sound FX 1.3 module", SoundFX ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 0x40); /* 0x3C should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/soundtk.c b/prowizard/rips/soundtk.c new file mode 100755 index 00000000..597591f4 --- /dev/null +++ b/prowizard/rips/soundtk.c @@ -0,0 +1,25 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +void Rip_SoundTracker ( void ) +{ + /* PW_k is still the nbr of pattern */ + /* PW_WholeSampleSize is still the whole sample size */ + + OutputSize = PW_WholeSampleSize + (PW_k*1024) + 600; + + CONVERT = BAD; + Save_Rip ( "SoundTracker module", SoundTracker ); + + if ( Save_Status == GOOD ) + PW_i += 46; /* after 1st volume */ +} + diff --git a/prowizard/rips/spike.c b/prowizard/rips/spike.c new file mode 100755 index 00000000..c24c8a16 --- /dev/null +++ b/prowizard/rips/spike.c @@ -0,0 +1,52 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_SpikeCruncher ( void ) +{ + /* PW_l is still the whole size */ + + + Uchar * Amiga_EXE_Header_Block; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bSpike Cruncher Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[SpikeCruncher][0]; + OutName[2] = Extensions[SpikeCruncher][1]; + OutName[3] = Extensions[SpikeCruncher][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 36; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 36 ); + BZERO ( Amiga_EXE_Header_Block , 36 ); + + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[30] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x02; + Amiga_EXE_Header_Block[19] = 0x01; + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[35] = 0x96; + Amiga_EXE_Header_Block[31] = 0xE9; + + Save_Rip_Special ( "Spike Cruncher Exe-file", SpikeCruncher, Amiga_EXE_Header_Block , 36 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 36; + Save_Rip ( "Spike Cruncher Exe-file", SpikeCruncher ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 40); /* 36 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/starpack.c b/prowizard/rips/starpack.c new file mode 100755 index 00000000..7d14bf11 --- /dev/null +++ b/prowizard/rips/starpack.c @@ -0,0 +1,24 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_STARPACK ( void ) +{ + /* PW_k is still the sample data address */ + /* PW_WholeSampleSize is the whole sample size already */ + + OutputSize = PW_WholeSampleSize + PW_k + 0x314; + + CONVERT = GOOD; + Save_Rip ( "StarTrekker Packer module", Star_pack ); + + if ( Save_Status == GOOD ) + PW_i += 24; /* 23 after 1st vol */ +} + diff --git a/prowizard/rips/startrek.c b/prowizard/rips/startrek.c new file mode 100755 index 00000000..ab10e3d1 --- /dev/null +++ b/prowizard/rips/startrek.c @@ -0,0 +1,24 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_StarTrekker ( void ) +{ + /* PW_k is still the nbr of pattern */ + /* PW_WholeSampleSize is still the whole sample size */ + + OutputSize = PW_WholeSampleSize + (PW_k*1024) + 1084; + + CONVERT = BAD; + Save_Rip ( "StarTrekker module", StarTrekker ); + + if ( Save_Status == GOOD ) + PW_i += 1081; /* after header */ +} + diff --git a/prowizard/rips/stc270.c b/prowizard/rips/stc270.c new file mode 100755 index 00000000..df53db3e --- /dev/null +++ b/prowizard/rips/stc270.c @@ -0,0 +1,59 @@ +#ifdef DOS +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_StoneCracker270 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bStoneCracker 2.70 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[S404][0]; + OutName[2] = Extensions[S404][1]; + OutName[3] = Extensions[S404][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + Save_Rip_Special ( "StoneCracker 2.70 Exe-file", StoneCracker270, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 32; + Save_Rip ( "StoneCracker 2.70 Exe-file", StoneCracker270 ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 36); /* 32 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/stc299.c b/prowizard/rips/stc299.c new file mode 100755 index 00000000..a7c5c85e --- /dev/null +++ b/prowizard/rips/stc299.c @@ -0,0 +1,54 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_STC299 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + Save_Rip_Special ( "StoneCracker 2.99 Exe-file", STC299, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 32; + Save_Rip ( "StoneCracker 2.99 Exe-file", STC299 ); + } + + if ( Save_Status == GOOD ) + PW_i += 348; +} + diff --git a/prowizard/rips/stc299b.c b/prowizard/rips/stc299b.c new file mode 100755 index 00000000..b8962fca --- /dev/null +++ b/prowizard/rips/stc299b.c @@ -0,0 +1,54 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_STC299b ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + Save_Rip_Special ( "StoneCracker 2.99b Exe-file", STC299b, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 32; + Save_Rip ( "StoneCracker 2.99b Exe-file", STC299b ); + } + + if ( Save_Status == GOOD ) + PW_i += 344; +} + diff --git a/prowizard/rips/stc299d.c b/prowizard/rips/stc299d.c new file mode 100755 index 00000000..2bca4b63 --- /dev/null +++ b/prowizard/rips/stc299d.c @@ -0,0 +1,54 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_STC299d ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + Save_Rip_Special ( "StoneCracker 2.99d Exe-file", STC299d, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 32; + Save_Rip ( "StoneCracker 2.99d Exe-file", STC299d ); + } + + if ( Save_Status == GOOD ) + PW_i += 340; +} + diff --git a/prowizard/rips/stc300.c b/prowizard/rips/stc300.c new file mode 100755 index 00000000..07578137 --- /dev/null +++ b/prowizard/rips/stc300.c @@ -0,0 +1,54 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_STC300 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + Save_Rip_Special ( "StoneCracker 3.00 Exe-file", STC300, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 32; + Save_Rip ( "StoneCracker 3.00 Exe-file", STC300 ); + } + + if ( Save_Status == GOOD ) + PW_i += 336; /* beside the S300 tag */ +} + diff --git a/prowizard/rips/stc310.c b/prowizard/rips/stc310.c new file mode 100755 index 00000000..5f616724 --- /dev/null +++ b/prowizard/rips/stc310.c @@ -0,0 +1,54 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_STC310 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + Save_Rip_Special ( "StoneCracker 3.10 Exe-file", STC310, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 32; + Save_Rip ( "StoneCracker 3.10 Exe-file", STC310 ); + } + + if ( Save_Status == GOOD ) + PW_i += 520; /* beside the S310 tag */ +} + diff --git a/prowizard/rips/stim.c b/prowizard/rips/stim.c new file mode 100755 index 00000000..44679276 --- /dev/null +++ b/prowizard/rips/stim.c @@ -0,0 +1,26 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_STIM ( void ) +{ + OutputSize = PW_WholeSampleSize + PW_j + 31*4 + 31*8; + + /* printf ( "\b\b\b\b\b\b\b\bSTIM (Slamtilt) module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[STIM][0]; + OutName[2] = Extensions[STIM][1]; + OutName[3] = Extensions[STIM][2];*/ + + CONVERT = GOOD; + Save_Rip ( "STIM (Slamtilt) module", STIM ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 1); /* 0 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/stk26.c b/prowizard/rips/stk26.c new file mode 100755 index 00000000..9d389c41 --- /dev/null +++ b/prowizard/rips/stk26.c @@ -0,0 +1,38 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_STK26 ( void ) +{ + /* PW_WholeSampleSize is the whole sample siz */ + OutputSize = (in_data[PW_Start_Address+951]*256) + 1468 + PW_WholeSampleSize; + + CONVERT = GOOD; + if ( in_data[PW_Start_Address+1464] == 'M' ) + { + /* OutName[1] = Extensions[STK26][0]; + OutName[2] = Extensions[STK26][1]; + OutName[3] = Extensions[STK26][2];*/ + Save_Rip ( "Sountracker 2.6 module", STK26 ); + /* printf ( "\b\b\b\b\b\b\b\bSountracker 2.6 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + } + else + { + /* OutName[1] = Extensions[IceTracker][0]; + OutName[2] = Extensions[IceTracker][1]; + OutName[3] = Extensions[IceTracker][2];*/ + Save_Rip ( "IceTracker 1.0 modul", IceTracker ); + /* printf ( "\b\b\b\b\b\b\b\bIceTracker 1.0 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + } + + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 1470); /* 1464 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/superc27.c b/prowizard/rips/superc27.c new file mode 100755 index 00000000..96022011 --- /dev/null +++ b/prowizard/rips/superc27.c @@ -0,0 +1,61 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_SuperCruncher27 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bSuper Cruncher 2.7 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[SuperCruncher][0]; + OutName[2] = Extensions[SuperCruncher][1]; + OutName[3] = Extensions[SuperCruncher][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 36; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 36 ); + BZERO ( Amiga_EXE_Header_Block , 36 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[30] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x02; + Amiga_EXE_Header_Block[19] = 0x01; + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[35] = 0xA8; + Amiga_EXE_Header_Block[31] = 0xE9; + + Amiga_EXE_Header_Block[24] = in_data[PW_Start_Address+680]; + Amiga_EXE_Header_Block[25] = in_data[PW_Start_Address+681]; + Amiga_EXE_Header_Block[26] = in_data[PW_Start_Address+682]; + Amiga_EXE_Header_Block[27] = in_data[PW_Start_Address+683]; + + /* also the last 4 bytes are 'removed' frequently ... Here they are */ + in_data[PW_Start_Address+OutputSize-4] = 0x00; + in_data[PW_Start_Address+OutputSize-3] = 0x00; + in_data[PW_Start_Address+OutputSize-2] = 0x03; + in_data[PW_Start_Address+OutputSize-1] = 0xF2; + + Save_Rip_Special ( "Super Cruncher 2.7 Exe-file", SuperCruncher, Amiga_EXE_Header_Block , 36 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 36; + Save_Rip ( "Super Cruncher 2.7 Exe-file", SuperCruncher ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 40); /* 36 should do but call it "just to be sure" :) */ +} + diff --git a/prowizard/rips/syncro.c b/prowizard/rips/syncro.c new file mode 100755 index 00000000..418852e4 --- /dev/null +++ b/prowizard/rips/syncro.c @@ -0,0 +1,59 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_SyncroPacker ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bSyncro Packer 4.6 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[SyncroPacker][0]; + OutName[2] = Extensions[SyncroPacker][1]; + OutName[3] = Extensions[SyncroPacker][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + + Save_Rip_Special ( "Syncro Packer 4.6 Exe-file", SyncroPacker, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 32; + Save_Rip ( "Syncro Packer 4.6 Exe-file", SyncroPacker ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 100); /* 32 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/tdd.c b/prowizard/rips/tdd.c new file mode 100755 index 00000000..b43eb39a --- /dev/null +++ b/prowizard/rips/tdd.c @@ -0,0 +1,28 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_TheDarkDemon ( void ) +{ + /* PW_WholeSampleSize is the WholeSampleSize + pattern data size */ + + /* 564 = header */ + OutputSize = PW_WholeSampleSize + 564; + + /* printf ( "\b\b\b\b\b\b\b\bThe Dark Demon module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[TDD][0]; + OutName[2] = Extensions[TDD][1]; + OutName[3] = Extensions[TDD][2];*/ + + CONVERT = GOOD; + Save_Rip ( "The Dark Demon module", TDD ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 140); /* 137 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/time17.c b/prowizard/rips/time17.c new file mode 100755 index 00000000..ccd59df8 --- /dev/null +++ b/prowizard/rips/time17.c @@ -0,0 +1,92 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_TimeCruncher17 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bTime Cruncher 1.7 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[TimeCruncher][0]; + OutName[2] = Extensions[TimeCruncher][1]; + OutName[3] = Extensions[TimeCruncher][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 36; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 36 ); + BZERO ( Amiga_EXE_Header_Block , 36 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[30] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x02; + Amiga_EXE_Header_Block[19] = 0x01; + Amiga_EXE_Header_Block[27] = 0x01; + Amiga_EXE_Header_Block[31] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 60; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[32] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[33] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[34] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[35] = *Whatever; + + /* also the last 24 bytes are 'removed' frequently ... Here they are */ + in_data[PW_Start_Address+OutputSize-24] = 0x00; + in_data[PW_Start_Address+OutputSize-23] = 0x00; + in_data[PW_Start_Address+OutputSize-22] = 0x03; + in_data[PW_Start_Address+OutputSize-21] = 0xEC; + + in_data[PW_Start_Address+OutputSize-20] = 0x00; + in_data[PW_Start_Address+OutputSize-19] = 0x00; + in_data[PW_Start_Address+OutputSize-18] = 0x00; + in_data[PW_Start_Address+OutputSize-17] = 0x00; + + in_data[PW_Start_Address+OutputSize-16] = 0x00; + in_data[PW_Start_Address+OutputSize-15] = 0x00; + in_data[PW_Start_Address+OutputSize-14] = 0x03; + in_data[PW_Start_Address+OutputSize-13] = 0xF2; + + in_data[PW_Start_Address+OutputSize-12] = 0x00; + in_data[PW_Start_Address+OutputSize-11] = 0x00; + in_data[PW_Start_Address+OutputSize-10] = 0x03; + in_data[PW_Start_Address+OutputSize-9] = 0xEB; + + in_data[PW_Start_Address+OutputSize-8] = 0x00; + in_data[PW_Start_Address+OutputSize-7] = 0x00; + in_data[PW_Start_Address+OutputSize-6] = 0x00; + in_data[PW_Start_Address+OutputSize-5] = 0x01; + + in_data[PW_Start_Address+OutputSize-4] = 0x00; + in_data[PW_Start_Address+OutputSize-3] = 0x00; + in_data[PW_Start_Address+OutputSize-2] = 0x03; + in_data[PW_Start_Address+OutputSize-1] = 0xF2; + + Save_Rip_Special ( "Time Cruncher 1.7 Exe-file", TimeCruncher, Amiga_EXE_Header_Block , 36 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 36; + Save_Rip ( "Time Cruncher 1.7 Exe-file", TimeCruncher ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 42); /* 36 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/tnmc11.c b/prowizard/rips/tnmc11.c new file mode 100755 index 00000000..47fdc0ae --- /dev/null +++ b/prowizard/rips/tnmc11.c @@ -0,0 +1,84 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_TNMCruncher11 ( void ) +{ + /* PW_l is still the whole size */ + /* PW_m is the decrunched size (necessary to rebuild header) */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bTNM Cruncher 1.1 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[TNMCruncher][0]; + OutName[2] = Extensions[TNMCruncher][1]; + OutName[3] = Extensions[TNMCruncher][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 40; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 40 ); + BZERO ( Amiga_EXE_Header_Block , 40 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[34] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x03; + Amiga_EXE_Header_Block[19] = 0x02; + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[39] = 0x9B; + Amiga_EXE_Header_Block[35] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 680; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[24] = *(Whatever+3); + Amiga_EXE_Header_Block[25] = *(Whatever+2); + Amiga_EXE_Header_Block[26] = *(Whatever+1); + Amiga_EXE_Header_Block[27] = *Whatever; + PW_j = PW_m / 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[31] = *Whatever; + + /* also the last 12 bytes are 'removed' frequently ... Here they are */ + in_data[PW_Start_Address+OutputSize-12] = 0x00; + in_data[PW_Start_Address+OutputSize-11] = 0x00; + in_data[PW_Start_Address+OutputSize-10] = 0x03; + in_data[PW_Start_Address+OutputSize-9] = 0xEB; + + in_data[PW_Start_Address+OutputSize-8] = *(Whatever+3); + in_data[PW_Start_Address+OutputSize-7] = *(Whatever+2); + in_data[PW_Start_Address+OutputSize-6] = *(Whatever+1); + in_data[PW_Start_Address+OutputSize-5] = *Whatever; + + in_data[PW_Start_Address+OutputSize-4] = 0x00; + in_data[PW_Start_Address+OutputSize-3] = 0x00; + in_data[PW_Start_Address+OutputSize-2] = 0x03; + in_data[PW_Start_Address+OutputSize-1] = 0xF2; + + Save_Rip_Special ( "TNM Cruncher 1.1 Exe-file", TNMCruncher, Amiga_EXE_Header_Block , 40 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 40; + Save_Rip ( "TNM Cruncher 1.1 Exe-file", TNMCruncher ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 44); /* 40 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/tp1.c b/prowizard/rips/tp1.c new file mode 100755 index 00000000..74043855 --- /dev/null +++ b/prowizard/rips/tp1.c @@ -0,0 +1,26 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_TP1 ( void ) +{ + /* PW_WholeSampleSize is the size of the module :) */ + + OutputSize = PW_WholeSampleSize; + /* printf ( "\b\b\b\b\b\b\b\bTracker Packer v1 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[TP1][0]; + OutName[2] = Extensions[TP1][1]; + OutName[3] = Extensions[TP1][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Tracker Packer v1 module", TP1 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 1); /* 0 could be enough */ +} diff --git a/prowizard/rips/tp2.c b/prowizard/rips/tp2.c new file mode 100755 index 00000000..e6a21dc3 --- /dev/null +++ b/prowizard/rips/tp2.c @@ -0,0 +1,84 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_TP2 ( void ) +{ + /* PW_j is the size of the pattern list */ + /* PW_l is the number of sample */ + /* PW_WholeSampleSize is the sample data size */ + + + PW_m=0; + for ( PW_k=0 ; PW_k PW_m ) + PW_m = PW_o; + } + /* PW_m is the highest pattern number */ + PW_m += 8; + /* PW_m is now the size of the track table list */ + PW_n = 0; +/*printf ( "highest pattern : %ld (%x)\n" , PW_m , PW_m );*/ + for ( PW_k=0 ; PW_k<(PW_m/2) ; PW_k++ ) + { + PW_o = (in_data[PW_Start_Address+PW_l*8+32+PW_j*2+PW_k*2]*256)+in_data[PW_Start_Address+PW_l*8+33+PW_j*2+PW_k*2]; +/*printf ( "%4x, " , PW_o );*/ + if ( PW_o > PW_n ) + PW_n = PW_o; + } +/*printf ( "\nhighest : %ld (%x)\n" , PW_n , PW_n );*/ +/*printf ( "track data address : %ld (%x)\n" , (34+8*PW_l+2*PW_j+PW_m ),(34+8*PW_l+2*PW_j+PW_m));*/ + PW_n += (34+8*PW_l+2*PW_j+PW_m); +/*printf ( "address of last track : %ld\n" , PW_n );*/ + OutputSize = PW_n; + + + /* all vars are availlable now, save PW_WholeSampleSize */ + + /* now counting size of the last pattern ... pfiew .. */ + PW_l = 0; + for ( PW_j=0 ; PW_j<64 ; PW_j++ ) + { +/*printf ( "%ld," , PW_l );*/ + if ( (in_data[PW_Start_Address+PW_n+PW_l]&0xC0 ) == 0xC0 ) + { + PW_j += (0x100-in_data[PW_Start_Address+PW_n+PW_l]); + PW_j -= 1; + PW_l += 1; + continue; + } + if ( (in_data[PW_Start_Address+PW_n+PW_l]&0xC0 ) == 0x80 ) + { + PW_l += 2; + continue; + } + PW_l += 1; + if ( (in_data[PW_Start_Address+PW_n+PW_l]&0x0F ) == 0x00 ) + { + PW_l += 1; + continue; + } + PW_l += 2; + } +/*printf ( "\nsize of the last track : %ld\n" , PW_l );*/ + + OutputSize += PW_WholeSampleSize + PW_l; + /* printf ( "\b\b\b\b\b\b\b\bTracker Packer v2 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[TP2][0]; + OutName[2] = Extensions[TP2][1]; + OutName[3] = Extensions[TP2][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Tracker Packer v2 module", TP2 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 1); /* 0 could be enough */ +} diff --git a/prowizard/rips/tp3.c b/prowizard/rips/tp3.c new file mode 100755 index 00000000..7569d5ec --- /dev/null +++ b/prowizard/rips/tp3.c @@ -0,0 +1,87 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_TP3 ( void ) +{ + /* PW_j is the size of the pattern list */ + /* PW_l is the number of sample */ + /* PW_WholeSampleSize is the sample data size */ + + + PW_m=0; + for ( PW_k=0 ; PW_k PW_m ) + PW_m = PW_o; + } + /* PW_m is the highest pattern number */ + PW_m += 8; + /* PW_m is now the size of the track table list */ + PW_n = 0; +/*printf ( "highest pattern : %ld (%x)\n" , PW_m , PW_m );*/ + for ( PW_k=0 ; PW_k<(PW_m/2) ; PW_k++ ) + { + PW_o = (in_data[PW_Start_Address+PW_l*8+32+PW_j*2+PW_k*2]*256)+in_data[PW_Start_Address+PW_l*8+33+PW_j*2+PW_k*2]; +/*printf ( "%4x, " , PW_o );*/ + if ( PW_o > PW_n ) + PW_n = PW_o; + } +/*printf ( "\nhighest : %ld (%x)\n" , PW_n , PW_n );*/ +/*printf ( "track data address : %ld (%x)\n" , (34+8*PW_l+2*PW_j+PW_m ),(34+8*PW_l+2*PW_j+PW_m));*/ + PW_n += (34+8*PW_l+2*PW_j+PW_m); +/*printf ( "address of last track : %ld\n" , PW_n );*/ + OutputSize = PW_n; + + + /* all vars are availlable now, save PW_WholeSampleSize */ + + /* now counting size of the last pattern ... pfiew .. */ + PW_l = 0; + for ( PW_j=0 ; PW_j<64 ; PW_j++ ) + { +/*printf ( "%ld," , PW_l );*/ + if ( (in_data[PW_Start_Address+PW_n+PW_l]&0xC0 ) == 0xC0 ) + { + PW_j += (0x100-in_data[PW_Start_Address+PW_n+PW_l]); + PW_j -= 1; + PW_l += 1; + continue; + } + if ( (in_data[PW_Start_Address+PW_n+PW_l]&0xC0 ) == 0x80 ) + { + PW_l += 2; + continue; + } + PW_l += 1; + if ( (in_data[PW_Start_Address+PW_n+PW_l]&0x0F ) == 0x00 ) + { + PW_l += 1; + continue; + } + PW_l += 2; + } +/*printf ( "\nsize of the last track : %ld\n" , PW_l );*/ + + OutputSize += PW_l + 2; /* +2 for $0000 at the end .. */ + if ( ((OutputSize/2)*2) != OutputSize ) + OutputSize += 1; + OutputSize += PW_WholeSampleSize; + /* printf ( "\b\b\b\b\b\b\b\bTracker Packer v3 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[TP3][0]; + OutName[2] = Extensions[TP3][1]; + OutName[3] = Extensions[TP3][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Tracker Packer v3 module", TP3 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 1); /* 0 could be enough */ +} diff --git a/prowizard/rips/tpack102.c b/prowizard/rips/tpack102.c new file mode 100755 index 00000000..48ce2b65 --- /dev/null +++ b/prowizard/rips/tpack102.c @@ -0,0 +1,58 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_Tetrapack102 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bTetrapack 1.02 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[TPACK102][0]; + OutName[2] = Extensions[TPACK102][1]; + OutName[3] = Extensions[TPACK102][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + Save_Rip_Special ( "Tetrapack 1.02 Exe-file", TPACK102, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 32; + Save_Rip ( "Tetrapack 1.02 Exe-file", TPACK102 ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 36); /* 32 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/tpack21.c b/prowizard/rips/tpack21.c new file mode 100755 index 00000000..aa221d88 --- /dev/null +++ b/prowizard/rips/tpack21.c @@ -0,0 +1,58 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_Tetrapack_2_1 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bTetrapack 2.1 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[TPACK21][0]; + OutName[2] = Extensions[TPACK21][1]; + OutName[3] = Extensions[TPACK21][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + Save_Rip_Special ( "Tetrapack 2.1 Exe-file", TPACK21, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 32; + Save_Rip ( "Tetrapack 2.1 Exe-file", TPACK21 ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 36); /* 32 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/tpack22.c b/prowizard/rips/tpack22.c new file mode 100755 index 00000000..4b77b6db --- /dev/null +++ b/prowizard/rips/tpack22.c @@ -0,0 +1,58 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_Tetrapack_2_2 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bTetrapack 2.2 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[TPACK22][0]; + OutName[2] = Extensions[TPACK22][1]; + OutName[3] = Extensions[TPACK22][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + Save_Rip_Special ( "Tetrapack 2.2 Exe-file", TPACK22, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 32; + Save_Rip ( "Tetrapack 2.2 Exe-file", TPACK22 ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 36); /* 32 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/tryit101.c b/prowizard/rips/tryit101.c new file mode 100755 index 00000000..8a40efb5 --- /dev/null +++ b/prowizard/rips/tryit101.c @@ -0,0 +1,59 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_TryIt101 ( void ) +{ + /* PW_l is still the whole size */ + + Uchar * Amiga_EXE_Header_Block; + Uchar * Whatever; + + OutputSize = PW_l; + + /* printf ( "\b\b\b\b\b\b\b\bTry-It Cruncher 1.01 Exe-file found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[TryIt][0]; + OutName[2] = Extensions[TryIt][1]; + OutName[3] = Extensions[TryIt][2];*/ + + CONVERT = BAD; + + if ( Amiga_EXE_Header == BAD ) + { + PW_Start_Address -= 32; + OutputSize -= 32; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 32 ); + BZERO ( Amiga_EXE_Header_Block , 32 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[26] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[11] = 0x01; + Amiga_EXE_Header_Block[27] = 0xE9; + + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + PW_j = PW_l - 36; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[20] = Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[21] = Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[22] = Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[31] = *Whatever; + Save_Rip_Special ( "Try-It Cruncher 1.01 Exe-file", TryIt, Amiga_EXE_Header_Block , 32 ); + free ( Amiga_EXE_Header_Block ); + } + else + { + PW_Start_Address -= 64; + Save_Rip ( "Try-It Cruncher 1.01 Exe-file", TryIt ); + } + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 65); /* 64 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/turbosqueezer61.c b/prowizard/rips/turbosqueezer61.c new file mode 100755 index 00000000..348ae0ad --- /dev/null +++ b/prowizard/rips/turbosqueezer61.c @@ -0,0 +1,73 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_TurboSqueezer61 ( void ) +{ + /* PW_l is still the whole size */ + + /*Uchar * Amiga_EXE_Header_Block;*/ + /*Uchar * Whatever;*/ + + OutputSize = PW_l; + + CONVERT = BAD; + /* + if ( Amiga_EXE_Header == BAD ) + { + OutputSize -= 40; + Amiga_EXE_Header_Block = (Uchar *) malloc ( 40 ); + BZERO ( Amiga_EXE_Header_Block , 40 ); + Amiga_EXE_Header_Block[2] = Amiga_EXE_Header_Block[11] = Amiga_EXE_Header_Block[34] = 0x03; + Amiga_EXE_Header_Block[3] = 0xF3; + Amiga_EXE_Header_Block[19] = 0x02; + Amiga_EXE_Header_Block[23] = Amiga_EXE_Header_Block[39] = 0x7D; + Amiga_EXE_Header_Block[35] = 0xE9; + */ + /* WARNING !!! WORKS ONLY ON PC !!! */ + /* 68k machines code : c1 = *(Whatever+2); */ + /* 68k machines code : c2 = *(Whatever+3); */ + /* PW_j = PW_l - 568; + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[24] = *(Whatever+3); + Amiga_EXE_Header_Block[25] = *(Whatever+2); + Amiga_EXE_Header_Block[26] = *(Whatever+1); + Amiga_EXE_Header_Block[27] = *Whatever; + + PW_j = ((in_data[PW_Start_Address+480]*256*256*256)+ + (in_data[PW_Start_Address+481]*256*256)+ + (in_data[PW_Start_Address+482]*256)+ + in_data[PW_Start_Address+483]) + 36; + + PW_j /= 4; + Whatever = (Uchar *) &PW_j; + Amiga_EXE_Header_Block[28] = *(Whatever+3); + Amiga_EXE_Header_Block[29] = *(Whatever+2); + Amiga_EXE_Header_Block[30] = *(Whatever+1); + Amiga_EXE_Header_Block[31] = *Whatever; + */ + /* also the last 4 bytes are 'removed' frequently ... Here they are */ + /* in_data[PW_Start_Address+OutputSize-4] = 0x00; + in_data[PW_Start_Address+OutputSize-3] = 0x00; + in_data[PW_Start_Address+OutputSize-2] = 0x03; + in_data[PW_Start_Address+OutputSize-1] = 0xF2; + + Save_Rip_Special ( "TurboSqueezer 6.1 Exe-file", TurboSqueezer61, Amiga_EXE_Header_Block , 40 ); + free ( Amiga_EXE_Header_Block ); + } + else + {*/ + PW_Start_Address -= 40; + Save_Rip ( "TurboSqueezer 6.1 Exe-file", TurboSqueezer61 ); + /* }*/ + + if ( Save_Status == GOOD ) + PW_i += 44; +} diff --git a/prowizard/rips/unic.c b/prowizard/rips/unic.c new file mode 100755 index 00000000..83f8fb6f --- /dev/null +++ b/prowizard/rips/unic.c @@ -0,0 +1,46 @@ +#ifdef DOS +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_UNIC_withID ( void ) +{ + /* PW_k is still the nbr of pattern */ + + OutputSize = PW_WholeSampleSize + (PW_k*768) + 1084; + + /* printf ( "\b\b\b\b\b\b\b\bUNIC tracker v1 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[UNIC_v1][0]; + OutName[2] = Extensions[UNIC_v1][1]; + OutName[3] = Extensions[UNIC_v1][2];*/ + + CONVERT = GOOD; + Save_Rip ( "UNIC tracker v1 module", UNIC_v1 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 1081); /* 1080 should do but call it "just to be sure" :) */ +} + + +void Rip_UNIC_noID ( void ) +{ + /* PW_k is still the nbr of pattern */ + + OutputSize = PW_WholeSampleSize + (PW_k*768) + 1080; + + /* printf ( "\b\b\b\b\b\b\b\bUNIC tracker v1 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[UNIC_v1][0]; + OutName[2] = Extensions[UNIC_v1][1]; + OutName[3] = Extensions[UNIC_v1][2];*/ + + CONVERT = GOOD; + Save_Rip ( "UNIC tracker v1 module", UNIC_v1 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 46); /* 45 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/unic2.c b/prowizard/rips/unic2.c new file mode 100755 index 00000000..ca415aa8 --- /dev/null +++ b/prowizard/rips/unic2.c @@ -0,0 +1,28 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +void Rip_UNIC2 ( void ) +{ + /* PW_k is still the nbr of pattern */ + + OutputSize = PW_WholeSampleSize + (PW_k*768) + 1060; + + /* printf ( "\b\b\b\b\b\b\b\bUNIC tracker v2 module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[UNIC_v2][0]; + OutName[2] = Extensions[UNIC_v2][1]; + OutName[3] = Extensions[UNIC_v2][2];*/ + + CONVERT = GOOD; + Save_Rip ( "UNIC tracker v2 module", UNIC_v2 ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 26); /* 25 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/wn.c b/prowizard/rips/wn.c new file mode 100755 index 00000000..ddbff3a2 --- /dev/null +++ b/prowizard/rips/wn.c @@ -0,0 +1,28 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_WN ( void ) +{ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+42+30*PW_k]*256)+in_data[PW_Start_Address+43+30*PW_k])*2); + PW_j = in_data[PW_Start_Address+1083]; + OutputSize = PW_WholeSampleSize + (PW_j*1024) + 1084; + /* printf ( "\b\b\b\b\b\b\b\bWanton Packer module found at %ld !. its size is : %ld\n" , PW_Start_Address , OutputSize );*/ + /* OutName[1] = Extensions[Wanton_packer][0]; + OutName[2] = Extensions[Wanton_packer][1]; + OutName[3] = Extensions[Wanton_packer][2];*/ + + CONVERT = GOOD; + Save_Rip ( "Wanton Packer module", Wanton_packer ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 1082); /* 1081 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/xann.c b/prowizard/rips/xann.c new file mode 100755 index 00000000..d3688f7b --- /dev/null +++ b/prowizard/rips/xann.c @@ -0,0 +1,30 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_XANN ( void ) +{ + /* PW_WholeSampleSize is the whole sample size */ + + PW_k=0; + for ( PW_j=0 ; PW_j<64 ; PW_j++ ) + { + PW_l = in_data[PW_Start_Address+2+PW_j*4]; + if ( PW_l > PW_k ) + PW_k = PW_l; + } + PW_k /= 4; + OutputSize = PW_WholeSampleSize + 1084 + (PW_k*1024); + + CONVERT = GOOD; + Save_Rip ( "Xann Packer module", XANN_packer ); + + if ( Save_Status == GOOD ) + PW_i += (OutputSize - 4); /* 3 should do but call it "just to be sure" :) */ +} diff --git a/prowizard/rips/xm.c b/prowizard/rips/xm.c new file mode 100755 index 00000000..16f30add --- /dev/null +++ b/prowizard/rips/xm.c @@ -0,0 +1,58 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +void Rip_XM ( void ) +{ + /* PW_l is the header size and points on the first pattern */ + /* PW_j is the number of pattern */ + /* PW_k is the number of instruments */ + + /* get whole pattern data siz */ + for ( PW_o=0 ; PW_o 0x7f) || ((PW_Start_Address+896)>PW_in_size) ) + { + return BAD; + } + + /* test #4 */ + for ( PW_k = 0 ; PW_k < 31 ; PW_k ++ ) + { + if ( in_data[PW_Start_Address + 10 + (8*PW_k)] > 0x0f ) + { + return BAD; + } + } + + /* test #5 */ + for ( PW_j=0 ; PW_j<128 ; PW_j++ ) + { + if ( in_data[PW_Start_Address + 768 + PW_j] > 0x7f ) + { + return BAD; + } + } + return GOOD; +} + diff --git a/prowizard/tests/ambk.c b/prowizard/tests/ambk.c new file mode 100755 index 00000000..9a12b316 --- /dev/null +++ b/prowizard/tests/ambk.c @@ -0,0 +1,51 @@ +/* (31 mar 2003) + * ambk.c (test) +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testAmBk ( void ) +{ + if (PW_i + 68 > PW_in_size) + { + return BAD; + } + + /* test #1 */ + PW_Start_Address = PW_i; + if ((in_data[PW_Start_Address+4] != 0x00)|| + (in_data[PW_Start_Address+5] != 0x03)|| + (in_data[PW_Start_Address+6] != 0x00)|| + (in_data[PW_Start_Address+7] > 0x01)|| + (in_data[PW_Start_Address+12]!= 'M')|| + (in_data[PW_Start_Address+13]!= 'u')|| + (in_data[PW_Start_Address+14]!= 's')|| + (in_data[PW_Start_Address+15]!= 'i')|| + (in_data[PW_Start_Address+16]!= 'c')|| + (in_data[PW_Start_Address+17]!= ' ')|| + (in_data[PW_Start_Address+18]!= ' ')|| + (in_data[PW_Start_Address+19]!= ' ')) + { +/*printf ( "#1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* get the whole size */ + PW_k = (in_data[PW_Start_Address+9]*256*256)+(in_data[PW_Start_Address+10]*256)+in_data[PW_Start_Address+11]+12; + if ( PW_k+PW_Start_Address > PW_in_size ) + { +/*printf ( "#1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + return GOOD; +} + diff --git a/prowizard/tests/arcd.c b/prowizard/tests/arcd.c new file mode 100755 index 00000000..7b47e9f7 --- /dev/null +++ b/prowizard/tests/arcd.c @@ -0,0 +1,48 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testArcDDataCruncher () +{ + PW_Start_Address = PW_i; + if ( (PW_Start_Address + 12) > PW_in_size ) + { + return BAD; + } + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+8]*256*256*256) + + (in_data[PW_Start_Address+9]*256*256) + + (in_data[PW_Start_Address+10]*256) + + in_data[PW_Start_Address+11] ); + /* unpacked size */ + PW_k = ( (in_data[PW_Start_Address+5]*256*256) + + (in_data[PW_Start_Address+6]*256) + + in_data[PW_Start_Address+7] ); + + if ( (PW_k <= 2) || (PW_l <= 2) ) + { +/*printf ( "#1\n" );*/ + return BAD; + } + + if ( PW_l > 0xFFFFFF ) + { +/*printf ( "#2\n" );*/ + return BAD; + } + + if ( PW_k <= PW_l ) + { +/*printf ( "#3\n" );*/ + return BAD; + } + + return GOOD; +} diff --git a/prowizard/tests/bp.c b/prowizard/tests/bp.c new file mode 100755 index 00000000..b1fd6c74 --- /dev/null +++ b/prowizard/tests/bp.c @@ -0,0 +1,60 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testBP ( void ) +{ + /* test 1 */ + if ( (PW_i < 26) || ((PW_Start_Address+512)>PW_in_size) ) + { + return BAD; + } + + /* test 2 */ + PW_Start_Address = PW_i-26; + for ( PW_j=0 ; PW_j<15 ; PW_j++ ) + { + if ( in_data[32+PW_j*32+PW_Start_Address] == 0xff ) + continue; + if ( in_data[PW_j*32+63+PW_Start_Address] > 0x40 ) + return BAD; + } + + /* various shits to calculate the size */ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<15 ; PW_k++ ) + { + if ( in_data[PW_Start_Address+32+32*PW_k] != 0xff ) + PW_WholeSampleSize += (((in_data[PW_Start_Address+56+32*PW_k]*256)+in_data[PW_Start_Address+57+32*PW_k])*2); + } + PW_j = in_data[PW_Start_Address+29]; + PW_l = in_data[PW_Start_Address+30]*256 + in_data[PW_Start_Address+31]; + OutputSize = PW_WholeSampleSize + (PW_j*64); + PW_j = 0; + if ( (PW_Start_Address+525+(PW_l*16)) > PW_in_size ) + return BAD; + + for ( PW_k=0 ; PW_k PW_j ) + PW_j = (in_data[PW_Start_Address+512+PW_k*16]*256 + in_data[PW_Start_Address+513+PW_k*16]); + if ( (in_data[PW_Start_Address+516+PW_k*16]*256 + + in_data[PW_Start_Address+517+PW_k*16]) > PW_j ) + PW_j = (in_data[PW_Start_Address+516+PW_k*16]*256 + in_data[PW_Start_Address+517+PW_k*16]); + if ( (in_data[PW_Start_Address+520+PW_k*16]*256 + + in_data[PW_Start_Address+521+PW_k*16]) > PW_j ) + PW_j = (in_data[PW_Start_Address+520+PW_k*16]*256 + in_data[PW_Start_Address+521+PW_k*16]); + if ( (in_data[PW_Start_Address+524+PW_k*16]*256 + + in_data[PW_Start_Address+525+PW_k*16]) > PW_j ) + PW_j = (in_data[PW_Start_Address+524+PW_k*16]*256 + in_data[PW_Start_Address+525+PW_k*16]); + } + + return GOOD; +} diff --git a/prowizard/tests/bsifc.c b/prowizard/tests/bsifc.c new file mode 100755 index 00000000..dcb616cf --- /dev/null +++ b/prowizard/tests/bsifc.c @@ -0,0 +1,42 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testBSIFutureComposer ( void ) +{ + PW_Start_Address = PW_i; + + /* file size < 18424 */ + if ( test_1_start(PW_Start_Address + 18424) ) + { +/*printf ( "#1 (start:%ld) (number of samples:%ld)\n" , PW_Start_Address , PW_j);*/ + return BAD; + } + + if (( in_data[PW_Start_Address+17412] != 'D' ) || + ( in_data[PW_Start_Address+17413] != 'I' ) || + ( in_data[PW_Start_Address+17414] != 'G' ) || + ( in_data[PW_Start_Address+17415] != 'I' ) ) + { +/*printf ( "#2 (start:%ld) (number of samples:%ld)\n" , PW_Start_Address , PW_j);*/ + return BAD; + } + + if (( in_data[PW_Start_Address+18424] != 'D' ) || + ( in_data[PW_Start_Address+18425] != 'I' ) || + ( in_data[PW_Start_Address+18426] != 'G' ) || + ( in_data[PW_Start_Address+18427] != 'P' ) ) + { +/*printf ( "#3 (start:%ld) (number of samples:%ld)\n" , PW_Start_Address , PW_j);*/ + return BAD; + } + + return GOOD; +} + diff --git a/prowizard/tests/bytek13.c b/prowizard/tests/bytek13.c new file mode 100755 index 00000000..f717677a --- /dev/null +++ b/prowizard/tests/bytek13.c @@ -0,0 +1,90 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testByteKiller_13 ( void ) +{ + /* if ( PW_i < 135 )*/ + if ( test_1_start (135) == BAD ) + { +/*printf ( "#1\n" );*/ + return BAD; + } + + PW_Start_Address = PW_i-135; + + if ( (in_data[PW_Start_Address] != 0x41 ) || + (in_data[PW_Start_Address+1] != 0xFA ) || + (in_data[PW_Start_Address+2] != 0x00 ) || + (in_data[PW_Start_Address+3] != 0xE6 ) || + (in_data[PW_Start_Address+4] != 0x43 ) || + (in_data[PW_Start_Address+5] != 0xF9 ) || + (in_data[PW_Start_Address+10] != 0x20 ) || + (in_data[PW_Start_Address+11] != 0x18 ) || + (in_data[PW_Start_Address+12] != 0x22 ) || + (in_data[PW_Start_Address+13] != 0x18 ) || + (in_data[PW_Start_Address+14] != 0x2A ) || + (in_data[PW_Start_Address+15] != 0x18 ) || + (in_data[PW_Start_Address+16] != 0x24 ) || + (in_data[PW_Start_Address+17] != 0x49 ) || + (in_data[PW_Start_Address+18] != 0xD1 ) || + (in_data[PW_Start_Address+19] != 0xC0 ) || + (in_data[PW_Start_Address+20] != 0xD5 ) || + (in_data[PW_Start_Address+21] != 0xC1 ) || + (in_data[PW_Start_Address+22] != 0x20 ) || + (in_data[PW_Start_Address+23] != 0x20 ) || + (in_data[PW_Start_Address+24] != 0xB1 ) || + (in_data[PW_Start_Address+25] != 0x85 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+232]*256*256*256) + + (in_data[PW_Start_Address+233]*256*256) + + (in_data[PW_Start_Address+234]*256) + + in_data[PW_Start_Address+235] ); + + PW_l += 304; + + if ( PW_i >= 171 ) + { + if ( (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x03 ) || + (in_data[PW_Start_Address-33] != 0xF3 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x00 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x02 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/bytek20.c b/prowizard/tests/bytek20.c new file mode 100755 index 00000000..b47ae063 --- /dev/null +++ b/prowizard/tests/bytek20.c @@ -0,0 +1,87 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testByteKiller_20 ( void ) +{ + if ( test_1_start(127) == BAD ) + { +/*printf ( "#1\n" );*/ + return BAD; + } + PW_Start_Address = PW_i-127; + + if ( (in_data[PW_Start_Address] != 0x48 ) || + (in_data[PW_Start_Address+1] != 0xE7 ) || + (in_data[PW_Start_Address+2] != 0xFF ) || + (in_data[PW_Start_Address+3] != 0xFE ) || + (in_data[PW_Start_Address+4] != 0x4D ) || + (in_data[PW_Start_Address+5] != 0xF9 ) || + (in_data[PW_Start_Address+6] != 0x00 ) || + (in_data[PW_Start_Address+7] != 0xDF ) || + (in_data[PW_Start_Address+8] != 0xF1 ) || + (in_data[PW_Start_Address+9] != 0x80 ) || + (in_data[PW_Start_Address+10] != 0x41 ) || + (in_data[PW_Start_Address+11] != 0xFA ) || + (in_data[PW_Start_Address+12] != 0x00 ) || + (in_data[PW_Start_Address+13] != 0xBA ) || + (in_data[PW_Start_Address+14] != 0x43 ) || + (in_data[PW_Start_Address+15] != 0xF9 ) || + (in_data[PW_Start_Address+20] != 0x20 ) || + (in_data[PW_Start_Address+21] != 0x18 ) || + (in_data[PW_Start_Address+22] != 0x22 ) || + (in_data[PW_Start_Address+23] != 0x18 ) || + (in_data[PW_Start_Address+24] != 0x2A ) || + (in_data[PW_Start_Address+25] != 0x18 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+198]*256*256*256) + + (in_data[PW_Start_Address+199]*256*256) + + (in_data[PW_Start_Address+200]*256) + + in_data[PW_Start_Address+201] ); + + PW_l += 272; + + if ( PW_i >= 163 ) + { + if ( (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x03 ) || + (in_data[PW_Start_Address-33] != 0xF3 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x00 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x02 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/bytek30.c b/prowizard/tests/bytek30.c new file mode 100755 index 00000000..3c861582 --- /dev/null +++ b/prowizard/tests/bytek30.c @@ -0,0 +1,80 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testByteKiller30 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x00 ) || + (in_data[PW_Start_Address+17] != 0xDF ) || + (in_data[PW_Start_Address+18] != 0xF1 ) || + (in_data[PW_Start_Address+19] != 0x80 ) || + (in_data[PW_Start_Address+20] != 0x20 ) || + (in_data[PW_Start_Address+21] != 0x18 ) || + (in_data[PW_Start_Address+22] != 0x22 ) || + (in_data[PW_Start_Address+23] != 0x18 ) || + (in_data[PW_Start_Address+24] != 0xD1 ) || + (in_data[PW_Start_Address+25] != 0xC0 ) || + (in_data[PW_Start_Address+26] != 0x20 ) || + (in_data[PW_Start_Address+27] != 0x10 ) || + (in_data[PW_Start_Address+28] != 0x24 ) || + (in_data[PW_Start_Address+29] != 0x49 ) || + (in_data[PW_Start_Address+30] != 0xD5 ) || + (in_data[PW_Start_Address+31] != 0xC1 ) || + (in_data[PW_Start_Address+32] != 0x7A ) || + (in_data[PW_Start_Address+33] != 0x03 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+188]*256*256*256) + + (in_data[PW_Start_Address+189]*256*256) + + (in_data[PW_Start_Address+190]*256) + + in_data[PW_Start_Address+191] ); + + PW_l += 236; + + + if ( PW_i >= 32 ) + { + if ( (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x03 ) || + (in_data[PW_Start_Address-29] != 0xF3 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x01 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/bytekp10.c b/prowizard/tests/bytekp10.c new file mode 100755 index 00000000..16811fc1 --- /dev/null +++ b/prowizard/tests/bytekp10.c @@ -0,0 +1,78 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testbytekillerpro10 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+22] != 0x00 ) || + (in_data[PW_Start_Address+23] != 0x04 ) || + (in_data[PW_Start_Address+24] != 0x2A ) || + (in_data[PW_Start_Address+25] != 0x28 ) || + (in_data[PW_Start_Address+26] != 0x00 ) || + (in_data[PW_Start_Address+27] != 0x08 ) || + (in_data[PW_Start_Address+28] != 0x41 ) || + (in_data[PW_Start_Address+29] != 0xE8 ) || + (in_data[PW_Start_Address+30] != 0x00 ) || + (in_data[PW_Start_Address+31] != 0x0C ) || + (in_data[PW_Start_Address+32] != 0x24 ) || + (in_data[PW_Start_Address+33] != 0x49 ) || + (in_data[PW_Start_Address+34] != 0xD1 ) || + (in_data[PW_Start_Address+35] != 0xC0 ) || + (in_data[PW_Start_Address+36] != 0xD5 ) || + (in_data[PW_Start_Address+37] != 0xC1 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+222]*256*256*256) + + (in_data[PW_Start_Address+223]*256*256) + + (in_data[PW_Start_Address+224]*256) + + in_data[PW_Start_Address+225] ); + + PW_l += 308; + + + if ( PW_i >= 50 ) + { + if ( (in_data[PW_Start_Address-50] != 0x00 ) || + (in_data[PW_Start_Address-49] != 0x00 ) || + (in_data[PW_Start_Address-48] != 0x03 ) || + (in_data[PW_Start_Address-47] != 0xF3 ) || + (in_data[PW_Start_Address-46] != 0x00 ) || + (in_data[PW_Start_Address-45] != 0x00 ) || + (in_data[PW_Start_Address-44] != 0x00 ) || + (in_data[PW_Start_Address-43] != 0x00 ) || + (in_data[PW_Start_Address-42] != 0x00 ) || + (in_data[PW_Start_Address-41] != 0x00 ) || + (in_data[PW_Start_Address-40] != 0x00 ) || + (in_data[PW_Start_Address-39] != 0x02 ) || + (in_data[PW_Start_Address-38] != 0x00 ) || + (in_data[PW_Start_Address-37] != 0x00 ) || + (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/crmaddr.c b/prowizard/tests/crmaddr.c new file mode 100755 index 00000000..734503ff --- /dev/null +++ b/prowizard/tests/crmaddr.c @@ -0,0 +1,81 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testcrunchmaniaAddr ( void ) +{ + PW_Start_Address = PW_i - 4; + + if ( (in_data[PW_Start_Address+36] != 0x6F ) || + (in_data[PW_Start_Address+37] != 0x14 ) || + (in_data[PW_Start_Address+38] != 0x26 ) || + (in_data[PW_Start_Address+39] != 0x4A ) || + (in_data[PW_Start_Address+40] != 0x49 ) || + (in_data[PW_Start_Address+41] != 0xE9 ) || + (in_data[PW_Start_Address+46] != 0xE4 ) || + (in_data[PW_Start_Address+47] != 0x8F ) || + (in_data[PW_Start_Address+48] != 0x52 ) || + (in_data[PW_Start_Address+49] != 0x87 ) || + (in_data[PW_Start_Address+50] != 0x24 ) || + (in_data[PW_Start_Address+51] != 0x4C ) || + (in_data[PW_Start_Address+52] != 0x28 ) || + (in_data[PW_Start_Address+53] != 0xDB ) || + (in_data[PW_Start_Address+54] != 0x53 ) || + (in_data[PW_Start_Address+55] != 0x87 ) || + (in_data[PW_Start_Address+56] != 0x66 ) || + (in_data[PW_Start_Address+57] != 0xFA ) ) + { + /* should be enough :))) */ + /*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address]*256*256*256) + + (in_data[PW_Start_Address+1]*256*256) + + (in_data[PW_Start_Address+2]*256) + + in_data[PW_Start_Address+3] ); + + PW_l *= 4; + PW_l += 36; + + + if ( PW_i >= 28 ) + { + if ( (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x03 ) || + (in_data[PW_Start_Address-25] != 0xF3 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x01 ) || + (in_data[PW_Start_Address-16] != 0x00 ) || + (in_data[PW_Start_Address-15] != 0x00 ) || + (in_data[PW_Start_Address-14] != 0x00 ) || + (in_data[PW_Start_Address-13] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/crnd.c b/prowizard/tests/crnd.c new file mode 100755 index 00000000..05338dda --- /dev/null +++ b/prowizard/tests/crnd.c @@ -0,0 +1,29 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +short testCRND ( void ) +{ + PW_Start_Address = PW_i; + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+4]*256*256*256) + + (in_data[PW_Start_Address+5]*256*256) + + (in_data[PW_Start_Address+6]*256) + + in_data[PW_Start_Address+7] ); + + if ( (PW_l + PW_i) > PW_in_size ) + return BAD; + +/* testSpecialCruncherData ( 4 , in_data[(in_data[PW_i+4]*256*256*256+in_data[PW_i+5]*256*256+in_data[PW_i+6]*256+in_data[PW_i+7])-16] );*/ + testSpecialCruncherData ( 4 , in_data[PW_l-16] ); + + return GOOD; +} diff --git a/prowizard/tests/dblatn.c b/prowizard/tests/dblatn.c new file mode 100755 index 00000000..9406f1c1 --- /dev/null +++ b/prowizard/tests/dblatn.c @@ -0,0 +1,87 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testDoubleAction10 ( void ) +{ + if ( PW_i < 123 ) + { +/*printf ( "#1\n" );*/ + return BAD; + } + PW_Start_Address = PW_i-123; + + if ( (in_data[PW_Start_Address+8] != 0x47 ) || + (in_data[PW_Start_Address+9] != 0xF9 ) || + (in_data[PW_Start_Address+10] != 0x00 ) || + (in_data[PW_Start_Address+11] != 0xDF ) || + (in_data[PW_Start_Address+12] != 0xF0 ) || + (in_data[PW_Start_Address+13] != 0x00 ) || + (in_data[PW_Start_Address+14] != 0x37 ) || + (in_data[PW_Start_Address+15] != 0x7C ) || + (in_data[PW_Start_Address+18] != 0x00 ) || + (in_data[PW_Start_Address+19] != 0x9A ) || + (in_data[PW_Start_Address+26] != 0x43 ) || + (in_data[PW_Start_Address+27] != 0xF9 ) || + (in_data[PW_Start_Address+28] != 0x00 ) || + (in_data[PW_Start_Address+29] != 0xBF ) || + (in_data[PW_Start_Address+30] != 0xD1 ) || + (in_data[PW_Start_Address+31] != 0x00 ) || + (in_data[PW_Start_Address+32] != 0x12 ) || + (in_data[PW_Start_Address+33] != 0xBC ) || + (in_data[PW_Start_Address+34] != 0x00 ) || + (in_data[PW_Start_Address+35] != 0xFD ) ) + { + /* should be enough :))) */ +printf ( "#2 Start:%ld\n" , PW_Start_Address ); + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+4]*256*256*256) + + (in_data[PW_Start_Address+5]*256*256) + + (in_data[PW_Start_Address+6]*256) + + in_data[PW_Start_Address+7] ); + PW_l *= 4; + PW_l += 36; + + if ( PW_i >= 147 ) + { + if ( (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x03 ) || + (in_data[PW_Start_Address-21] != 0xF3 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) || + (in_data[PW_Start_Address-16] != 0x00 ) || + (in_data[PW_Start_Address-15] != 0x00 ) || + (in_data[PW_Start_Address-14] != 0x00 ) || + (in_data[PW_Start_Address-13] != 0x01 ) || + (in_data[PW_Start_Address-12] != 0x00 ) || + (in_data[PW_Start_Address-11] != 0x00 ) || + (in_data[PW_Start_Address-10] != 0x00 ) || + (in_data[PW_Start_Address-9] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + + + return GOOD; + /* PW_l is the size of the pack */ +} diff --git a/prowizard/tests/defja32p.c b/prowizard/tests/defja32p.c new file mode 100755 index 00000000..631b6374 --- /dev/null +++ b/prowizard/tests/defja32p.c @@ -0,0 +1,72 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testDefjam32pro ( void ) +{ + + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x3D ) || + (in_data[PW_Start_Address+17] != 0x40 ) || + (in_data[PW_Start_Address+18] != 0x00 ) || + (in_data[PW_Start_Address+19] != 0x9A ) || + (in_data[PW_Start_Address+20] != 0x3D ) || + (in_data[PW_Start_Address+21] != 0x40 ) || + (in_data[PW_Start_Address+22] != 0x00 ) || + (in_data[PW_Start_Address+23] != 0x9C ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+180]*256*256*256) + + (in_data[PW_Start_Address+181]*256*256) + + (in_data[PW_Start_Address+182]*256) + + in_data[PW_Start_Address+183] ); + + PW_l += 796; + + if ( PW_i >= 32 ) + { + if ( (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x03 ) || + (in_data[PW_Start_Address-29] != 0xF3 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x01 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + + return GOOD; + /* PW_l is the size of the pack */ + +} + diff --git a/prowizard/tests/defjam32.c b/prowizard/tests/defjam32.c new file mode 100755 index 00000000..c993b460 --- /dev/null +++ b/prowizard/tests/defjam32.c @@ -0,0 +1,90 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testDefjam32 ( void ) +{ + PW_Start_Address = PW_i-2; + + if ( (in_data[PW_Start_Address+12] != 0x28 ) || + (in_data[PW_Start_Address+13] != 0x7A ) || + (in_data[PW_Start_Address+14] != 0x01 ) || + (in_data[PW_Start_Address+15] != 0x52 ) || + (in_data[PW_Start_Address+16] != 0x20 ) || + (in_data[PW_Start_Address+17] != 0x4C ) || + (in_data[PW_Start_Address+18] != 0xD1 ) || + (in_data[PW_Start_Address+19] != 0xFC ) || + (in_data[PW_Start_Address+24] != 0xB3 ) || + (in_data[PW_Start_Address+25] != 0xCC ) || + (in_data[PW_Start_Address+26] != 0x6E ) || + (in_data[PW_Start_Address+27] != 0x08 ) || + (in_data[PW_Start_Address+28] != 0x20 ) || + (in_data[PW_Start_Address+29] != 0x49 ) || + (in_data[PW_Start_Address+30] != 0xD1 ) || + (in_data[PW_Start_Address+31] != 0xFA ) || + (in_data[PW_Start_Address+32] != 0xFF ) || + (in_data[PW_Start_Address+33] != 0xF4 ) || + (in_data[PW_Start_Address+34] != 0x60 ) || + (in_data[PW_Start_Address+35] != 0x06 ) || + (in_data[PW_Start_Address+36] != 0x18 ) || + (in_data[PW_Start_Address+37] != 0xD9 ) || + (in_data[PW_Start_Address+38] != 0xB9 ) || + (in_data[PW_Start_Address+39] != 0xC8 ) || + (in_data[PW_Start_Address+40] != 0x6D ) || + (in_data[PW_Start_Address+41] != 0xFA ) || + (in_data[PW_Start_Address+42] != 0x43 ) || + (in_data[PW_Start_Address+43] != 0xF9 ) || + (in_data[PW_Start_Address+44] != 0x00 ) ) + { + /* should be enough :))) */ + /*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+20]*256*256*256) + + (in_data[PW_Start_Address+21]*256*256) + + (in_data[PW_Start_Address+22]*256) + + in_data[PW_Start_Address+23] ); + + PW_l += 692; + + if ( PW_i >= 32 ) + { + if ( (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x03 ) || + (in_data[PW_Start_Address-29] != 0xF3 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x01 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/di.c b/prowizard/tests/di.c new file mode 100755 index 00000000..6b7ae435 --- /dev/null +++ b/prowizard/tests/di.c @@ -0,0 +1,138 @@ +/* (3rd of April 2000) + * bugs pointed out by Thomas Neumann .. thx :) + * (May 2002) + * added test_smps() +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testDI ( void ) +{ + /* test #1 */ + if ( PW_i < 17 ) + { + return BAD; + } + + /* test #2 (number of sample) */ + PW_Start_Address = PW_i-17; + PW_k = (in_data[PW_Start_Address]*256)+in_data[PW_Start_Address+1]; + if ( PW_k > 31 ) + { +/*printf ( "#1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* test #3 (finetunes and whole sample size) */ + /* PW_k = number of samples */ + PW_WholeSampleSize = 0; + PW_l = 0; + for ( PW_j=0 ; PW_j 0xffff) || + (PW_m > 0xffff) || + (PW_n > 0xffff) ) + { +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( test_smps(PW_o, PW_m, PW_n, in_data[PW_Start_Address+17+PW_j*8], in_data[PW_Start_Address+16+PW_j*8] ) == BAD ) + return BAD; + /* gets total size of samples */ + PW_WholeSampleSize += PW_o; + } + if ( PW_WholeSampleSize <= 2 ) + { +/*printf ( "#2,4\n" );*/ + return BAD; + } + + /* test #4 (addresses of pattern in file ... possible ?) */ + /* PW_WholeSampleSize is the whole sample size */ + /* PW_k is still the number of sample */ + PW_m = PW_k; + PW_j = (in_data[PW_Start_Address+2]*256*256*256) + +(in_data[PW_Start_Address+3]*256*256) + +(in_data[PW_Start_Address+4]*256) + +in_data[PW_Start_Address+5]; + /* PW_j is the address of pattern table now */ + PW_k = (in_data[PW_Start_Address+6]*256*256*256) + +(in_data[PW_Start_Address+7]*256*256) + +(in_data[PW_Start_Address+8]*256) + +in_data[PW_Start_Address+9]; + /* PW_k is the address of the pattern data */ + PW_l = (in_data[PW_Start_Address+10]*256*256*256) + +(in_data[PW_Start_Address+11]*256*256) + +(in_data[PW_Start_Address+12]*256) + +in_data[PW_Start_Address+13]; + /* PW_l is the address of the sample data */ + if ( (PW_k <= PW_j)||(PW_l<=PW_j)||(PW_l<=PW_k) ) + { +/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_k-PW_j) > 128 ) + { +/*printf ( "#3,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_k > PW_in_size)||(PW_l>PW_in_size)||(PW_j>PW_in_size) ) + { +/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* test #4,1 :) */ + PW_m *= 8; + PW_m += 2; + if ( PW_j < PW_m ) + { +/*printf ( "#4 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* test #5 */ + if ( (PW_k + PW_Start_Address) > PW_in_size ) + { +/*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* test pattern table reliability */ + for ( PW_m=PW_j ; PW_m<(PW_k-1) ; PW_m++ ) + { + if ( in_data[PW_Start_Address + PW_m] > 0x80 ) + { +/*printf ( "#6 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + /* test #6 ($FF at the end of pattern list ?) */ + if ( in_data[PW_Start_Address+PW_k-1] != 0xFF ) + { +/*printf ( "#6,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* test #7 (addres of sample data > $FFFF ? ) */ + /* PW_l is still the address of the sample data */ + if ( PW_l > 65535 ) + { +/*printf ( "#7 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + return GOOD; +} + diff --git a/prowizard/tests/digibst.c b/prowizard/tests/digibst.c new file mode 100755 index 00000000..7bf7b7aa --- /dev/null +++ b/prowizard/tests/digibst.c @@ -0,0 +1,78 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testDigiBooster17 ( void ) +{ + PW_Start_Address = PW_i; + + /* get nbr of pattern saved */ + PW_m = in_data[PW_Start_Address+46]; /*this value is -1 !*/ + + /* test if there are pattern in pattern list > number of pattern saved */ + for ( PW_j=0 ; PW_j<128 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+48+PW_j] > PW_m ) + { +/*printf ( "#1 (Start:%ld) (max pat:%ld) (pat wrong:%d)\n" + , PW_Start_Address , PW_m , in_data[PW_Start_Address+48+PW_j] );*/ + return BAD; + } + } + + /* samples > $FFFFFF ) */ + /* PW_m is the number of pattern saved -1 */ + PW_WholeSampleSize = 0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + PW_o = ((in_data[PW_Start_Address+176+(PW_j*4)]*256*256*256)+ + (in_data[PW_Start_Address+177+(PW_j*4)]*256*256)+ + (in_data[PW_Start_Address+178+(PW_j*4)]*256)+ + in_data[PW_Start_Address+179+(PW_j*4)] ); + if ( PW_o > 0xFFFFFF ) + { +/*printf ( "#2 (Start:%ld) (sample:%ld) (len:%ld)\n" + , PW_Start_Address , PW_j , PW_o );*/ + return BAD; + } + /* volumes */ + if ( in_data[PW_Start_Address+548+PW_j] > 0x40 ) + { +/*printf ( "#3 (Start:%ld) (sample:%ld) (vol:%d)\n" + , PW_Start_Address , PW_j , in_data[PW_Start_Address+548+PW_j] );*/ + return BAD; + } + PW_WholeSampleSize += PW_o; + } + + + /* pattern sizes */ + /* PW_m is the number of pattern saved -1 */ + /* PW_WholeSampleSize is the whole sample size :) */ + PW_k = 1572; /* first pattern addy */ + for ( PW_j=0 ; PW_j<=PW_m ; PW_j++ ) + { + PW_o = (in_data[PW_Start_Address+PW_k]*256)+in_data[PW_Start_Address+PW_k+1]; + /* size < 64 ? */ + if ( PW_o < 64 ) + { +/*printf ( "#4 (Start:%ld) (pat size:%ld) (at:%ld)\n" , PW_Start_Address , PW_o , PW_k );*/ + return BAD; + } + PW_k += PW_o+2; + } + + + /* PW_m is the number of pattern saved -1 */ + /* PW_WholeSampleSize is the whole sample size :) */ + /* PW_k is the module size saves the samples data */ + + return GOOD; +} + diff --git a/prowizard/tests/eureka.c b/prowizard/tests/eureka.c new file mode 100755 index 00000000..3e46afb9 --- /dev/null +++ b/prowizard/tests/eureka.c @@ -0,0 +1,157 @@ +/* (27 dec 2001) + * added some checks to prevent readings outside of input file (in test 1) + * (May 2002) + * added test_smps() +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testEUREKA ( void ) +{ + /* test 1 */ + if ( (PW_i < 45) || ((PW_Start_Address+950)>=PW_in_size) ) + { +/*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + + /* test 2 */ + PW_Start_Address = PW_i-45; + PW_j = in_data[PW_Start_Address+950]; + if ( (PW_j==0) || (PW_j>127) ) + { +/*printf ( "#2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test #3 finetunes & volumes */ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + PW_o = (in_data[PW_Start_Address+42+PW_k*30]*256) + in_data[PW_Start_Address+43+PW_k*30]; + PW_m = (in_data[PW_Start_Address+46+PW_k*30]*256) + in_data[PW_Start_Address+47+PW_k*30]; + PW_n = (in_data[PW_Start_Address+48+PW_k*30]*256) + in_data[PW_Start_Address+49+PW_k*30]; + PW_o *= 2; + PW_m *= 2; + PW_n *= 2; + if ( (PW_o > 0xffff) || + (PW_m > 0xffff) || + (PW_n > 0xffff) ) + { +/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( test_smps ( PW_o+2, PW_m, PW_n, in_data[PW_Start_Address+45+PW_k*30], in_data[PW_Start_Address+44+PW_k*30] ) == BAD) + return BAD; + PW_WholeSampleSize += PW_o; + } + + + /* test 4 */ + PW_l = (in_data[PW_Start_Address+1080]*256*256*256) + +(in_data[PW_Start_Address+1081]*256*256) + +(in_data[PW_Start_Address+1082]*256) + +in_data[PW_Start_Address+1083]; + if ( (PW_l+PW_Start_Address) > PW_in_size ) + { +/*printf ( "#4 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_l < 1084 ) + { +/*printf ( "#4,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_m=0; + /* pattern list */ + for ( PW_k=0 ; PW_k PW_m ) + PW_m = PW_n; + if ( PW_n > 127 ) + { +/*printf ( "#4,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + PW_k += 2; /* to be sure .. */ + while ( PW_k != 128 ) + { + if ( in_data[PW_Start_Address+952+PW_k] != 0 ) + { +/*printf ( "#4,3 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_k += 1; + } + PW_m += 1; + /* PW_m is the highest pattern number */ + + + /* test #5 */ + /* PW_j is still the size if the pattern table */ + /* PW_l is still the address of the sample data */ + /* PW_m is the highest pattern number */ + PW_n=0; + PW_j=999999l; + for ( PW_k=0 ; PW_k<(PW_m*4) ; PW_k++ ) + { + PW_o = (in_data[PW_Start_Address+PW_k*2+1084]*256)+in_data[PW_Start_Address+PW_k*2+1085]; + if ( (PW_o > PW_l) || (PW_o < 1084) ) + { +/*printf ( "#5 (Start:%ld)(PW_k:%ld)(PW_j:%ld)(PW_l:%ld)\n" , PW_Start_Address,PW_k,PW_j,PW_l );*/ + return BAD; + } + if ( PW_o > PW_n ) + PW_n = PW_o; + if ( PW_o < PW_j ) + PW_j = PW_o; + } + /* PW_o is the highest track address */ + /* PW_j is the lowest track address */ + + /* test track datas */ + /* last track wont be tested ... */ + for ( PW_k=PW_j ; PW_k 0x13 ) + { +/*printf ( "#6,1 Start:%ld (at:%x)\n" , PW_Start_Address , PW_k );*/ + return BAD; + } + PW_k += 3; + continue; + } + } + + return GOOD; +} diff --git a/prowizard/tests/fc13.c b/prowizard/tests/fc13.c new file mode 100755 index 00000000..f9714555 --- /dev/null +++ b/prowizard/tests/fc13.c @@ -0,0 +1,67 @@ +/* + * update 18 mar 2003 + * - fake test replaced by good test :) -> more FC13 found +*/ + + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testFC13 ( void ) +{ + PW_Start_Address = PW_i; + + /* file size < 113 */ + if ( (PW_in_size - PW_Start_Address) < 113 ) + { + /*printf ( "#1 (start:%ld) (size:%ld)\n" , PW_Start_Address , PW_in_size-PW_Start_Address);*/ + return BAD; + } + + /* get addy of 1st sample */ + PW_m = (( in_data[PW_Start_Address+32]*256*256*256)+ + ( in_data[PW_Start_Address+33]*256*256)+ + ( in_data[PW_Start_Address+34]*256)+ + in_data[PW_Start_Address+35] ); + + /* test in-size again */ + if ( PW_Start_Address+PW_m > PW_in_size ) + { + /*printf ( "#2 (start:%ld) (1st smp addy:%ld)\n" , PW_Start_Address , PW_m);*/ + return BAD; + } + + /* test various addresses */ + PW_j = (( in_data[PW_Start_Address+8] *256*256*256)+ + ( in_data[PW_Start_Address+9] *256*256)+ + ( in_data[PW_Start_Address+10]*256)+ + in_data[PW_Start_Address+11] ); + + PW_k = (( in_data[PW_Start_Address+16]*256*256*256)+ + ( in_data[PW_Start_Address+17]*256*256)+ + ( in_data[PW_Start_Address+18]*256)+ + in_data[PW_Start_Address+19] ); + + PW_l = (( in_data[PW_Start_Address+24]*256*256*256)+ + ( in_data[PW_Start_Address+25]*256*256)+ + ( in_data[PW_Start_Address+26]*256)+ + in_data[PW_Start_Address+27] ); + + /* test in-size again */ + if ( (PW_j > PW_in_size) || (PW_k > PW_in_size) || (PW_l > PW_in_size) ) + { + /*printf ( "#2 (start:%ld) (PW_j:%ld) (PW_k:%ld) (PW_l:%ld)\n" , PW_Start_Address , PW_j, PW_k, PW_l);*/ + return BAD; + } + + /* PW_m is the addy of the 1st sample */ + return GOOD; +} + diff --git a/prowizard/tests/fc14.c b/prowizard/tests/fc14.c new file mode 100755 index 00000000..480dc93a --- /dev/null +++ b/prowizard/tests/fc14.c @@ -0,0 +1,67 @@ +/* + * update 18 mar 2003 + * - fake test replaced by good test :) -> more FC14 found +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testFC14 ( void ) +{ + PW_Start_Address = PW_i; + + /* file size < 193 */ + if ( (PW_in_size - PW_Start_Address) < 193 ) + { +/*printf ( "#1 (start:%ld) (size:%ld)\n" , PW_Start_Address , PW_in_size-PW_Start_Address);*/ + return BAD; + } + + /* get 1st sample addy */ + PW_m = (( in_data[PW_Start_Address+32]*256*256*256)+ + ( in_data[PW_Start_Address+33]*256*256)+ + ( in_data[PW_Start_Address+34]*256)+ + in_data[PW_Start_Address+35] ); + + /* test in-size again */ + if ( PW_Start_Address+PW_m > PW_in_size ) + { +/*printf ( "#2 (start:%ld) (1st smp addy:%ld)\n" , PW_Start_Address , PW_m);*/ + return BAD; + } + + /* test various addresses */ + PW_j = (( in_data[PW_Start_Address+8] *256*256*256)+ + ( in_data[PW_Start_Address+9] *256*256)+ + ( in_data[PW_Start_Address+10]*256)+ + in_data[PW_Start_Address+11] ); + + PW_k = (( in_data[PW_Start_Address+16]*256*256*256)+ + ( in_data[PW_Start_Address+17]*256*256)+ + ( in_data[PW_Start_Address+18]*256)+ + in_data[PW_Start_Address+19] ); + + PW_l = (( in_data[PW_Start_Address+36]*256*256*256)+ + ( in_data[PW_Start_Address+37]*256*256)+ + ( in_data[PW_Start_Address+38]*256)+ + in_data[PW_Start_Address+39] ); + + /* test in-size again */ + if ( (PW_j > PW_in_size) || (PW_k > PW_in_size) || (PW_l > PW_in_size) ) + { +/*printf ( "#2 (start:%ld) (PW_j:%ld) (PW_k:%ld) (PW_l:%ld)\n" + , PW_Start_Address , PW_j, PW_k, PW_l);*/ + return BAD; + } + + /* PW_l is 1st waveform addy */ + return GOOD; +} + diff --git a/prowizard/tests/fc_m.c b/prowizard/tests/fc_m.c new file mode 100755 index 00000000..d723b550 --- /dev/null +++ b/prowizard/tests/fc_m.c @@ -0,0 +1,37 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testFC_M ( void ) +{ + /* test 1 */ + PW_Start_Address = PW_i; + if ( in_data[PW_Start_Address + 4] != 0x01 ) + { + return BAD; + } + + /* test 2 */ + if ( in_data[PW_Start_Address + 5] != 0x00 ) + { + return BAD; + } + + /* test 3 */ + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+37+8*PW_j] > 0x40 ) + { + return BAD; + } + } + + return GOOD; +} + diff --git a/prowizard/tests/fuchs.c b/prowizard/tests/fuchs.c new file mode 100755 index 00000000..b3724bbf --- /dev/null +++ b/prowizard/tests/fuchs.c @@ -0,0 +1,98 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +short testFuchsTracker ( void ) +{ + /* test #1 */ + if ( PW_i<192 ) + { +/*printf ( "#1\n" );*/ + return BAD; + } + PW_Start_Address = PW_i-192; + + /* all sample size */ + PW_j = ((in_data[PW_Start_Address+10]*256*256*256)+ + (in_data[PW_Start_Address+11]*256*256)+ + (in_data[PW_Start_Address+12]*256)+ + in_data[PW_Start_Address+13] ); + if ( (PW_j <= 2) || (PW_j >= (65535*16)) ) + { +/*printf ( "#1,1\n" );*/ + return BAD; + } + + + + /* samples descriptions */ + PW_m=0; + for ( PW_k = 0 ; PW_k < 16 ; PW_k ++ ) + { + /* size */ + PW_o = (in_data[PW_Start_Address+PW_k*2+14]*256)+in_data[PW_Start_Address+PW_k*2+15]; + /* loop start */ + PW_n = (in_data[PW_Start_Address+PW_k*2+78]*256)+in_data[PW_Start_Address+PW_k*2+79]; + + /* volumes */ + if ( in_data[PW_Start_Address+46+PW_k*2] > 0x40 ) + { +/*printf ( "#2\n" );*/ + return BAD; + } + /* size < loop start ? */ + if ( PW_o < PW_n ) + { +/*printf ( "#2,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_m += PW_o; + } + + /* PW_m is the size of all samples (in descriptions) */ + /* PW_j is the sample data sizes (header) */ + /* size<2 or size > header sample size ? */ + if ( (PW_m <= 2) || (PW_m > PW_j) ) + { +/*printf ( "#2,2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* get highest pattern number in pattern list */ + PW_k=0; + for ( PW_j=0 ; PW_j<40 ; PW_j++ ) + { + PW_n = in_data[PW_Start_Address+PW_j*2+113]; + if ( PW_n > 40 ) + { +/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_n > PW_k ) + PW_k = PW_n; + } + + /* PW_m is the size of all samples (in descriptions) */ + /* PW_k is the highest pattern data -1 */ + /* input file not long enough ? */ + PW_k += 1; + PW_k *= 1024; + if ( (PW_k+200) > PW_in_size ) + { +/*printf ( "#4 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* PW_m is the size of all samples (in descriptions) */ + /* PW_k is the pattern data size */ + + return GOOD; +} + diff --git a/prowizard/tests/fuzzac.c b/prowizard/tests/fuzzac.c new file mode 100755 index 00000000..1635850a --- /dev/null +++ b/prowizard/tests/fuzzac.c @@ -0,0 +1,53 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testFUZZAC ( void ) +{ + PW_Start_Address = PW_i; + + /* test finetune */ + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + if ( in_data[PW_Start_Address+72+PW_k*68] > 0x0F ) + { + return BAD; + } + } + + /* test volumes */ + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + if ( in_data[PW_Start_Address+73+PW_k*68] > 0x40 ) + { + return BAD; + } + } + + /* test sample sizes */ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + PW_j = (in_data[PW_Start_Address+66+PW_k*68]*256)+in_data[PW_Start_Address+67+PW_k*68]; + if ( PW_j > 0x8000 ) + { + return BAD; + } + PW_WholeSampleSize += (PW_j * 2); + } + + /* test size of pattern list */ + if ( in_data[PW_Start_Address+2114] == 0x00 ) + { + return BAD; + } + + return GOOD; +} + diff --git a/prowizard/tests/gmc.c b/prowizard/tests/gmc.c new file mode 100755 index 00000000..84566462 --- /dev/null +++ b/prowizard/tests/gmc.c @@ -0,0 +1,147 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testGMC ( void ) +{ + /* test #1 */ + if ( (PW_i<7) || ((PW_Start_Address+444)>PW_in_size) ) + { +/*printf ( "#1\n" );*/ + return BAD; + } + PW_Start_Address = PW_i-7; + + /* samples descriptions */ + PW_WholeSampleSize=0; + PW_j=0; + for ( PW_k = 0 ; PW_k < 15 ; PW_k ++ ) + { + PW_o = (in_data[PW_Start_Address+16*PW_k+4]*256)+in_data[PW_Start_Address+16*PW_k+5]; + PW_n = (in_data[PW_Start_Address+16*PW_k+12]*256)+in_data[PW_Start_Address+16*PW_k+13]; + PW_o *= 2; + /* volumes */ + if ( in_data[PW_Start_Address + 7 + (16*PW_k)] > 0x40 ) + { +/*printf ( "#2\n" );*/ + return BAD; + } + /* size */ + if ( PW_o > 0xFFFF ) + { +/*printf ( "#2,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_n > PW_o ) + { +/*printf ( "#2,2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_WholeSampleSize += PW_o; + if ( PW_o != 0 ) + PW_j = PW_k+1; + } + if ( PW_WholeSampleSize <= 4 ) + { +/*printf ( "#2,3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_j is the highest not null sample */ + + /* pattern table size */ + if ( ( in_data[PW_Start_Address+243] > 0x64 ) || + ( in_data[PW_Start_Address+243] == 0x00 ) ) + { + return BAD; + } + + /* pattern order table */ + PW_l=0; + for ( PW_n=0 ; PW_n<100 ; PW_n++ ) + { + PW_k = ((in_data[PW_Start_Address+244+PW_n*2]*256)+ + in_data[PW_Start_Address+245+PW_n*2]); + if ( ((PW_k/1024)*1024) != PW_k ) + { +/*printf ( "#4 Start:%ld (PW_k:%ld)\n" , PW_Start_Address , PW_k);*/ + return BAD; + } + PW_l = ((PW_k/1024)>PW_l) ? PW_k/1024 : PW_l; + } + PW_l += 1; + /* PW_l is the number of pattern */ + if ( (PW_l == 1) || (PW_l >0x64) ) + { + return BAD; + } + + /* test pattern data */ + PW_o = in_data[PW_Start_Address+243]; + PW_m = 0; + for ( PW_k=0 ; PW_k 0x03 ) || + ( (in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0x0f) >= 0x90 )) + { +/*printf ( "#5,0 Start:%ld (PW_k:%ld)\n" , PW_Start_Address , PW_k);*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0xf0)>>4) > PW_j ) + { +/*printf ( "#5,1 Start:%ld (PW_j:%ld) (where:%ld) (value:%x)\n" + , PW_Start_Address , PW_j , PW_Start_Address+444+PW_k*1024+PW_n*4+2 + , ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0xf0)>>4) );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0x0f) == 3) && + (in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+3] > 0x40) ) + { +/*printf ( "#5,2 Start:%ld (PW_j:%ld)\n" , PW_Start_Address , PW_j);*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0x0f) == 4) && + (in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+3] > 0x63) ) + { +/*printf ( "#5,3 Start:%ld (PW_j:%ld)\n" , PW_Start_Address , PW_j);*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0x0f) == 5) && + (in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+3] > PW_o+1) ) + { +/*printf ( "#5,4 Start:%ld (effect:5)(PW_o:%ld)(4th note byte:%x)\n" , PW_Start_Address , PW_j , in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+3]);*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0x0f) == 6) && + (in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+3] >= 0x02) ) + { +/*printf ( "#5,5 Start:%ld (at:%ld)\n" , PW_Start_Address , PW_Start_Address+444+PW_k*1024+PW_n*4+3 );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+2]&0x0f) == 7) && + (in_data[PW_Start_Address+444+PW_k*1024+PW_n*4+3] >= 0x02) ) + { +/*printf ( "#5,6 Start:%ld (at:%ld)\n" , PW_Start_Address , PW_Start_Address+444+PW_k*1024+PW_n*4+3 );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+444+PW_k*1024+PW_n*4]&0x0f) > 0x00) || (in_data[PW_Start_Address+445+PW_k*1024+PW_n*4] > 0x00) ) + PW_m = 1; + } + } + if ( PW_m == 0 ) + { + /* only empty notes */ + return BAD; + } + /* PW_WholeSampleSize is the whole sample size */ + + return GOOD; +} + diff --git a/prowizard/tests/gnpl.c b/prowizard/tests/gnpl.c new file mode 100755 index 00000000..449e43ff --- /dev/null +++ b/prowizard/tests/gnpl.c @@ -0,0 +1,45 @@ +/* 22 mar 2003 + * GnuPlayer.c + * based on XtC's description ! ... good job ! :). + * +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testGnuPlayer ( void ) +{ + /* test #1 */ + if ( PW_i < 0x92 ) + { + /*printf ( "#0 (start:%ld) \n", PW_i - 0x92 );*/ + return BAD; + } + + /* test #2 smp size and loop start */ + PW_WholeSampleSize = 0; + PW_o = 0; /* will hold the number of non-null samples */ + PW_Start_Address = PW_i - 0x92; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + PW_j = (in_data[PW_Start_Address+20+PW_k*4]*256) + in_data[PW_Start_Address+21+PW_k*4]; + PW_l = (in_data[PW_Start_Address+22+PW_k*4]*256) + in_data[PW_Start_Address+23+PW_k*4]; + if ( PW_l > (PW_j+1) ) + { + /*printf ( "#1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_j != 0 ) PW_o += 1; + PW_WholeSampleSize += PW_j; + } + + return GOOD; +} + diff --git a/prowizard/tests/gpmo.c b/prowizard/tests/gpmo.c new file mode 100755 index 00000000..1d0da952 --- /dev/null +++ b/prowizard/tests/gpmo.c @@ -0,0 +1,107 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testGPMO ( void ) +{ + /* test 1 */ + if ( PW_i < 1080 ) + { + /*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + /*if ( PW_Start_Address == 0)printf ("yo");*/ + + /* test 2 */ + PW_Start_Address = PW_i-1080; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + /* size */ + PW_j = (((in_data[PW_Start_Address+42+PW_k*30]*256)+in_data[PW_Start_Address+43+PW_k*30])*2); + /* loop start */ + PW_m = (((in_data[PW_Start_Address+46+PW_k*30]*256)+in_data[PW_Start_Address+47+PW_k*30])*2); + /* loop size */ + PW_n = (((in_data[PW_Start_Address+48+PW_k*30]*256)+in_data[PW_Start_Address+49+PW_k*30])*2); + + if ( test_smps (PW_j,PW_m,PW_n,in_data[PW_Start_Address+45+PW_k*30]/2,in_data[PW_Start_Address+44+PW_k*30]) == BAD ) + { + /* printf ( "#2 (Start:%ld)(siz:%ld)(lstart:%ld)(lsiz:%ld)\n" , PW_Start_Address,PW_j,PW_m,PW_n );*/ + return BAD; + } + } + + /*if ( PW_Start_Address == 0)printf ("yo");*/ + + /* test #4 pattern list size */ + PW_l = in_data[PW_Start_Address+950]; + if ( (PW_l>127) || (PW_l==0) ) + { + /* printf ( "#4,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /*if ( PW_Start_Address == 0)printf ("yo");*/ + + /* PW_l holds the size of the pattern list */ + PW_k=0; + for ( PW_j=0 ; PW_j<128 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+952+PW_j] > PW_k ) + PW_k = in_data[PW_Start_Address+952+PW_j]; + if ( in_data[PW_Start_Address+952+PW_j] > 127 ) + { + /* printf ( "#4,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + /*if ( PW_Start_Address == 0)printf ("yo");*/ + + /* PW_k holds the highest pattern number */ + /* test last patterns of the pattern list = 0 ? */ + PW_j += 2; /* found some obscure ptk :( */ + while ( PW_j < 128 ) + { + if ( in_data[PW_Start_Address+952+PW_j] > 0x7f ) + { + /* printf ( "#4,2 (Start:%ld) (PW_j:%ld) (at:%ld)\n" , PW_Start_Address,PW_j ,PW_Start_Address+952+PW_j );*/ + return BAD; + } + PW_j += 1; + } + /* PW_k is the number of pattern in the file (-1) */ + PW_k += 1; + + /* if ( PW_Start_Address == 0)printf ("yo");*/ + + /* test #5 pattern data ... */ + if ( ((PW_k*1024)+1084+PW_Start_Address) > PW_in_size ) + { + /* printf ( "#5,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + for ( PW_j=0 ; PW_j<(PW_k*256) ; PW_j++ ) + { + /* sample > 1f or pitch > 358 ? */ + if ( in_data[PW_Start_Address+1084+PW_j*4] > 0x13 ) + { + /* printf ( "#5.1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_l = ((in_data[PW_Start_Address+1084+PW_j*4]&0x0f)*256)+in_data[PW_Start_Address+1085+PW_j*4]; + if ( (PW_l>0) && (PW_l<0x1C) ) + { + /* printf ( "#5,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + return GOOD; +} + diff --git a/prowizard/tests/heatseek.c b/prowizard/tests/heatseek.c new file mode 100755 index 00000000..d1472493 --- /dev/null +++ b/prowizard/tests/heatseek.c @@ -0,0 +1,151 @@ +/* (May 2002) + * added test_smps() +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testHEATSEEKER ( void ) +{ + int nbr_notes=0; + + if ( (PW_i < 3) || ((PW_i+375)>=PW_in_size)) + { + return BAD; + } + PW_Start_Address = PW_i-3; + + /* size of the pattern table */ + if ( (in_data[PW_Start_Address+248] > 0x7f) || + (in_data[PW_Start_Address+248] == 0x00) ) + { + return BAD; + } + + /* test noisetracker byte */ + if ( in_data[PW_Start_Address+249] != 0x7f ) + { + return BAD; + } + + /* test samples */ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + /* size */ + PW_j = (in_data[PW_Start_Address+PW_k*8]*256)+in_data[PW_Start_Address+1+PW_k*8]; + /* loop start */ + PW_m = (in_data[PW_Start_Address+PW_k*8+4]*256)+in_data[PW_Start_Address+5+PW_k*8]; + /* loop size */ + PW_n = (in_data[PW_Start_Address+PW_k*8+6]*256)+in_data[PW_Start_Address+7+PW_k*8]; + PW_j *= 2; + PW_m *= 2; + PW_n *= 2; + if ( test_smps(PW_j, PW_m, PW_n, in_data[PW_Start_Address+3+PW_k*8], in_data[PW_Start_Address+2+PW_k*8] ) == BAD ) + return BAD; + if ( (PW_j > 0xFFFF) || + (PW_m > 0xFFFF) || + (PW_n > 0xFFFF) ) + { +/*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_WholeSampleSize += PW_j; + } + if ( PW_WholeSampleSize <= 4 ) + { +/*printf ( "#5,3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* test pattern table */ + PW_l = 0; + for ( PW_j=0 ; PW_j<128 ; PW_j ++ ) + { + if ( in_data[PW_Start_Address+250+PW_j] > 0x7f ) + { + return BAD; + } + if ( in_data[PW_Start_Address+250+PW_j] > PW_l ) + PW_l = in_data[PW_Start_Address+250+PW_j]; + } + /* PW_l = highest pattern number */ + if ( (PW_Start_Address + (PW_l*16) + 378) > PW_in_size ) + { + /* PW_l*16 is the minimum size of all patterns */ + return BAD; + } + + /* test notes */ + PW_k=0; + PW_j=0; + for ( PW_m=0 ; PW_m<=PW_l ; PW_m++ ) + { + for ( PW_n=0 ; PW_n<4 ; PW_n++ ) + { + for ( PW_o=0 ; PW_o<64 ; PW_o++ ) + { + switch (in_data[PW_Start_Address+378+PW_j]&0xE0) + { + case 0x00: + if ( ((in_data[PW_Start_Address+378+PW_j]&0x0F)>0x03) || (((in_data[PW_Start_Address+378+PW_j]&0x0F)==0x00) && (in_data[PW_Start_Address+379+PW_j]<0x71) && (in_data[PW_Start_Address+379+PW_j]!=0x00))) + { + /*printf ( "#6) start:%ld (%x) (at:%x) (PW_l:%ld)\n",PW_Start_Address, in_data[PW_Start_Address+378+PW_j], PW_Start_Address+378+PW_j,PW_l );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+380+PW_j]&0x0f) == 0x0d) && (in_data[PW_Start_Address+381+PW_j]>0x64)) + { + /* printf ( "#6,5 Start:%ld cmd D arg : %x\n", PW_Start_Address, in_data[PW_Start_Address+381+PW_j] );*/ + return BAD; + } + PW_k += 4; + PW_j += 4; + if ( ((in_data[PW_Start_Address+378+PW_j]&0x0f)!=0x00) || (in_data[PW_Start_Address+379+PW_j]!=0x00)) + nbr_notes = 1; + break; + case 0x80: + if (( in_data[PW_Start_Address+379+PW_j]!=0x00 ) || ( in_data[PW_Start_Address+380+PW_j]!=0x00 )) + { +/*printf ( "#7) start:%ld (%x) (at:%x)\n" +,PW_Start_Address, in_data[PW_Start_Address+379+PW_j], PW_Start_Address+379+PW_j );*/ + return BAD; + } + PW_o += in_data[PW_Start_Address+381+PW_j]; + PW_j += 4; + PW_k += 4; + break; + case 0xC0: + if ( in_data[PW_Start_Address+379+PW_j]!=0x00 ) + { +/*printf ( "#7) start:%ld (%x) (at:%x)\n" +,PW_Start_Address, in_data[PW_Start_Address+379+PW_j], PW_Start_Address+379+PW_j );*/ + return BAD; + } + PW_o = 100; + PW_j += 4; + PW_k += 4; + break; + default: + return BAD; + break; + } + } + } + } + if ( nbr_notes == 0 ) + { + /* only empty notes */ + return BAD; + } + + /* PW_k is the size of the pattern data */ + /* PW_WholeSampleSize is the size of the sample data */ + return GOOD; +} diff --git a/prowizard/tests/hqc2.c b/prowizard/tests/hqc2.c new file mode 100755 index 00000000..cf45bba4 --- /dev/null +++ b/prowizard/tests/hqc2.c @@ -0,0 +1,79 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testHQCCruncher2 ( void ) +{ + PW_Start_Address = PW_i - 64; + + if ( (in_data[PW_Start_Address+1776] != 0x02 ) || + (in_data[PW_Start_Address+1777] != 0x4D ) || + (in_data[PW_Start_Address+1778] != 0x45 ) || + (in_data[PW_Start_Address+1779] != 0x58 ) || + (in_data[PW_Start_Address+1780] != 0x00 ) || + (in_data[PW_Start_Address+1781] != 0x00 ) || + (in_data[PW_Start_Address+1782] != 0x03 ) || + (in_data[PW_Start_Address+1783] != 0xEC ) || + (in_data[PW_Start_Address+1784] != 0x00 ) || + (in_data[PW_Start_Address+1785] != 0x00 ) || + (in_data[PW_Start_Address+1786] != 0x00 ) || + (in_data[PW_Start_Address+1787] != 0x00 ) || + (in_data[PW_Start_Address+1788] != 0x00 ) || + (in_data[PW_Start_Address+1789] != 0x00 ) || + (in_data[PW_Start_Address+1790] != 0x03 ) || + (in_data[PW_Start_Address+1791] != 0xF2 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+1808]*256*256*256) + + (in_data[PW_Start_Address+1809]*256*256) + + (in_data[PW_Start_Address+1810]*256) + + in_data[PW_Start_Address+1811] ); + + PW_l *= 4; + PW_l += 1816; + + +/* if ( PW_i >= 50 ) */ +/* { */ +/* if ( (in_data[PW_Start_Address-50] != 0x00 ) || */ +/* (in_data[PW_Start_Address-49] != 0x00 ) || */ +/* (in_data[PW_Start_Address-48] != 0x03 ) || */ +/* (in_data[PW_Start_Address-47] != 0xF3 ) || */ +/* (in_data[PW_Start_Address-46] != 0x00 ) || */ +/* (in_data[PW_Start_Address-45] != 0x00 ) || */ +/* (in_data[PW_Start_Address-44] != 0x00 ) || */ +/* (in_data[PW_Start_Address-43] != 0x00 ) || */ +/* (in_data[PW_Start_Address-42] != 0x00 ) || */ +/* (in_data[PW_Start_Address-41] != 0x00 ) || */ +/* (in_data[PW_Start_Address-40] != 0x00 ) || */ +/* (in_data[PW_Start_Address-39] != 0x02 ) || */ +/* (in_data[PW_Start_Address-38] != 0x00 ) || */ +/* (in_data[PW_Start_Address-37] != 0x00 ) || */ +/* (in_data[PW_Start_Address-36] != 0x00 ) || */ +/* (in_data[PW_Start_Address-35] != 0x00 ) ) */ +/* { */ +/* Amiga_EXE_Header = BAD; */ +/* } */ +/* else */ + Amiga_EXE_Header = GOOD; +/* } */ +/* else */ +/* Amiga_EXE_Header = BAD; */ + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/hrt.c b/prowizard/tests/hrt.c new file mode 100755 index 00000000..988db15a --- /dev/null +++ b/prowizard/tests/hrt.c @@ -0,0 +1,32 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testHRT ( void ) +{ + /* test 1 */ + if ( PW_i < 1080 ) + { + return BAD; + } + + /* test 2 */ + PW_Start_Address = PW_i-1080; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + if ( in_data[45+PW_j*30+PW_Start_Address] > 0x40 ) + { + return BAD; + } + } + + return GOOD; +} + + diff --git a/prowizard/tests/jamcrack.c b/prowizard/tests/jamcrack.c new file mode 100755 index 00000000..090c3b5d --- /dev/null +++ b/prowizard/tests/jamcrack.c @@ -0,0 +1,71 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testJamCracker ( void ) +{ + PW_Start_Address = PW_i; + + /* number of samples */ + PW_j = in_data[PW_Start_Address+5]; + if ( (PW_j == 0) || (PW_j > 0x1f) ) + { +/*printf ( "#1 (start:%ld) (number of samples:%ld)\n" , PW_Start_Address , PW_j);*/ + return BAD; + } + + /* sample sizes */ + /* PW_j is the number of sample */ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_kPW_in_size) ) + { + return BAD; + } + + /* test 2 */ + PW_Start_Address = PW_i-952; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + /* volume > 64 ? */ + if ( in_data[PW_Start_Address+47+PW_j*30] > 0x40 ) + { + return BAD; + } + /* finetune > 15 ? */ + if ( in_data[PW_Start_Address+46+PW_j*30] > 0x0f ) + { + return BAD; + } + } + + return GOOD; +} + diff --git a/prowizard/tests/ksm.c b/prowizard/tests/ksm.c new file mode 100755 index 00000000..ed7961d9 --- /dev/null +++ b/prowizard/tests/ksm.c @@ -0,0 +1,60 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testKSM ( void ) +{ + PW_Start_Address = PW_i; + if ( (PW_Start_Address + 1536) > PW_in_size) + return BAD; + + /* test "a" */ + if ( in_data[PW_Start_Address+15] != 'a' ) + return BAD; + + /* test volumes */ + for ( PW_k=0 ; PW_k<15 ; PW_k++ ) + if ( in_data[PW_Start_Address+54+PW_k*32] > 0x40 ) + return BAD; + + /* test tracks data */ + /* first, get the highest track number .. */ + PW_j = 0; + for ( PW_k=0 ; PW_k<1024 ; PW_k ++ ) + { + if ( in_data[PW_Start_Address+PW_k+512] == 0xFF ) + break; + if ( in_data[PW_Start_Address+PW_k+512] > PW_j ) + PW_j = in_data[PW_Start_Address+PW_k+512]; + } + if ( PW_k == 1024 ) + { +/*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_j == 0 ) + { +/*printf ( "#6 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* so, now, PW_j is the highest track number (first is 00h !!) */ + /* real test on tracks data starts now */ + /* first, test if we don't get out of the file */ + if ( (PW_Start_Address + 1536 + PW_j*192 + 64*3) > PW_in_size ) + return BAD; + /* now testing tracks */ + for ( PW_k = 0 ; PW_k <= PW_j ; PW_k++ ) + for ( PW_l=0 ; PW_l < 64 ; PW_l++ ) + if ( in_data[PW_Start_Address+1536+PW_k*192+PW_l*3] > 0x24 ) + return BAD; + + /* PW_j is still the highest track number */ + return GOOD; +} + diff --git a/prowizard/tests/maxpac12.c b/prowizard/tests/maxpac12.c new file mode 100755 index 00000000..d57dc356 --- /dev/null +++ b/prowizard/tests/maxpac12.c @@ -0,0 +1,84 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +short testMaxPacker12 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x01 ) || + (in_data[PW_Start_Address+17] != 0x70 ) || + (in_data[PW_Start_Address+18] != 0xD7 ) || + (in_data[PW_Start_Address+19] != 0xFA ) || + (in_data[PW_Start_Address+20] != 0x01 ) || + (in_data[PW_Start_Address+21] != 0x70 ) || + (in_data[PW_Start_Address+22] != 0x49 ) || + (in_data[PW_Start_Address+23] != 0xFA ) || + (in_data[PW_Start_Address+24] != 0x01 ) || + (in_data[PW_Start_Address+25] != 0x60 ) || + (in_data[PW_Start_Address+26] != 0x34 ) || + (in_data[PW_Start_Address+27] != 0x1C ) || + (in_data[PW_Start_Address+28] != 0x12 ) || + (in_data[PW_Start_Address+29] != 0x1C ) || + (in_data[PW_Start_Address+30] != 0x10 ) || + (in_data[PW_Start_Address+31] != 0x1C ) || + (in_data[PW_Start_Address+32] != 0x2C ) || + (in_data[PW_Start_Address+33] != 0x4B ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+384]*256*256*256) + + (in_data[PW_Start_Address+385]*256*256) + + (in_data[PW_Start_Address+386]*256) + + in_data[PW_Start_Address+387] ); + + PW_l += 429; + PW_m = (PW_l/4)*4; + if ( PW_m != PW_l ) + PW_l = PW_m + 4; + + + if ( PW_i >= 32 ) + { + if ( (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x03 ) || + (in_data[PW_Start_Address-29] != 0xF3 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x01 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/mc30addr.c b/prowizard/tests/mc30addr.c new file mode 100755 index 00000000..a8cd4f02 --- /dev/null +++ b/prowizard/tests/mc30addr.c @@ -0,0 +1,82 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testMasterCruncher30addr ( void ) +{ + + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0xD3 ) || + (in_data[PW_Start_Address+17] != 0xC9 ) || + (in_data[PW_Start_Address+18] != 0x58 ) || + (in_data[PW_Start_Address+19] != 0x89 ) || + (in_data[PW_Start_Address+20] != 0x2B ) || + (in_data[PW_Start_Address+21] != 0x49 ) || + (in_data[PW_Start_Address+124]!= 0xE3 ) || + (in_data[PW_Start_Address+125]!= 0x10 ) || + (in_data[PW_Start_Address+126]!= 0xE3 ) || + (in_data[PW_Start_Address+127]!= 0x51 ) || + (in_data[PW_Start_Address+128]!= 0x51 ) || + (in_data[PW_Start_Address+129]!= 0xCA ) || + (in_data[PW_Start_Address+130]!= 0xFF ) || + (in_data[PW_Start_Address+131]!= 0xF4 ) || + (in_data[PW_Start_Address+132]!= 0x4A ) || + (in_data[PW_Start_Address+133]!= 0x43 ) || + (in_data[PW_Start_Address+134]!= 0x67 ) || + (in_data[PW_Start_Address+135]!= 0x06 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+428]*256*256*256) + + (in_data[PW_Start_Address+429]*256*256) + + (in_data[PW_Start_Address+430]*256) + + in_data[PW_Start_Address+431] ); + + PW_l *= 4; + PW_l += 472; + + if ( PW_i >= 36 ) + { + if ( (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x03 ) || + (in_data[PW_Start_Address-33] != 0xF3 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x00 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x02 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/mcobj.c b/prowizard/tests/mcobj.c new file mode 100755 index 00000000..9ebb7d7e --- /dev/null +++ b/prowizard/tests/mcobj.c @@ -0,0 +1,75 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testMegaCruncherObj ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+12] != 0x4C ) || + (in_data[PW_Start_Address+13] != 0xDD ) || + (in_data[PW_Start_Address+14] != 0x00 ) || + (in_data[PW_Start_Address+15] != 0x03 ) || + (in_data[PW_Start_Address+16] != 0x4E ) || + (in_data[PW_Start_Address+17] != 0xAE ) || + (in_data[PW_Start_Address+18] != 0xFF ) || + (in_data[PW_Start_Address+19] != 0x3A ) || + (in_data[PW_Start_Address+20] != 0x4A ) || + (in_data[PW_Start_Address+21] != 0x80 ) || + (in_data[PW_Start_Address+22] != 0x67 ) || + (in_data[PW_Start_Address+23] != 0x30 ) || + (in_data[PW_Start_Address+24] != 0x41 ) || + (in_data[PW_Start_Address+25] != 0xFA ) || + (in_data[PW_Start_Address+26] != 0x00 ) || + (in_data[PW_Start_Address+27] != 0x0E ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+466]*256*256*256) + + (in_data[PW_Start_Address+467]*256*256) + + (in_data[PW_Start_Address+468]*256) + + in_data[PW_Start_Address+469] ); + PW_l += 532; + + if ( PW_i >= 36 ) + { + if ( (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x03 ) || + (in_data[PW_Start_Address-33] != 0xF3 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x00 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x02 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/mcrun10.c b/prowizard/tests/mcrun10.c new file mode 100755 index 00000000..8cb030e1 --- /dev/null +++ b/prowizard/tests/mcrun10.c @@ -0,0 +1,76 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testMegaCruncher10 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x22 ) || + (in_data[PW_Start_Address+17] != 0x6B ) || + (in_data[PW_Start_Address+18] != 0x00 ) || + (in_data[PW_Start_Address+19] != 0x04 ) || + (in_data[PW_Start_Address+20] != 0x24 ) || + (in_data[PW_Start_Address+21] != 0x60 ) || + (in_data[PW_Start_Address+22] != 0xD5 ) || + (in_data[PW_Start_Address+23] != 0xC9 ) || + (in_data[PW_Start_Address+24] != 0x20 ) || + (in_data[PW_Start_Address+25] != 0x20 ) || + (in_data[PW_Start_Address+26] != 0x72 ) || + (in_data[PW_Start_Address+27] != 0x03 ) || + (in_data[PW_Start_Address+28] != 0x61 ) || + (in_data[PW_Start_Address+29] != 0x00 ) || + (in_data[PW_Start_Address+30] != 0x01 ) || + (in_data[PW_Start_Address+31] != 0x02 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+312]*256*256*256) + + (in_data[PW_Start_Address+313]*256*256) + + (in_data[PW_Start_Address+314]*256) + + in_data[PW_Start_Address+315] ); + + PW_l += 376; + + if ( PW_i >= 36 ) + { + if ( (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x03 ) || + (in_data[PW_Start_Address-33] != 0xF3 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x00 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x02 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/mcrun12.c b/prowizard/tests/mcrun12.c new file mode 100755 index 00000000..36142a3e --- /dev/null +++ b/prowizard/tests/mcrun12.c @@ -0,0 +1,76 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testMegaCruncher12 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x22 ) || + (in_data[PW_Start_Address+17] != 0x6B ) || + (in_data[PW_Start_Address+18] != 0x00 ) || + (in_data[PW_Start_Address+19] != 0x04 ) || + (in_data[PW_Start_Address+20] != 0x24 ) || + (in_data[PW_Start_Address+21] != 0x60 ) || + (in_data[PW_Start_Address+22] != 0xD5 ) || + (in_data[PW_Start_Address+23] != 0xC9 ) || + (in_data[PW_Start_Address+24] != 0x20 ) || + (in_data[PW_Start_Address+25] != 0x20 ) || + (in_data[PW_Start_Address+26] != 0x72 ) || + (in_data[PW_Start_Address+27] != 0x03 ) || + (in_data[PW_Start_Address+28] != 0x61 ) || + (in_data[PW_Start_Address+29] != 0x00 ) || + (in_data[PW_Start_Address+30] != 0x01 ) || + (in_data[PW_Start_Address+31] != 0x06 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+316]*256*256*256) + + (in_data[PW_Start_Address+317]*256*256) + + (in_data[PW_Start_Address+318]*256) + + in_data[PW_Start_Address+319] ); + + PW_l += 380; + + if ( PW_i >= 36 ) + { + if ( (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x03 ) || + (in_data[PW_Start_Address-33] != 0xF3 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x00 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x02 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/mmd0.c b/prowizard/tests/mmd0.c new file mode 100755 index 00000000..be9d3f60 --- /dev/null +++ b/prowizard/tests/mmd0.c @@ -0,0 +1,68 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +/* valid for MMD0 & MMD1 */ +short testMMD0 ( void ) +{ + PW_Start_Address = PW_i; + if ( (PW_Start_Address + 52) > PW_in_size ) + return BAD; + + /* get the 'should be' module size */ + PW_k = ((in_data[PW_Start_Address+4]*256*256*256)+ + (in_data[PW_Start_Address+5]*256*256)+ + (in_data[PW_Start_Address+6]*256)+ + in_data[PW_Start_Address+7] ); + + /* 52 : size of header */ + if ( PW_k < 52 ) + { +/*printf ( "#1 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test flag byte : 1 or 0 */ + PW_j = in_data[PW_Start_Address+20]; + if ( PW_j > 1 ) + { +/*printf ( "#2 (start:%ld) (flag:%ld)\n" , PW_Start_Address,PW_j );*/ + return BAD; + } + + /* get struct MMD* addy */ + PW_j = ((in_data[PW_Start_Address+8] *256*256*256)+ + (in_data[PW_Start_Address+9] *256*256)+ + (in_data[PW_Start_Address+10]*256)+ + in_data[PW_Start_Address+11] ); + if ( (PW_j < 52) || (PW_j > PW_k) ) + { +/*printf ( "#3 (start:%ld) (siz:%ld) (struct addy:%ld)\n" , PW_Start_Address,PW_k,PW_j );*/ + return BAD; + } + + /* test 'reserved' bytes which should be set to 0x00 */ + if ( (in_data[PW_Start_Address+21] != 0x00) || + (in_data[PW_Start_Address+22] != 0x00) || + (in_data[PW_Start_Address+23] != 0x00)) + { +/*printf ( "#4 (start:%ld) (21:%x) (22:%x) (23:%x)\n" + , PW_Start_Address + , in_data[PW_Start_Address+21] + , in_data[PW_Start_Address+22] + , in_data[PW_Start_Address+23]);*/ + return BAD; + } + + /* stop it for now ... few/cheap tests here, I agree .. */ + /* PW_k is the module size */ + + return GOOD; +} + diff --git a/prowizard/tests/mp.c b/prowizard/tests/mp.c new file mode 100755 index 00000000..db3ad1ea --- /dev/null +++ b/prowizard/tests/mp.c @@ -0,0 +1,177 @@ +/* (May 2002) + * added test_smps() +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testMP_noID ( void ) +{ + /* test #1 */ + if ( (PW_i < 3) || ((PW_i+375)>PW_in_size)) + { + return BAD; + } + + /* test #2 */ + PW_Start_Address = PW_i-3; + PW_l=0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + /* size */ + PW_k = (((in_data[PW_Start_Address+8*PW_j]*256)+in_data[PW_Start_Address+1+8*PW_j])*2); + /* loop start */ + PW_m = (((in_data[PW_Start_Address+4+8*PW_j]*256)+in_data[PW_Start_Address+5+8*PW_j])*2); + /* loop size */ + PW_n = (((in_data[PW_Start_Address+6+8*PW_j]*256)+in_data[PW_Start_Address+7+8*PW_j])*2); + PW_WholeSampleSize += PW_k; + + if ( test_smps(PW_k, PW_m, PW_n, in_data[PW_Start_Address+3+8*PW_j], in_data[PW_Start_Address+2+8*PW_j] ) == BAD ) + { + /* printf ( "#2 Start:%ld (siz:%ld)(lstart:%ld)(lsiz:%ld)\n", PW_Start_Address,PW_k,PW_m,PW_n );*/ + return BAD; + } + } + if ( PW_WholeSampleSize <= 2 ) + { + /*printf( "#2,5 (start:%ld)\n",PW_Start_Address );*/ + return BAD; + } + + /* test #3 */ + PW_l = in_data[PW_Start_Address+248]; + if ( (PW_l > 0x7f) || (PW_l == 0x00) ) + { + /*printf( "#3 (Start:%ld)\n",PW_Start_Address );*/ + return BAD; + } + + /* test #4 */ + /* PW_l contains the size of the pattern list */ + PW_k = 0; + for ( PW_j=0 ; PW_j<128 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+250+PW_j] > PW_k ) + PW_k = in_data[PW_Start_Address+250+PW_j]; + if ( in_data[PW_Start_Address+250+PW_j] > 0x7f ) + { + /*printf( "#4 (Start:%ld)\n",PW_Start_Address );*/ + return BAD; + } + if ( PW_j > PW_l+3 ) + if (in_data[PW_Start_Address+250+PW_j] != 0x00) + { + /*printf( "#4,1 (Start:%ld)\n",PW_Start_Address );*/ + return BAD; + } + } + PW_k += 1; + + /* test #5 ptk notes .. gosh ! (testing all patterns !) */ + /* PW_k contains the number of pattern saved */ + /* PW_WholeSampleSize is the whole sample size */ + PW_m = 0; + if ( PW_Start_Address + 379 + ((PW_k*256)*4) > PW_in_size ) + { + return BAD; + } + for ( PW_j=0 ; PW_j<((256*PW_k)-4) ; PW_j++ ) + { + PW_l = in_data[PW_Start_Address+378+PW_j*4+4]; + if ( PW_l > 19 ) /* 0x13 */ + { + /*printf( "#5 (Start:%ld)(byte0:%x)(Where:%ld)\n",PW_Start_Address,in_data[PW_Start_Address+378+PW_j*4],PW_Start_Address+378+PW_j*4 );*/ + return BAD; + } + PW_l = in_data[PW_Start_Address+378+PW_j*4]&0x0f; + PW_l *= 256; + PW_l += in_data[PW_Start_Address+379+PW_j*4]; + PW_n = in_data[PW_Start_Address+380+PW_j*4]>>4; + if ( PW_l != 0 ) + PW_m = 1; + if ( PW_n != 0 ) + PW_o = 1; + if ( (PW_l > 0) && (PW_l<0x71) ) + { + /*printf ( "#5,1 (Start:%ld)(where:%ld)(note:%ld)\n" , PW_Start_Address,PW_Start_Address+378+PW_j*4, PW_l );*/ + return BAD; + } + } + if ( (PW_m == 0) || (PW_o == 0) ) + { + /* no note ... odd */ + /*printf ("#5,2 (Start:%ld)\n",PW_Start_Address);*/ + return BAD; + } + + /* test #6 (loopStart+LoopSize > Sample ? ) */ + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + PW_k = (((in_data[PW_Start_Address+PW_j*8]*256)+in_data[PW_Start_Address+1+PW_j*8])*2); + PW_l = (((in_data[PW_Start_Address+4+PW_j*8]*256)+in_data[PW_Start_Address+5+PW_j*8])*2) + +(((in_data[PW_Start_Address+6+PW_j*8]*256)+in_data[PW_Start_Address+7+PW_j*8])*2); + if ( PW_l > (PW_k+2) ) + { + /*printf( "#6 (Start:%ld)\n",PW_Start_Address );*/ + return BAD; + } + } + + return GOOD; +} + + +short testMP_withID ( void ) +{ + /* test #1 */ + PW_Start_Address = PW_i; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+6+8*PW_j] > 0x0f ) + { + return BAD; + } + } + + /* test #2 */ + PW_l = in_data[PW_Start_Address+252]; + if ( (PW_l > 0x7f) || (PW_l == 0x00) ) + { + return BAD; + } + + /* test #4 */ + PW_k = 0; + for ( PW_j=0 ; PW_j<128 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+254+PW_j] > PW_k ) + PW_k = in_data[PW_Start_Address+254+PW_j]; + if ( in_data[PW_Start_Address+254+PW_j] > 0x7f ) + { + return BAD; + } + } + PW_k += 1; + + /* test #5 ptk notes .. gosh ! (testing all patterns !) */ + /* PW_k contains the number of pattern saved */ + for ( PW_j=0 ; PW_j<(256*PW_k) ; PW_j++ ) + { + PW_l = in_data[PW_Start_Address+382+PW_j*4]; + if ( PW_l > 19 ) /* 0x13 */ + { + return BAD; + } + } + + return GOOD; +} + + diff --git a/prowizard/tests/newtron.c b/prowizard/tests/newtron.c new file mode 100755 index 00000000..2c18e241 --- /dev/null +++ b/prowizard/tests/newtron.c @@ -0,0 +1,110 @@ +/* + * newtron.c ... 9 mar 2003 +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testNewtron ( void ) +{ + /* test #1 */ + if ( (PW_i < 7) || ((PW_i+373+1024+2)>PW_in_size)) + { + return BAD; + } + + /* test #1.5 */ + if ( in_data[PW_i-6] != 0x00 ) + { + return BAD; + } + + /* test #2 */ + PW_Start_Address = PW_i-7; + PW_l=0; + PW_WholeSampleSize = 0; + for ( PW_j=0 ; PW_j<31 ; PW_j+=1 ) + { + /* size */ + PW_k = (((in_data[PW_Start_Address+4+8*PW_j]*256)+in_data[PW_Start_Address+5+8*PW_j])*2); + /* loop start */ + PW_m = (((in_data[PW_Start_Address+8+8*PW_j]*256)+in_data[PW_Start_Address+9+8*PW_j])*2); + /* loop size */ + PW_n = (((in_data[PW_Start_Address+10+8*PW_j]*256)+in_data[PW_Start_Address+11+8*PW_j])*2); + PW_WholeSampleSize += PW_k; + + if ( test_smps(PW_k, PW_m, PW_n, in_data[PW_Start_Address+7+8*PW_j], in_data[PW_Start_Address+6+8*PW_j] ) == BAD ) + { + /* printf ( "#2 (start:%ld),(siz:%ld)(loopstart:%ld)(lsiz:%ld)(vol:%d)(fine:%d)(where:%ld)(PW_j:%ld)\n" + ,PW_Start_Address,PW_k,PW_m,PW_n, in_data[PW_Start_Address+7+8*PW_j], in_data[PW_Start_Address+6+8*PW_j] + ,PW_j*8+4+PW_Start_Address,PW_j );*/ + return BAD; + } + } + + if ( PW_WholeSampleSize <= 2 ) + { + /* printf( "#3\n" );*/ + return BAD; + } + + /* test #4 */ + PW_l = in_data[PW_Start_Address]; + if ( (PW_l > 0x7f) || (PW_l == 0x00) ) + { + /* printf( "#4 (start:%ld)(indata[0]:%x)\n",PW_Start_Address,in_data[PW_Start_Address] );*/ + return BAD; + } + + /* test #5 */ + /* PW_l contains the size of the pattern list */ + PW_k = 0; + for ( PW_j=0 ; PW_j<128 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+252+PW_j] > PW_k ) + PW_k = in_data[PW_Start_Address+252+PW_j]; + if ( in_data[PW_Start_Address+252+PW_j] > 0x7f ) + { + /*printf( "#5\n" );*/ + return BAD; + } + } + PW_k += 1; + + /* #6 */ + if ( ((PW_k*1024) + 380) != ((in_data[PW_Start_Address+2]*256)+in_data[PW_Start_Address+3]+4)) + { + return BAD; + } + + /* test #7 ptk notes .. gosh ! (testing all patterns !) */ + /* PW_k contains the number of pattern saved */ + /* PW_WholeSampleSize is the whole sample size */ + for ( PW_j=0 ; PW_j<(256*PW_k) ; PW_j++ ) + { + PW_l = in_data[PW_Start_Address+380+PW_j*4]; + if ( PW_l > 19 ) /* 0x13 */ + { + /*printf( "#7,0\n" );*/ + return BAD; + } + PW_m = in_data[PW_Start_Address+380+PW_j*4]&0x0f; + PW_m *= 256; + PW_m += in_data[PW_Start_Address+381+PW_j*4]; + if ( (PW_m > 0) && (PW_m<0x71) ) + { + /*printf ( "#7,1 (Start:%ld)(where:%ld)(note:%ld)\n" , PW_Start_Address,PW_Start_Address+380+PW_j*4, PW_WholeSampleSize );*/ + return BAD; + } + } + + return GOOD; +} + diff --git a/prowizard/tests/nfh.c b/prowizard/tests/nfh.c new file mode 100755 index 00000000..d8edfbde --- /dev/null +++ b/prowizard/tests/nfh.c @@ -0,0 +1,87 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +/* Noise from Heaven Chipdisk (21 oct 2001) by Iris */ + +short testNFH ( void ) +{ + /* test 1 */ + if ( PW_i < 1080 ) + { +/*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + + /* test 2 */ + PW_Start_Address = PW_i-1080; + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + /* size */ + PW_j = (((in_data[PW_Start_Address+42+PW_k*30]*256)+in_data[PW_Start_Address+43+PW_k*30])*2); + /* loop start */ + PW_m = (((in_data[PW_Start_Address+46+PW_k*30]*256)+in_data[PW_Start_Address+47+PW_k*30])*2); + /* loop size */ + PW_n = (((in_data[PW_Start_Address+48+PW_k*30]*256)+in_data[PW_Start_Address+49+PW_k*30])*2); + + if ( test_smps(PW_j*2, PW_m, PW_n, in_data[PW_Start_Address+45+30*PW_k], in_data[PW_Start_Address+44+30*PW_k] ) == BAD ) + { + /*printf ( "start : %ld\n", PW_Start_Address );*/ + return BAD; + } + + PW_WholeSampleSize += PW_j; + } + + /* test #4 pattern list size */ + PW_l = in_data[PW_Start_Address+950]; + if ( (PW_l>127) || (PW_l==0) ) + { + /*printf ( "#4,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_l holds the size of the pattern list */ + PW_k=0; + for ( PW_j=0 ; PW_j<128 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+952+PW_j] > PW_k ) + PW_k = in_data[PW_Start_Address+952+PW_j]; + if ( in_data[PW_Start_Address+952+PW_j] > 127 ) + { + /*printf ( "#4,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + /* PW_k holds the highest pattern number */ + /* test last patterns of the pattern list = 0 ? */ + PW_j += 2; /* found some obscure ptk :( */ + while ( PW_j < 128 ) + { + if ( in_data[PW_Start_Address+952+PW_j] > 0x7f ) + { + /*printf ( "#4,2 (Start:%ld) (PW_j:%ld) (at:%ld)\n" , PW_Start_Address,PW_j ,PW_Start_Address+952+PW_j );*/ + return BAD; + } + PW_j += 1; + } + /* PW_k is the number of pattern in the file (-1) */ + PW_k += 1; + + + /* test #5 pattern data ... */ + if ( ((PW_k*1024)+1084+PW_Start_Address) > PW_in_size ) + { +/*printf ( "#5,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + return GOOD; +} + diff --git a/prowizard/tests/noiserun.c b/prowizard/tests/noiserun.c new file mode 100755 index 00000000..66405570 --- /dev/null +++ b/prowizard/tests/noiserun.c @@ -0,0 +1,107 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testNoiserunner ( void ) +{ + /* test 1 */ + if ( PW_i < 1080 ) + { + return BAD; + } + + /* test 2 */ + PW_Start_Address = PW_i-1080; + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + PW_j = (((in_data[PW_Start_Address+6+PW_k*16]*256)+in_data[PW_Start_Address+7+PW_k*16])*2); + if ( PW_j > 0xFFFF ) + { +/*printf ( "#2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* volumes */ + if ( in_data[PW_Start_Address+1+PW_k*16] > 0x40 ) + { +/*printf ( "#3 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_WholeSampleSize += PW_j; + } + if ( PW_WholeSampleSize == 0 ) + { + return BAD; + } + /* PW_WholeSampleSize is the size of all the sample data */ + + /* test #4 pattern list size */ + PW_l = in_data[PW_Start_Address+950]; + if ( (PW_l>127) || (PW_l==0) ) + { +/*printf ( "#4,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_l holds the size of the pattern list */ + PW_k=0; + for ( PW_j=0 ; PW_j PW_k ) + PW_k = in_data[PW_Start_Address+952+PW_j]; + if ( in_data[PW_Start_Address+952+PW_j] > 127 ) + { +/*printf ( "#4,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + /* PW_k holds the highest pattern number */ + /* test last patterns of the pattern list = 0 ? */ + while ( PW_j != 128 ) + { + if ( in_data[PW_Start_Address+952+PW_j] != 0 ) + { +/*printf ( "#4,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_j += 1; + } + /* PW_k is the number of pattern in the file (-1) */ + PW_k += 1; + + /* test if we read outside of the file */ + if ( (PW_Start_Address+PW_k*256) > PW_in_size ) + return BAD; + + /* test #5 pattern data ... */ + for ( PW_j=0 ; PW_j<(PW_k*256) ; PW_j++ ) + { + /* note > 48h ? */ + if ( in_data[PW_Start_Address+1086+PW_j*4] > 0x48 ) + { +/*printf ( "#5.1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_l = in_data[PW_Start_Address+1087+PW_j*4]; + if ( ((PW_l/8)*8) != PW_l ) + { +/*printf ( "#5,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_l = in_data[PW_Start_Address+1084+PW_j*4]; + if ( ((PW_l/4)*4) != PW_l ) + { +/*printf ( "#5,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + return GOOD; +} + + diff --git a/prowizard/tests/npd1.c b/prowizard/tests/npd1.c new file mode 100755 index 00000000..0cff774d --- /dev/null +++ b/prowizard/tests/npd1.c @@ -0,0 +1,144 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testNoisepacker1 ( void ) +{ + if ( PW_i < 15 ) + { + return BAD; + } + PW_Start_Address = PW_i-15; + + /* size of the pattern table */ + PW_j = (in_data[PW_Start_Address+2]*256)+in_data[PW_Start_Address+3]; + if ( (((PW_j/2)*2) != PW_j) || (PW_j == 0) ) + { +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_j is the size of the pattern list (*2) */ + + /* test nbr of samples */ + if ( (in_data[PW_Start_Address+1]&0x0f) != 0x0C ) + { +/*printf ( "#3,0 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_l = ((in_data[PW_Start_Address]<<4)&0xf0)|((in_data[PW_Start_Address+1]>>4)&0x0f); + if ( (PW_l > 0x1F) || (PW_l == 0) || ((PW_Start_Address+PW_j+8+PW_l*8)>PW_in_size)) + { +/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_l is the number of samples */ + + /* test volumes */ + for ( PW_k=0 ; PW_k 0x40 ) + { +/*printf ( "#3,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test sample sizes */ + PW_WholeSampleSize=0; + for ( PW_k=0 ; PW_k 0xFFFF) || + (PW_m > 0xFFFF) || + (PW_n > 0xFFFF) ) + { +/*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_m + PW_n) > (PW_o+2) ) + { +/*printf ( "#5,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_n != 0) && (PW_m == 0) ) + { +/*printf ( "#5,2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_WholeSampleSize += PW_o; + } + if ( PW_WholeSampleSize <= 4 ) + { +/*printf ( "#5,3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + + /* small shit to gain some vars */ + PW_l *= 16; + PW_l += 8; + PW_l += 4; + /* PW_l is now the size of the header 'til the end of sample descriptions */ + if (PW_l+PW_Start_Address > PW_in_size ) + { + return BAD; + } + + + /* test pattern table */ + PW_n=0; + for ( PW_k=0 ; PW_k PW_n ) + PW_n = PW_m; + } + PW_l += PW_j; + PW_l += PW_n; + PW_l += 8; /*paske on a que l'address du dernier pattern .. */ + /* PW_l is now the size of the header 'til the end of the track list */ + /* PW_j is now available for use :) */ + + /* test track data size */ + PW_k = (in_data[PW_Start_Address+6]*256)+in_data[PW_Start_Address+7]; + if ( (PW_k < 192) || (((PW_k/192)*192) != PW_k) ) + { + /*printf ( "#7 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* test notes */ + for ( PW_m=0 ; PW_m < PW_k ; PW_m+=3 ) + { + if ( PW_Start_Address + PW_l + PW_m > PW_in_size ) + { +/*printf ( "#8,0 Start:%ld\n", PW_Start_Address );*/ + return BAD; + } + if ( in_data[PW_Start_Address+PW_l+PW_m] > 0x49 ) + { + /*printf ( "#8 Start:%ld (at %x)(PW_k:%x)(PW_l:%x)(PW_m:%x)\n" , PW_Start_Address,PW_Start_Address+PW_l+PW_m,PW_k,PW_l,PW_m );*/ + return BAD; + } + } + + /* PW_WholeSampleSize is the size of the sample data */ + /* PW_l is the size of the header 'til the track datas */ + /* PW_k is the size of the track datas */ + return GOOD; +} diff --git a/prowizard/tests/npd2.c b/prowizard/tests/npd2.c new file mode 100755 index 00000000..9809f113 --- /dev/null +++ b/prowizard/tests/npd2.c @@ -0,0 +1,164 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testNoisepacker2 ( void ) +{ + if ( PW_i < 15 ) + { + return BAD; + } + PW_Start_Address = PW_i-15; + + /* size of the pattern table */ + PW_j = (in_data[PW_Start_Address+2]*256)+in_data[PW_Start_Address+3]; + if ( (((PW_j/2)*2) != PW_j) || (PW_j == 0) ) + { +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_j is the size of the pattern list (*2) */ + + /* test nbr of samples */ + if ( (in_data[PW_Start_Address+1]&0x0f) != 0x0C ) + { +/*printf ( "#3,0 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_l = ((in_data[PW_Start_Address]<<4)&0xf0)|((in_data[PW_Start_Address+1]>>4)&0x0f); + if ( (PW_l > 0x1F) || (PW_l == 0) || ((PW_Start_Address+8+PW_j+PW_l*8)>PW_in_size)) + { +/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_l is the number of samples */ + + /* test volumes */ + for ( PW_k=0 ; PW_k 0x40 ) + { + return BAD; + } + } + + /* test sample sizes */ + PW_WholeSampleSize=0; + for ( PW_k=0 ; PW_k 0xFFFF) || + (PW_m > 0xFFFF) || + (PW_n > 0xFFFF) ) + { +/*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_m + PW_n) > (PW_o+2) ) + { +/*printf ( "#5,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_n != 0) && (PW_m == 0) ) + { +/*printf ( "#5,2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_WholeSampleSize += PW_o; + } + if ( PW_WholeSampleSize <= 4 ) + { +/*printf ( "#5,3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + + /* small shit to gain some vars */ + PW_l *= 16; + PW_l += 8; + PW_l += 4; + /* PW_l is now the size of the header 'til the end of sample descriptions */ + if ( PW_l+PW_Start_Address > PW_in_size ) + { +/* printf ( "#5,4 Start:%ld\n", PW_Start_Address);*/ + return BAD; + } + + + /* test pattern table */ + PW_n=0; + for ( PW_k=0 ; PW_k PW_n ) + PW_n = PW_m; + } + PW_l += PW_j; + PW_l += PW_n; + PW_l += 8; /*paske on a que l'address du dernier pattern .. */ + /* PW_l is now the size of the header 'til the end of the track list */ + /* PW_n is the highest pattern number (*8) */ + /* PW_j is now available for use :) */ + if ( PW_l+PW_Start_Address>PW_in_size) + { +/* printf ( "#6,1 Start:%ld\n", PW_Start_Address);*/ + return BAD; + } + + /* test track data size */ + PW_k = (in_data[PW_Start_Address+6]*256)+in_data[PW_Start_Address+7]; + if ( (PW_k < 192) || (((PW_k/192)*192) != PW_k) ) + { +/*printf ( "#7 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* test notes */ + PW_j = ((in_data[PW_Start_Address]<<4)&0xf0)|((in_data[PW_Start_Address+1]>>4)&0x0f); + for ( PW_m=0 ; PW_m < PW_k ; PW_m+=3 ) + { + if ( PW_Start_Address + PW_l + PW_m > PW_in_size ) + { + /* printf ( "#8,0 Start:%ld\n", PW_Start_Address);*/ + return BAD; + } + if ( in_data[PW_Start_Address+PW_l+PW_m] > 0x49 ) + { +/*printf ( "#8 Start:%ld (at %x)(PW_k:%x)(PW_l:%x)(PW_m:%x)\n" , PW_Start_Address,PW_Start_Address+PW_l+PW_m,PW_k,PW_l,PW_m );*/ + return BAD; + } + if ( (((in_data[PW_Start_Address+PW_l+PW_m]<<4)&0x10)| + ((in_data[PW_Start_Address+PW_l+PW_m+1]>>4)&0x0f)) > PW_j ) + { +/*printf ( "#8,1 Start:%ld (at %x)(PW_k:%x)(PW_l:%x)(PW_m:%x)(PW_j:%ld)\n" , PW_Start_Address,PW_Start_Address+PW_l+PW_m,PW_k,PW_l,PW_m,PW_j );*/ + return BAD; + } + PW_n = (in_data[PW_Start_Address+PW_l+PW_m+1]&0x0F); + if ( (PW_n == 0) && (in_data[PW_Start_Address+PW_l+PW_m+2] != 0x00) ) + { +/*printf ( "#8,2 Start:%ld (at %x)(PW_k:%x)(PW_l:%x)(PW_m:%x)(PW_j:%ld)\n" , PW_Start_Address,PW_Start_Address+PW_l+PW_m,PW_k,PW_l,PW_m,PW_j );*/ + return BAD; + } + } + + /* PW_WholeSampleSize is the size of the sample data */ + /* PW_l is the size of the header 'til the track datas */ + /* PW_k is the size of the track datas */ + return GOOD; +} diff --git a/prowizard/tests/npd3.c b/prowizard/tests/npd3.c new file mode 100755 index 00000000..f507fa89 --- /dev/null +++ b/prowizard/tests/npd3.c @@ -0,0 +1,175 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testNoisepacker3 ( void ) +{ + if ( PW_i < 9 ) + { + return BAD; + } + PW_Start_Address = PW_i-9; + + /* size of the pattern table */ + PW_j = (in_data[PW_Start_Address+2]*256)+in_data[PW_Start_Address+3]; + if ( (((PW_j/2)*2) != PW_j) || (PW_j == 0) ) + { +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_j is the size of the pattern list (*2) */ + + /* test nbr of samples */ + if ( (in_data[PW_Start_Address+1]&0x0f) != 0x0C ) + { +/*printf ( "#3,0 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_l = ((in_data[PW_Start_Address]<<4)&0xf0)|((in_data[PW_Start_Address+1]>>4)&0x0f); + if ( (PW_l > 0x1F) || (PW_l == 0) || ((PW_Start_Address+8+PW_j+PW_l*8)>PW_in_size)) + { +/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_l is the number of samples */ + + /* test volumes */ + for ( PW_k=0 ; PW_k 0x40 ) + { + return BAD; + } + } + + /* test sample sizes */ + PW_WholeSampleSize=0; + for ( PW_k=0 ; PW_k 0xFFFF) || + (PW_m > 0xFFFF) || + (PW_n > 0xFFFF) ) + { +/*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_m + PW_n) > (PW_o+2) ) + { +/*printf ( "#5,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_n != 0) && (PW_m == 0) ) + { +/*printf ( "#5,2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_WholeSampleSize += PW_o; + } + if ( PW_WholeSampleSize <= 4 ) + { +/*printf ( "#5,3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + + /* small shit to gain some vars */ + PW_l *= 16; + PW_l += 8; + PW_l += 4; + /* PW_l is now the size of the header 'til the end of sample descriptions */ + if ( (PW_l+PW_Start_Address) > PW_in_size ) + { +/* printf ( "NP3 Header bigger than file size (%ld > %ld)\n", PW_l, PW_in_size);*/ + return BAD; + } + + + /* test pattern table */ + PW_n=0; + for ( PW_k=0 ; PW_k PW_n ) + PW_n = PW_m; + } + PW_l += PW_j; + PW_l += PW_n; + PW_l += 8; /*paske on a que l'address du dernier pattern .. */ + /* PW_l is now the size of the header 'til the end of the track list */ + /* PW_j is now available for use :) */ + /* PW_n is the highest pattern number (*8) */ + + /* test track data size */ + PW_k = (in_data[PW_Start_Address+6]*256)+in_data[PW_Start_Address+7]; + if ( (PW_k <= 63) || ((PW_k+PW_l+PW_Start_Address)>PW_in_size)) + { +/*printf ( "#7 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* test notes */ + /* re-calculate the number of sample */ + /* PW_k is the track data size */ + PW_j = ((in_data[PW_Start_Address]<<4)&0xf0)|((in_data[PW_Start_Address+1]>>4)&0x0f); + for ( PW_m=0 ; PW_m < PW_k ; PW_m++ ) + { + if ( (in_data[PW_Start_Address+PW_l+PW_m]&0x80) == 0x80 ) + continue; + /* si note trop grande et si effet = A */ + if ( (in_data[PW_Start_Address+PW_l+PW_m] > 0x49)|| + ((in_data[PW_Start_Address+PW_l+PW_m+1]&0x0f) == 0x0A) ) + { +/*printf ( "#8 Start:%ld (at %x)(PW_k:%x)(PW_l:%x)(PW_m:%x)\n" , PW_Start_Address,PW_Start_Address+PW_l+PW_m,PW_k,PW_l,PW_m );*/ + return BAD; + } + /* si effet D et arg > 0x40 */ + if ( ((in_data[PW_Start_Address+PW_l+PW_m+1]&0x0f) == 0x0D )&& + (in_data[PW_Start_Address+PW_l+PW_m+2] > 0x40 ) ) + { +/*printf ( "#8 Start:%ld (at %ld)(effet:%d)(arg:%ld)\n" + , PW_Start_Address + , PW_Start_Address+PW_l+PW_m + , (PW_Start_Address+PW_l+PW_m+1)&0x0f + , (PW_Start_Address+PW_l+PW_m+2) );*/ + return BAD; + } + /* sample nbr > ce qui est defini au debut ? */ + if ( (((in_data[PW_Start_Address+PW_l+PW_m]<<4)&0x10)| + ((in_data[PW_Start_Address+PW_l+PW_m+1]>>4)&0x0f)) > PW_j ) + { +/*printf ( "#8,1 Start:%ld (at %x)(PW_k:%x)(PW_l:%x)(PW_m:%x)(PW_j:%ld)\n" , PW_Start_Address,PW_Start_Address+PW_l+PW_m,PW_k,PW_l,PW_m,PW_j );*/ + return BAD; + } + /* all is empty ?!? ... cannot be ! */ + if ( (in_data[PW_Start_Address+PW_l+PW_m] == 0) && + (in_data[PW_Start_Address+PW_l+PW_m+1] == 0) && + (in_data[PW_Start_Address+PW_l+PW_m+2] == 0) && (PW_m<(PW_k-3)) ) + { +/*printf ( "#8,2 Start:%ld (at %x)(PW_k:%x)(PW_l:%x)(PW_m:%x)(PW_j:%ld)\n" , PW_Start_Address,PW_Start_Address+PW_l+PW_m,PW_k,PW_l,PW_m,PW_j );*/ + return BAD; + } + PW_m += 2; + } + + /* PW_WholeSampleSize is the size of the sample data */ + /* PW_l is the size of the header 'til the track datas */ + /* PW_k is the size of the track datas */ + return GOOD; +} diff --git a/prowizard/tests/p40a.c b/prowizard/tests/p40a.c new file mode 100755 index 00000000..21b58cf5 --- /dev/null +++ b/prowizard/tests/p40a.c @@ -0,0 +1,71 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testP40A ( void ) +{ + PW_Start_Address = PW_i; + + /* number of pattern (real) */ + PW_j = in_data[PW_Start_Address+4]; + if ( PW_j > 0x7f ) + { + return BAD; + } + + /* number of sample */ + PW_k = in_data[PW_Start_Address+6]; + if ( (PW_k > 0x1F) || (PW_k == 0) ) + { + return BAD; + } + + /* test volumes */ + for ( PW_l=0 ; PW_l 0x40 ) + { + return BAD; + } + } + + /* test sample sizes */ + PW_WholeSampleSize = 0; + for ( PW_l=0 ; PW_l 0xFFFF) || + (PW_n > 0xFFFF) ) + { + return BAD; + } + + if ( PW_n > (PW_o+2) ) + { + return BAD; + } + PW_WholeSampleSize += PW_o; + } + if ( PW_WholeSampleSize <= 4 ) + { + PW_WholeSampleSize = 0; + return BAD; + } + + /* PW_WholeSampleSize is the size of the sample data .. WRONG !! */ + /* PW_k is the number of samples */ + return GOOD; +} + diff --git a/prowizard/tests/p41a.c b/prowizard/tests/p41a.c new file mode 100755 index 00000000..7d7b2655 --- /dev/null +++ b/prowizard/tests/p41a.c @@ -0,0 +1,70 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testP41A ( void ) +{ + PW_Start_Address = PW_i; + + /* number of pattern (real) */ + PW_j = in_data[PW_Start_Address+4]; + if ( PW_j > 0x7f ) + { + return BAD; + } + + /* number of sample */ + PW_k = in_data[PW_Start_Address+6]; + if ( (PW_k > 0x1F) || (PW_k == 0) ) + { + return BAD; + } + + /* test volumes */ + for ( PW_l=0 ; PW_l 0x40 ) + { + return BAD; + } + } + + /* test sample sizes */ + PW_WholeSampleSize = 0; + for ( PW_l=0 ; PW_l 0xFFFF) || + (PW_n > 0xFFFF) ) + { + return BAD; + } + + if ( PW_n > (PW_o+2) ) + { + return BAD; + } + PW_WholeSampleSize += PW_o; + } + if ( PW_WholeSampleSize <= 4 ) + { + return BAD; + } + + /* PW_WholeSampleSize is the size of the sample data .. WRONG !! */ + /* PW_k is the number of samples */ + return GOOD; +} + diff --git a/prowizard/tests/p50a.c b/prowizard/tests/p50a.c new file mode 100755 index 00000000..c1e62bdc --- /dev/null +++ b/prowizard/tests/p50a.c @@ -0,0 +1,238 @@ +/* update on the 3rd of april 2000 */ +/* bug pointed out by Thomas Neumann ... thx */ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testP50A ( void ) +{ + int nbr_notes=0; + if ( PW_i < 7 ) + { + return BAD; + } + PW_Start_Address = PW_i-7; + + /* number of pattern (real) */ + PW_m = in_data[PW_Start_Address+2]; + if ( (PW_m > 0x7f) || (PW_m == 0) ) + { + /*printf ( "#1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_m is the real number of pattern */ + + /* number of sample */ + PW_k = in_data[PW_Start_Address+3]; + if ( (PW_k&0x40) == 0x40 ) + { + /*printf ( "#2\n" );*/ + return BAD; + } + if ( ((PW_k&0x3f) > 0x1F) || ((PW_k&0x3F) == 0) ) + { + /*printf ( "#2,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_k &= 0x3F; + /* PW_k is the number of sample */ + + /* test volumes */ + for ( PW_l=0 ; PW_l 0x40 ) + { + /*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* test fines */ + if ( in_data[PW_Start_Address+6+PW_l*6] > 0x0F ) + { + /*printf ( "#4 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test sample sizes and loop start */ + PW_WholeSampleSize = 0; + for ( PW_n=0 ; PW_n 0x8000)) || (PW_o == 0) ) + { + /*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_o < 0xFF00 ) + PW_WholeSampleSize += (PW_o*2); + + PW_j = ( (in_data[PW_Start_Address+8+PW_n*6]*256) + + in_data[PW_Start_Address+9+PW_n*6] ); + if ( (PW_j != 0xFFFF) && (PW_j >= PW_o) ) + { + /*printf ( "#5,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_o > 0xFFDF ) + { + if ( (0xFFFF-PW_o) > PW_k ) + { + /*printf ( "#5,2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + } + + /* test sample data address */ + PW_j = (in_data[PW_Start_Address]*256)+in_data[PW_Start_Address+1]; + if ( PW_j < (PW_k*6+4+PW_m*8) ) + { + /*printf ( "#6 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_j is the address of the sample data */ + + + /* test track table */ + for ( PW_l=0 ; PW_l<(PW_m*4) ; PW_l++ ) + { + PW_o = ((in_data[PW_Start_Address+4+PW_k*6+PW_l*2]*256)+ + in_data[PW_Start_Address+4+PW_k*6+PW_l*2+1] ); + if ( (PW_o+PW_k*6+4+PW_m*8) > PW_j ) + { + /*printf ( "#7 Start:%ld (value:%ld)(where:%x)(PW_l:%ld)(PW_m:%ld)(PW_o:%ld)\n" +, PW_Start_Address +, (in_data[PW_Start_Address+PW_k*6+4+PW_l*2]*256)+in_data[PW_Start_Address+4+PW_k*6+PW_l*2+1] +, PW_Start_Address+PW_k*6+4+PW_l*2 +, PW_l +, PW_m +, PW_o );*/ + return BAD; + } + } + + /* test pattern table */ + PW_l=0; + PW_o=0; + /* first, test if we dont oversize the input file */ + if ( (PW_Start_Address+PW_k*6+4+PW_m*8) > PW_in_size ) + { + /*printf ( "8,0 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + while ( (in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l] != 0xFF) && (PW_l<128) ) + { + if ( ((in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l]/2)*2) != in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l] ) + { +/*printf ( "#8,1 Start:%ld (value:%ld)(where:%x)(PW_l:%ld)(PW_m:%ld)(PW_k:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l] +, PW_Start_Address+PW_k*6+4+PW_m*8+PW_l +, PW_l +, PW_m +, PW_k );*/ + return BAD; + } + + if ( in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l] > (PW_m*2) ) + { +/*printf ( "#8,2 Start:%ld (value:%ld)(where:%x)(PW_l:%ld)(PW_m:%ld)(PW_k:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l] +, PW_Start_Address+PW_k*6+4+PW_m*8+PW_l +, PW_l +, PW_m +, PW_k );*/ + return BAD; + } + if ( in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l] > PW_o ) + PW_o = in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l]; + PW_l++; + } + /* are we beside the sample data address ? */ + if ( (PW_k*6+4+PW_m*8+PW_l) > PW_j ) + { + return BAD; + } + if ( (PW_l == 0) || (PW_l == 128) ) + { +/*printf ( "#8.3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_o /= 2; + PW_o += 1; + /* PW_o is the highest number of pattern */ + + + /* test notes ... pfiew */ + PW_l += 1; + for ( PW_n=(PW_k*6+4+PW_m*8+PW_l) ; PW_n 0x49 ) + { + /*printf ( "#9,0 Start:%ld (value:%ld) (where:%x) (PW_n:%ld) (PW_j:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_n] +, PW_Start_Address+PW_n +, PW_n +, PW_j );*/ + return BAD; + } + if ( in_data[PW_Start_Address+PW_n] > 0x02 ) + nbr_notes = 1; + if ( (((in_data[PW_Start_Address+PW_n]<<4)&0x10) | ((in_data[PW_Start_Address+PW_n+1]>>4)&0x0F)) > PW_k ) + { + /*printf ( "#9,1 Start:%ld (value:%ld) (where:%x) (PW_n:%ld) (PW_j:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_n] +, PW_Start_Address+PW_n +, PW_n +, PW_j );*/ + return BAD; + } + PW_n += 2; + continue; + } + + if ( (in_data[PW_Start_Address+PW_n]&0x80) == 0x80 ) + { + if ( in_data[PW_Start_Address+PW_n] == 0x80 ) + { + /* too many lines to repeat ? */ + if ( in_data[PW_Start_Address+PW_n+1] > 0x40 ) + { + return BAD; + } + if ( ((in_data[PW_Start_Address+PW_n+2]*256)+in_data[PW_Start_Address+PW_n+3]) < (in_data[PW_Start_Address+PW_n+1]*3) ) + { + /*printf ( "#9,3 (start:%ld)\n",PW_Start_Address);*/ + return BAD; + } + } + else + nbr_notes = 1; + } + PW_n += 3; + } + if ( nbr_notes == 0 ) + { + /* empty notes */ + /*printf ( "#9,4 (start:%ld)\n",PW_Start_Address);*/ + return BAD; + } + + /* PW_WholeSampleSize is the whole sample data size */ + /* PW_j is the address of the sample data */ + return GOOD; +} + diff --git a/prowizard/tests/p60a.c b/prowizard/tests/p60a.c new file mode 100755 index 00000000..0e64c5a5 --- /dev/null +++ b/prowizard/tests/p60a.c @@ -0,0 +1,394 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testP60A_nopack ( void ) +{ + int nbr_notes=0; + if ( PW_i < 7 ) + { + return BAD; + } + PW_Start_Address = PW_i-7; + + /* number of pattern (real) */ + PW_m = in_data[PW_Start_Address+2]; + if ( (PW_m > 0x7f) || (PW_m == 0) ) + { +/*printf ( "#1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_m is the real number of pattern */ + + /* number of sample */ + PW_k = (in_data[PW_Start_Address+3]&0x3F); + if ( (PW_k > 0x1F) || (PW_k == 0) || ((PW_k*6+PW_Start_Address+7)>=PW_in_size)) + { +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_k is the number of sample */ + + /* test volumes */ + for ( PW_l=0 ; PW_l 0x40 ) + { +/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test fines */ + for ( PW_l=0 ; PW_l 0x0F ) + { +/*printf ( "#4 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test sample sizes and loop start */ + PW_WholeSampleSize = 0; + for ( PW_n=0 ; PW_n 0x8000)) || (PW_o == 0) ) + { +/*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_o < 0xFF00 ) + PW_WholeSampleSize += (PW_o*2); + + PW_j = ( (in_data[PW_Start_Address+8+PW_n*6]*256) + + in_data[PW_Start_Address+9+PW_n*6] ); + if ( (PW_j != 0xFFFF) && (PW_j >= PW_o) ) + { +/*printf ( "#5,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_o > 0xFFDF ) + { + if ( (0xFFFF-PW_o) > PW_k ) + { +/*printf ( "#5,2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + } + + /* test sample data address */ + PW_j = (in_data[PW_Start_Address]*256)+in_data[PW_Start_Address+1]; + if ( PW_j < (PW_k*6+4+PW_m*8) ) + { +/*printf ( "#6 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_j is the address of the sample data */ + + + /* test track table */ + for ( PW_l=0 ; PW_l<(PW_m*4) ; PW_l++ ) + { + PW_o = ((in_data[PW_Start_Address+4+PW_k*6+PW_l*2]*256)+ + in_data[PW_Start_Address+4+PW_k*6+PW_l*2+1] ); + if ( (PW_o+PW_k*6+4+PW_m*8) > PW_j ) + { +/*printf ( "#7 Start:%ld (value:%ld)(where:%x)(PW_l:%ld)(PW_m:%ld)(PW_o:%ld)\n" +, PW_Start_Address +, (in_data[PW_Start_Address+PW_k*6+4+PW_l*2]*256)+in_data[PW_Start_Address+4+PW_k*6+PW_l*2+1] +, PW_Start_Address+PW_k*6+4+PW_l*2 +, PW_l +, PW_m +, PW_o );*/ + return BAD; + } + } + + /* test pattern table */ + PW_l=0; + PW_o=0; + /* first, test if we dont oversize the input file */ + if ( (PW_Start_Address+PW_k*6+4+PW_m*8) > PW_in_size ) + { +/*printf ( "8,0 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + while ( (in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l] != 0xFF) && (PW_l<128) ) + { + if ( in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l] > (PW_m-1) ) + { +/*printf ( "#8,1 Start:%ld (value:%ld)(where:%x)(PW_l:%ld)(PW_m:%ld)(PW_k:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l] +, PW_Start_Address+PW_k*6+4+PW_m*8+PW_l +, PW_l +, PW_m +, PW_k );*/ + return BAD; + } + if ( in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l] > PW_o ) + PW_o = in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l]; + PW_l++; + } + /* are we beside the sample data address ? */ + if ( (PW_k*6+4+PW_m*8+PW_l) > PW_j ) + { + return BAD; + } + if ( (PW_l == 0) || (PW_l == 128) ) + { +/*printf ( "#8.2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_o += 1; + /* PW_o is the highest number of pattern */ + + + /* test notes ... pfiew */ + PW_l += 1; + /* printf ( "Where : %ld\n" , PW_k*6+4+PW_m*8+PW_l);*/ + for ( PW_n=(PW_k*6+4+PW_m*8+PW_l) ; PW_n 0x49 ) + { +/*printf ( "#9,0 Start:%ld (value:%ld) (where:%x) (PW_n:%ld) (PW_j:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_n] +, PW_Start_Address+PW_n +, PW_n +, PW_j + );*/ + return BAD; + } + if ( in_data[PW_Start_Address+PW_n] >= 0x02 ) + nbr_notes = 1; + if ( (((in_data[PW_Start_Address+PW_n]<<4)&0x10) | ((in_data[PW_Start_Address+PW_n+1]>>4)&0x0F)) > PW_k ) + { +/*printf ( "#9,1 Start:%ld (value:%ld) (where:%x) (PW_n:%ld) (PW_j:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_n] +, PW_Start_Address+PW_n +, PW_n +, PW_j + );*/ + return BAD; + } + PW_n += 2; + } + else + PW_n += 3; + } + if ( nbr_notes == 0 ) + { + /*printf ( "9,3 (Start:%ld)\n",PW_Start_Address);*/ + return BAD; + } + + /* PW_WholeSampleSize is the whole sample data size */ + /* PW_j is the address of the sample data */ + return GOOD; +} + + +/******************/ +/* packed samples */ +/******************/ +short testP60A_pack ( void ) +{ + if ( PW_i < 11 ) + { + return BAD; + } + PW_Start_Address = PW_i-11; + + /* number of pattern (real) */ + PW_m = in_data[PW_Start_Address+2]; + if ( (PW_m > 0x7f) || (PW_m == 0) ) + { +/*printf ( "#1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_m is the real number of pattern */ + + /* number of sample */ + PW_k = in_data[PW_Start_Address+3]; + if ( (PW_k&0x40) != 0x40 ) + { +/*printf ( "#2,0 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_k &= 0x3F; + if ( (PW_k > 0x1F) || (PW_k == 0) ) + { +/*printf ( "#2,1 Start:%ld (PW_k:%ld)\n" , PW_Start_Address,PW_k );*/ + return BAD; + } + /* PW_k is the number of sample */ + + /* test volumes */ + if ( (PW_Start_Address+11+(PW_k*6)) > PW_in_size) + return BAD; + for ( PW_l=0 ; PW_l 0x40 ) + { +/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test fines */ + for ( PW_l=0 ; PW_l 0x0F ) + { +/*printf ( "#4 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test sample sizes and loop start */ + PW_WholeSampleSize = 0; + for ( PW_n=0 ; PW_n 0x8000)) || (PW_o == 0) ) + { +/*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_o < 0xFF00 ) + PW_WholeSampleSize += (PW_o*2); + + PW_j = ( (in_data[PW_Start_Address+12+PW_n*6]*256) + + in_data[PW_Start_Address+13+PW_n*6] ); + if ( (PW_j != 0xFFFF) && (PW_j >= PW_o) ) + { +/*printf ( "#5,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_o > 0xFFDF ) + { + if ( (0xFFFF-PW_o) > PW_k ) + { +/*printf ( "#5,2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + } + + /* test sample data address */ + PW_j = (in_data[PW_Start_Address]*256)+in_data[PW_Start_Address+1]; + if ( PW_j < (PW_k*6+8+PW_m*8) ) + { +/*printf ( "#6 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_j is the address of the sample data */ + + + /* test track table */ + for ( PW_l=0 ; PW_l<(PW_m*4) ; PW_l++ ) + { + PW_o = ((in_data[PW_Start_Address+8+PW_k*6+PW_l*2]*256)+ + in_data[PW_Start_Address+8+PW_k*6+PW_l*2+1] ); + if ( (PW_o+PW_k*6+8+PW_m*8) > PW_j ) + { +/*printf ( "#7 Start:%ld (value:%ld)(where:%x)(PW_l:%ld)(PW_m:%ld)(PW_o:%ld)\n" +, PW_Start_Address +, (in_data[PW_Start_Address+PW_k*6+8+PW_l*2]*256)+in_data[PW_Start_Address+8+PW_k*6+PW_l*2+1] +, PW_Start_Address+PW_k*6+8+PW_l*2 +, PW_l +, PW_m +, PW_o );*/ + return BAD; + } + } + + /* test pattern table */ + PW_l=0; + PW_o=0; + /* first, test if we dont oversize the input file */ + if ( (PW_k*6+8+PW_m*8) > PW_in_size ) + { +/*printf ( "8,0 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + while ( (in_data[PW_Start_Address+PW_k*6+8+PW_m*8+PW_l] != 0xFF) && (PW_l<128) ) + { + if ( in_data[PW_Start_Address+PW_k*6+8+PW_m*8+PW_l] > (PW_m-1) ) + { +/*printf ( "#8,1 Start:%ld (value:%ld)(where:%x)(PW_l:%ld)(PW_m:%ld)(PW_k:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_k*6+8+PW_m*8+PW_l] +, PW_Start_Address+PW_k*6+8+PW_m*8+PW_l +, PW_l +, PW_m +, PW_k );*/ + return BAD; + } + if ( in_data[PW_Start_Address+PW_k*6+8+PW_m*8+PW_l] > PW_o ) + PW_o = in_data[PW_Start_Address+PW_k*6+8+PW_m*8+PW_l]; + PW_l++; + } + if ( (PW_l == 0) || (PW_l == 128) ) + { +/*printf ( "#8.2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_o += 1; + /* PW_o is the highest number of pattern */ + + + /* test notes ... pfiew */ + PW_l += 1; + for ( PW_n=(PW_k*6+8+PW_m*8+PW_l) ; PW_n 0x49 ) + { +/*printf ( "#9,0 Start:%ld (value:%ld) (where:%x) (PW_n:%ld) (PW_j:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_n] +, PW_Start_Address+PW_n +, PW_n +, PW_j + );*/ + return BAD; + } + if ( (((in_data[PW_Start_Address+PW_n]<<4)&0x10) | ((in_data[PW_Start_Address+PW_n+1]>>4)&0x0F)) > PW_k ) + { +/*printf ( "#9,1 Start:%ld (value:%ld) (where:%x) (PW_n:%ld) (PW_j:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_n] +, PW_Start_Address+PW_n +, PW_n +, PW_j + );*/ + return BAD; + } + PW_n += 2; + } + else + PW_n += 3; + } + + /* PW_WholeSampleSize is the whole sample data size */ + /* PW_j is the address of the sample data */ + return GOOD; +} + diff --git a/prowizard/tests/p61a.c b/prowizard/tests/p61a.c new file mode 100755 index 00000000..2c02005d --- /dev/null +++ b/prowizard/tests/p61a.c @@ -0,0 +1,526 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testP61A_nopack ( void ) +{ + if ( PW_i < 7 ) + { + return BAD; + } + PW_Start_Address = PW_i-7; + + /* number of pattern (real) */ + PW_m = in_data[PW_Start_Address+2]; + if ( (PW_m > 0x7f) || (PW_m == 0) ) + { +/*printf ( "#1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_m is the real number of pattern */ + + /* number of sample */ + PW_k = (in_data[PW_Start_Address+3]&0x3F); + if ( (PW_k > 0x1F) || (PW_k == 0) || ((PW_k*6+PW_Start_Address+7)>=PW_in_size)) + { +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_k is the number of sample */ + + /* test volumes */ + for ( PW_l=0 ; PW_l 0x40 ) + { +/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test fines */ + for ( PW_l=0 ; PW_l 0x0F ) + { +/*printf ( "#4 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test sample sizes and loop start */ + PW_WholeSampleSize = 0; + for ( PW_n=0 ; PW_n 0x8000)) || (PW_o == 0) ) + { +/*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_o < 0xFF00 ) + PW_WholeSampleSize += (PW_o*2); + + PW_j = ( (in_data[PW_Start_Address+8+PW_n*6]*256) + + in_data[PW_Start_Address+9+PW_n*6] ); + if ( (PW_j != 0xFFFF) && (PW_j >= PW_o) ) + { +/*printf ( "#5,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_o > 0xFFDF ) + { + if ( (0xFFFF-PW_o) > PW_k ) + { +/*printf ( "#5,2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + } + + /* test sample data address */ + PW_j = (in_data[PW_Start_Address]*256)+in_data[PW_Start_Address+1]; + if ( PW_j < (PW_k*6+4+PW_m*8) ) + { +/*printf ( "#6 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_j is the address of the sample data */ + + + /* test track table */ + for ( PW_l=0 ; PW_l<(PW_m*4) ; PW_l++ ) + { + PW_o = ((in_data[PW_Start_Address+4+PW_k*6+PW_l*2]*256)+ + in_data[PW_Start_Address+4+PW_k*6+PW_l*2+1] ); + if ( (PW_o+PW_k*6+4+PW_m*8) > PW_j ) + { +/*printf ( "#7 Start:%ld (value:%ld)(where:%x)(PW_l:%ld)(PW_m:%ld)(PW_o:%ld)\n" +, PW_Start_Address +, (in_data[PW_Start_Address+PW_k*6+4+PW_l*2]*256)+in_data[PW_Start_Address+4+PW_k*6+PW_l*2+1] +, PW_Start_Address+PW_k*6+4+PW_l*2 +, PW_l +, PW_m +, PW_o );*/ + return BAD; + } + } + + /* test pattern table */ + PW_l=0; + PW_o=0; + /* first, test if we dont oversize the input file */ + if ( (PW_Start_Address+PW_k*6+4+PW_m*8) > PW_in_size ) + { +/*printf ( "8,0 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + while ( (in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l] != 0xFF) && (PW_l<128) ) + { + if ( in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l] > (PW_m-1) ) + { +/*printf ( "#8,1 Start:%ld (value:%ld)(where:%x)(PW_l:%ld)(PW_m:%ld)(PW_k:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l] +, PW_Start_Address+PW_k*6+4+PW_m*8+PW_l +, PW_l +, PW_m +, PW_k );*/ + return BAD; + } + if ( in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l] > PW_o ) + PW_o = in_data[PW_Start_Address+PW_k*6+4+PW_m*8+PW_l]; + PW_l++; + } + /* are we beside the sample data address ? */ + if ( (PW_k*6+4+PW_m*8+PW_l) > PW_j ) + { + return BAD; + } + if ( (PW_l == 0) || (PW_l == 128) ) + { +/*printf ( "#8.2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_o += 1; + /* PW_o is the highest number of pattern */ + + + /* test notes ... pfiew */ + PW_l += 1; + for ( PW_n=(PW_k*6+4+PW_m*8+PW_l) ; PW_n PW_k ) + { +/*printf ( "#9,1 Start:%ld (value:%ld) (where:%x) (PW_n:%ld) (PW_j:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_n] +, PW_Start_Address+PW_n +, PW_n +, PW_j + );*/ + return BAD; + } + PW_n += 2; + continue; + } + if ( (in_data[PW_Start_Address+PW_n]&0xf0) == 0x70 ) + { + if ( (in_data[PW_Start_Address+PW_n+1]&0x1F) > PW_k ) + { +/*printf ( "#9,2 Start:%ld (value:%ld) (where:%x) (PW_n:%ld) (PW_j:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_n] +, PW_Start_Address+PW_n +, PW_n +, PW_j + );*/ + return BAD; + } + PW_n += 1; + continue; + } + /* no Note nor Sample number */ + if ( (in_data[PW_Start_Address+PW_n]&0xf0) == 0xe0 ) + { + PW_n += 2; + continue; + } + if ( (in_data[PW_Start_Address+PW_n]&0xf0) == 0x60 ) + { + PW_n += 1; + continue; + } + + if ( (in_data[PW_Start_Address+PW_n]&0x80) == 0x80 ) + { + if ( (((in_data[PW_Start_Address+PW_n]<<4)&0x10) | ((in_data[PW_Start_Address+PW_n+1]>>4)&0x0F)) > PW_k ) + { +/*printf ( "#9,3 Start:%ld (value:%ld) (where:%x) (PW_n:%ld) (PW_j:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_n] +, PW_Start_Address+PW_n +, PW_n +, PW_j + );*/ + return BAD; + } + PW_n += 3; + continue; + } + + if ( (((in_data[PW_Start_Address+PW_n]<<4)&0x10) | ((in_data[PW_Start_Address+PW_n+1]>>4)&0x0F)) > PW_k ) + { +/*printf ( "#9,4 Start:%ld (value:%ld) (where:%x) (PW_n:%ld) (PW_j:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_n] +, PW_Start_Address+PW_n +, PW_n +, PW_j + );*/ + return BAD; + } + PW_n += 2; + } + + /* PW_WholeSampleSize is the whole sample data size */ + /* PW_j is the address of the sample data */ + return GOOD; +} + + +/******************/ +/* packed samples */ +/******************/ +short testP61A_pack ( void ) +{ + if ( PW_i < 11 ) + { + return BAD; + } + PW_Start_Address = PW_i-11; + + /* number of pattern (real) */ + PW_m = in_data[PW_Start_Address+2]; + if ( (PW_m > 0x7f) || (PW_m == 0) ) + { +/*printf ( "#1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_m is the real number of pattern */ + + /* number of sample */ + PW_k = in_data[PW_Start_Address+3]; + if ( (PW_k&0x40) != 0x40 ) + { +/*printf ( "#2,0 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_k &= 0x3F; + if ( (PW_k > 0x1F) || (PW_k == 0) ) + { +/*printf ( "#2,1 Start:%ld (PW_k:%ld)\n" , PW_Start_Address,PW_k );*/ + return BAD; + } + /* PW_k is the number of sample */ + + /* test volumes */ + if ( (PW_Start_Address+11+(PW_k*6))>PW_in_size) + return BAD; + for ( PW_l=0 ; PW_l 0x40 ) + { +/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test fines */ + for ( PW_l=0 ; PW_l 0x0F ) + { +/*printf ( "#4 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test sample sizes and loop start */ + PW_WholeSampleSize = 0; + for ( PW_n=0 ; PW_n 0x8000)) || (PW_o == 0) ) + { +/*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_o < 0xFF00 ) + PW_WholeSampleSize += (PW_o*2); + + PW_j = ( (in_data[PW_Start_Address+12+PW_n*6]*256) + + in_data[PW_Start_Address+13+PW_n*6] ); + if ( (PW_j != 0xFFFF) && (PW_j >= PW_o) ) + { +/*printf ( "#5,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_o > 0xFFDF ) + { + if ( (0xFFFF-PW_o) > PW_k ) + { +/*printf ( "#5,2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + } + + /* test sample data address */ + PW_j = (in_data[PW_Start_Address]*256)+in_data[PW_Start_Address+1]; + if ( PW_j < (PW_k*6+8+PW_m*8) ) + { +/*printf ( "#6 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_j is the address of the sample data */ + + + /* test track table */ + for ( PW_l=0 ; PW_l<(PW_m*4) ; PW_l++ ) + { + PW_o = ((in_data[PW_Start_Address+8+PW_k*6+PW_l*2]*256)+ + in_data[PW_Start_Address+8+PW_k*6+PW_l*2+1] ); + if ( (PW_o+PW_k*6+8+PW_m*8) > PW_j ) + { +/*printf ( "#7 Start:%ld (value:%ld)(where:%x)(PW_l:%ld)(PW_m:%ld)(PW_o:%ld)\n" +, PW_Start_Address +, (in_data[PW_Start_Address+PW_k*6+8+PW_l*2]*256)+in_data[PW_Start_Address+8+PW_k*6+PW_l*2+1] +, PW_Start_Address+PW_k*6+8+PW_l*2 +, PW_l +, PW_m +, PW_o );*/ + return BAD; + } + } + + /* test pattern table */ + PW_l=0; + PW_o=0; + /* first, test if we dont oversize the input file */ + if ( (PW_k*6+8+PW_m*8) > PW_in_size ) + { +/*printf ( "8,0 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + while ( (in_data[PW_Start_Address+PW_k*6+8+PW_m*8+PW_l] != 0xFF) && (PW_l<128) ) + { + if ( in_data[PW_Start_Address+PW_k*6+8+PW_m*8+PW_l] > (PW_m-1) ) + { +/*printf ( "#8,1 Start:%ld (value:%ld)(where:%x)(PW_l:%ld)(PW_m:%ld)(PW_k:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_k*6+8+PW_m*8+PW_l] +, PW_Start_Address+PW_k*6+8+PW_m*8+PW_l +, PW_l +, PW_m +, PW_k );*/ + return BAD; + } + if ( in_data[PW_Start_Address+PW_k*6+8+PW_m*8+PW_l] > PW_o ) + PW_o = in_data[PW_Start_Address+PW_k*6+8+PW_m*8+PW_l]; + PW_l++; + } + if ( (PW_l == 0) || (PW_l == 128) ) + { +/*printf ( "#8.2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_o += 1; + /* PW_o is the highest number of pattern */ + + + /* test notes ... pfiew */ + PW_l += 1; + for ( PW_n=(PW_k*6+8+PW_m*8+PW_l) ; PW_n PW_k ) + { +/*printf ( "#9,1 Start:%ld (value:%ld) (where:%x) (PW_n:%ld) (PW_j:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_n] +, PW_Start_Address+PW_n +, PW_n +, PW_j + );*/ + return BAD; + } + PW_n += 2; + continue; + } + if ( (in_data[PW_Start_Address+PW_n]&0xf0) == 0x70 ) + { + if ( (in_data[PW_Start_Address+PW_n+1]&0x1F) > PW_k ) + { +/*printf ( "#9,1 Start:%ld (value:%ld) (where:%x) (PW_n:%ld) (PW_j:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_n] +, PW_Start_Address+PW_n +, PW_n +, PW_j + );*/ + return BAD; + } + PW_n += 1; + continue; + } + /* no Note nor Sample number */ + if ( (in_data[PW_Start_Address+PW_n]&0xf0) == 0xe0 ) + { + PW_n += 2; + continue; + } + if ( (in_data[PW_Start_Address+PW_n]&0xf0) == 0x60 ) + { + PW_n += 1; + continue; + } + + if ( (in_data[PW_Start_Address+PW_n]&0x80) == 0x80 ) + { + if ( (((in_data[PW_Start_Address+PW_n]<<4)&0x10) | ((in_data[PW_Start_Address+PW_n+1]>>4)&0x0F)) > PW_k ) + { +/*printf ( "#9,1 Start:%ld (value:%ld) (where:%x) (PW_n:%ld) (PW_j:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_n] +, PW_Start_Address+PW_n +, PW_n +, PW_j + );*/ + return BAD; + } + PW_n += 3; + continue; + } + + if ( (((in_data[PW_Start_Address+PW_n]<<4)&0x10) | ((in_data[PW_Start_Address+PW_n+1]>>4)&0x0F)) > PW_k ) + { +/*printf ( "#9,1 Start:%ld (value:%ld) (where:%x) (PW_n:%ld) (PW_j:%ld)\n" +, PW_Start_Address +, in_data[PW_Start_Address+PW_n] +, PW_Start_Address+PW_n +, PW_n +, PW_j + );*/ + return BAD; + } + PW_n += 2; + } + + + /* PW_WholeSampleSize is the whole sample data size */ + /* PW_j is the address of the sample data */ + return GOOD; +} + diff --git a/prowizard/tests/pha.c b/prowizard/tests/pha.c new file mode 100755 index 00000000..50a6ef23 --- /dev/null +++ b/prowizard/tests/pha.c @@ -0,0 +1,86 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPHA ( void ) +{ + /* test #1 */ + if ( PW_i < 11 ) + { +/* +printf ( "#1 (PW_i:%ld)\n" , PW_i ); +*/ + return BAD; + } + + /* test #2 (volumes,sample addresses and whole sample size) */ + PW_Start_Address = PW_i-11; + PW_l=0; + PW_WholeSampleSize = 0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + /* sample size */ + PW_n =(((in_data[PW_Start_Address+PW_j*14]*256)+in_data[PW_Start_Address+PW_j*14+1])*2); + PW_WholeSampleSize += PW_n; + /* loop start */ + PW_m =(((in_data[PW_Start_Address+PW_j*14+4]*256)+in_data[PW_Start_Address+PW_j*14+5])*2); + + if ( in_data[PW_Start_Address+3+PW_j*14] > 0x40 ) + { +/*printf ( "#2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_m > PW_WholeSampleSize ) + { +/*printf ( "#2,1 (start:%ld) (smp nbr:%ld) (size:%ld) (lstart:%ld)\n" + , PW_Start_Address,PW_j,PW_n,PW_m );*/ + return BAD; + } + PW_k = (in_data[PW_Start_Address+8+PW_j*14]*256*256*256) + +(in_data[PW_Start_Address+9+PW_j*14]*256*256) + +(in_data[PW_Start_Address+10+PW_j*14]*256) + +in_data[PW_Start_Address+11+PW_j*14]; + /* PW_k is the address of this sample data */ + if ( (PW_k < 0x3C0) || (PW_k>PW_in_size) ) + { +/*printf ( "#2,2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + if ( (PW_WholeSampleSize <= 2) || (PW_WholeSampleSize>(31*65535)) ) + { + /*printf ( "#2,3 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test #3 (addresses of pattern in file ... possible ?) */ + /* PW_WholeSampleSize is the WholeSampleSize */ + PW_l = PW_WholeSampleSize + 960; + PW_k = 0; + for ( PW_j=0 ; PW_j<128 ; PW_j++ ) + { + PW_m = (in_data[PW_Start_Address+448+PW_j*4]*256*256*256) + +(in_data[PW_Start_Address+449+PW_j*4]*256*256) + +(in_data[PW_Start_Address+450+PW_j*4]*256) + +in_data[PW_Start_Address+451+PW_j*4]; + if ( PW_m > PW_k ) + PW_k = PW_m; + if ( (PW_m+2) < PW_l ) + { + /*printf ( "#5 (start:%ld)(add:%ld)(min:%ld)(where:%ld)\n" , PW_Start_Address,PW_m,PW_l, PW_j );*/ + return BAD; + } + } + /* PW_k is the highest pattern data address */ + + + return GOOD; +} + + diff --git a/prowizard/tests/pm.c b/prowizard/tests/pm.c new file mode 100755 index 00000000..cf35e363 --- /dev/null +++ b/prowizard/tests/pm.c @@ -0,0 +1,42 @@ +/* update on the 3rd of april 2000 */ +/* some advices by Thomas Neumann .. thx */ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +/* Power Music */ +short testPM ( void ) +{ + /* test 1 */ + if ( PW_i < 1080 ) + { + return BAD; + } + + /* test 2 */ + PW_Start_Address = PW_i-1080; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+45+30*PW_j] > 0x40 ) + { + return BAD; + } + } + + /* test 3 */ + if ( (in_data[PW_Start_Address+951] > 0x7F) && (in_data[PW_Start_Address+951] != 0xFF) ) + { + return BAD; + } + + return GOOD; +} + + diff --git a/prowizard/tests/pm01.c b/prowizard/tests/pm01.c new file mode 100755 index 00000000..fec3144d --- /dev/null +++ b/prowizard/tests/pm01.c @@ -0,0 +1,135 @@ +/* +- 22 sept 2001 - +bugfix : test #5 was fake since first pat addy can be != $00000000 +*/ + + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +short testPM01 ( void ) +{ + /* test #1 */ + if ( (PW_i < 3) || ((PW_Start_Address + 766)>PW_in_size) ) + { +/*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + + /* test #2 */ + PW_Start_Address = PW_i-3; + PW_l=0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + PW_k = (((in_data[PW_Start_Address+PW_j*8]*256)+in_data[PW_Start_Address+1+PW_j*8])*2); + PW_l += PW_k; + /* finetune > 0x0f ? */ + if ( in_data[PW_Start_Address+2+8*PW_j] > 0x0f ) + { +/*printf ( "#2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* loop start > size ? */ + if ( (((in_data[PW_Start_Address+4+PW_j*8]*256)+in_data[PW_Start_Address+5+PW_j*8])*2) > PW_k ) + { +/*printf ( "#2,1 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + if ( PW_l <= 2 ) + { +/*printf ( "#2,2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test #3 about size of pattern list */ + PW_l = (in_data[PW_Start_Address+248]*256)+in_data[PW_Start_Address+249]; + PW_k = PW_l/4; + if ( (PW_k*4) != PW_l ) + { +/*printf ( "#3 (start:%ld)(PW_l:%ld)(PW_k:%ld)\n" , PW_Start_Address,PW_l,PW_k );*/ + return BAD; + } + if ( PW_k>127 ) + { +/*printf ( "#3,1 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_l == 0 ) + { +/*printf ( "#3,2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test #4 size of all the pattern data */ + /* PW_k contains the size of the pattern list */ + PW_l = (in_data[PW_Start_Address+762]*256*256*256) + +(in_data[PW_Start_Address+743]*256*256) + +(in_data[PW_Start_Address+764]*256) + +in_data[PW_Start_Address+765]; + if ( (PW_l<1024) || (PW_l>131072) || ((PW_l+PW_Start_Address)>PW_in_size) ) + { +/*printf ( "#4 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test #5 first pattern address != $00000000 ? */ + /* bugfix : removed coz first addy can be != $00000000 ! */ + + /* test #6 pattern addresses */ + /* PW_k is still ths size of the pattern list */ + for ( PW_j=0 ; PW_j 131072 ) + { +/*printf ( "#6 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + if ( ((PW_l/1024)*1024) != PW_l ) + { + return BAD; + } + } + + /* test #7 last patterns in pattern table != $00000000 ? */ + PW_j += 4; /* just to be sure */ + while ( PW_j != 128 ) + { + PW_l = (in_data[PW_Start_Address+250+PW_j*4]*256*256*256) + +(in_data[PW_Start_Address+251+PW_j*4]*256*256) + +(in_data[PW_Start_Address+252+PW_j*4]*256) + +in_data[PW_Start_Address+253+PW_j*4]; + if ( PW_l != 0 ) + { +/*printf ( "#7 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_j += 1; + } + + /* test #8 : first pattern data */ + for ( PW_j=0 ; PW_j<256 ; PW_j+=4 ) + { + if ( (255-in_data[PW_Start_Address+766+PW_j])>0x13 ) + { +/*printf ( "#8 (Start:%ld)\n", PW_Start_Address);*/ + return BAD; + } + } + + return GOOD; +} + + diff --git a/prowizard/tests/pm10c.c b/prowizard/tests/pm10c.c new file mode 100755 index 00000000..a1d217b7 --- /dev/null +++ b/prowizard/tests/pm10c.c @@ -0,0 +1,56 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +short testPM10c ( void ) +{ + /* test 1 */ + if ( (PW_Start_Address + 4452) > PW_in_size ) + { + return BAD; + } + + /* test 2 */ + if ( in_data[PW_Start_Address + 21] != 0xce ) + { + return BAD; + } + + /* test 3 */ + PW_j = (in_data[PW_Start_Address+4452]*256*256*256)+(in_data[PW_Start_Address+4453]*256*256)+(in_data[PW_Start_Address+4454]*256)+in_data[PW_Start_Address+4455]; + if ( (PW_Start_Address + PW_j + 4452) > PW_in_size ) + { + return BAD; + } + + /* test 4 */ + PW_k = (in_data[PW_Start_Address+4712]*256)+in_data[PW_Start_Address+4713]; + PW_l = PW_k/4; + PW_l *= 4; + if ( PW_l != PW_k ) + { + return BAD; + } + + /* test 5 */ + if ( in_data[PW_Start_Address + 36] != 0x10 ) + { + return BAD; + } + + /* test 6 */ + if ( in_data[PW_Start_Address + 37] != 0xFC ) + { + return BAD; + } + + return GOOD; +} + diff --git a/prowizard/tests/pm20.c b/prowizard/tests/pm20.c new file mode 100755 index 00000000..69140486 --- /dev/null +++ b/prowizard/tests/pm20.c @@ -0,0 +1,38 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPM2 ( void ) +{ + PW_Start_Address = PW_i; + /* test 1 */ + if ( (PW_Start_Address + 5714) > PW_in_size ) + { + return BAD; + } + + /* test 2 */ + /*if ( in_data[PW_Start_Address+5094] != 0x03 )*/ + /* not sure in fact ... */ + /* well, it IS the frequency table, it always seem */ + /* to be the 'standard one .. so here, there is 0358h */ + /* { + return BAD; + }*/ + + /* test 3 */ + if ( in_data[PW_Start_Address+5461] > 0x40 ) + /* testing a volume */ + { + return BAD; + } + + return GOOD; +} + diff --git a/prowizard/tests/pm40.c b/prowizard/tests/pm40.c new file mode 100755 index 00000000..4113ff95 --- /dev/null +++ b/prowizard/tests/pm40.c @@ -0,0 +1,58 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPM40 ( void ) +{ + PW_Start_Address = PW_i; + + /* size of the pattern list */ + PW_j = in_data[PW_Start_Address+7]; + if ( PW_j > 0x7f ) + { +/*printf ( "#1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_j is the size of the pattern list */ + + /* finetune */ + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + if ( in_data[PW_Start_Address+PW_k*8+266] > 0x0f ) + { +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* volume */ + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + if ( in_data[PW_Start_Address+PW_k*8+267] > 0x40 ) + { +/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* sample data address */ + PW_l = ( (in_data[PW_Start_Address+512]*256*256*256)+ + (in_data[PW_Start_Address+513]*256*256)+ + (in_data[PW_Start_Address+514]*256)+ + in_data[PW_Start_Address+515] ); + if ( (PW_l <= 520) || (PW_l > 2500000l ) ) + { +/*printf ( "#4 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* PW_l is the sample data address */ + return GOOD; +} + diff --git a/prowizard/tests/pmz.c b/prowizard/tests/pmz.c new file mode 100755 index 00000000..d05a4475 --- /dev/null +++ b/prowizard/tests/pmz.c @@ -0,0 +1,57 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPMZ ( void ) +{ + PW_Start_Address = PW_i; + + /* test 1 */ + if ( (PW_Start_Address + 4456) > PW_in_size ) + { + return BAD; + } + + /* test 2 */ + if ( in_data[PW_Start_Address + 21] != 0xd2 ) + { + return BAD; + } + + /* test 3 */ + PW_j = (in_data[PW_Start_Address+4456]*256*256*256)+(in_data[PW_Start_Address+4457]*256*256)+(in_data[PW_Start_Address+4458]*256)+in_data[PW_Start_Address+4459]; + if ( (PW_Start_Address + PW_j + 4456) > PW_in_size ) + { + return BAD; + } + + /* test 4 */ + PW_k = (in_data[PW_Start_Address+4712]*256)+in_data[PW_Start_Address+4713]; + PW_l = PW_k/4; + PW_l *= 4; + if ( PW_l != PW_k ) + { + return BAD; + } + + /* test 5 */ + if ( in_data[PW_Start_Address + 36] != 0x11 ) + { + return BAD; + } + + /* test 6 */ + if ( in_data[PW_Start_Address + 37] != 0x00 ) + { + return BAD; + } + + return GOOD; +} + diff --git a/prowizard/tests/polka.c b/prowizard/tests/polka.c new file mode 100755 index 00000000..c4f42d03 --- /dev/null +++ b/prowizard/tests/polka.c @@ -0,0 +1,95 @@ +/* (Mar 2003) + * polka.c +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPolka ( void ) +{ + /* test #1 */ + if ( (PW_i < 0x438) || ((PW_i+0x830)>PW_in_size)) + { + return BAD; + } + + /* test #2 */ + PW_Start_Address = PW_i-0x438; + PW_l=0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + /* size */ + PW_k = (((in_data[PW_Start_Address+42+30*PW_j]*256)+in_data[PW_Start_Address+43+30*PW_j])*2); + /* loop start */ + PW_m = (((in_data[PW_Start_Address+46+30*PW_j]*256)+in_data[PW_Start_Address+47+30*PW_j])*2); + /* loop size */ + PW_n = (((in_data[PW_Start_Address+48+30*PW_j]*256)+in_data[PW_Start_Address+49+30*PW_j])*2); + PW_WholeSampleSize += PW_k; + + if ( test_smps(PW_k, PW_m, PW_n, in_data[PW_Start_Address+45+30*PW_j], in_data[PW_Start_Address+44+30*PW_j] ) == BAD ) + { + /* printf ("#2 (start:%ld)(siz:%ld)(lstart:%ld)(lsiz:%ld)(vol:%d)(fine:%d)(Where:%ld)\n" + ,PW_Start_Address,PW_k,PW_m,PW_n + ,in_data[PW_Start_Address+0x2d +30+PW_j],in_data[PW_Start_Address+0x2c +30*PW_j] + ,PW_Start_Address+0x2a + 30*PW_j);*/ + return BAD; + } + } + if ( PW_WholeSampleSize <= 2 ) + { + /* printf( "#2,1\n" );*/ + return BAD; + } + + /* test #3 */ + PW_l = in_data[PW_Start_Address+0x3b6]; + if ( (PW_l > 0x7f) || (PW_l == 0x00) ) + { + /*printf( "#3\n" );*/ + return BAD; + } + + /* test #4 */ + /* PW_l contains the size of the pattern list */ + PW_k = 0; + for ( PW_j=0 ; PW_j<128 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+0x3b8+PW_j] > PW_k ) + PW_k = in_data[PW_Start_Address+0x3b8+PW_j]; + if ( in_data[PW_Start_Address+0x3b8+PW_j] > 0x7f ) + { + /*printf( "#4 (start:%ld)\n",PW_Start_Address );*/ + return BAD; + } + } + PW_k += 1; + + /* test #5 notes .. gosh ! (testing all patterns !) */ + /* PW_k contains the number of pattern saved */ + /* PW_WholeSampleSize contains the whole sample size :) */ + for ( PW_j=0 ; PW_j<(256*PW_k) ; PW_j++ ) + { + PW_l = in_data[PW_Start_Address+0x43c+PW_j*4]; + if ( (PW_l > 72) || (((PW_l/2)*2)!=PW_l) ) + { + /*printf( "#5 (start:%ld)(note:%ld)(where:%ld)\n",PW_Start_Address,PW_l,PW_Start_Address+0x43c +PW_j*4 );*/ + return BAD; + } + PW_l = in_data[PW_Start_Address+0x43e +PW_j*4]&0xf0; + PW_m = in_data[PW_Start_Address+0x43d +PW_j*4]; + if ( (PW_l != 0) || (PW_m > 0x1f)) + { + /*printf ( "#5,1 (Start:%ld)(where:%ld)(note:%ld)\n" , PW_Start_Address,PW_Start_Address+0x43c +PW_j*4, PW_m );*/ + return BAD; + } + } + + return GOOD; +} diff --git a/prowizard/tests/powerp23.c b/prowizard/tests/powerp23.c new file mode 100755 index 00000000..d92ff740 --- /dev/null +++ b/prowizard/tests/powerp23.c @@ -0,0 +1,78 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPowerpacker23 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x22 ) || + (in_data[PW_Start_Address+17] != 0x48 ) || + (in_data[PW_Start_Address+18] != 0xD3 ) || + (in_data[PW_Start_Address+19] != 0xFC ) || + (in_data[PW_Start_Address+20] != 0x00 ) || + (in_data[PW_Start_Address+21] != 0x00 ) || + (in_data[PW_Start_Address+22] != 0x02 ) || + (in_data[PW_Start_Address+23] != 0x00 ) || + (in_data[PW_Start_Address+24] != 0x2C ) || + (in_data[PW_Start_Address+25] != 0x78 ) || + (in_data[PW_Start_Address+26] != 0x00 ) || + (in_data[PW_Start_Address+27] != 0x04 ) || + (in_data[PW_Start_Address+28] != 0x48 ) || + (in_data[PW_Start_Address+29] != 0xE7 ) || + (in_data[PW_Start_Address+30] != 0x00 ) || + (in_data[PW_Start_Address+31] != 0xC0 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+344]*256*256*256) + + (in_data[PW_Start_Address+345]*256*256) + + (in_data[PW_Start_Address+346]*256) + + in_data[PW_Start_Address+347] ); + + PW_l += 572; + + if ( PW_i >= 36 ) + { + if ( (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x03 ) || + (in_data[PW_Start_Address-33] != 0xF3 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x00 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x02 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/powerp30.c b/prowizard/tests/powerp30.c new file mode 100755 index 00000000..5b7f289b --- /dev/null +++ b/prowizard/tests/powerp30.c @@ -0,0 +1,77 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPowerpacker30 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0xD1 ) || + (in_data[PW_Start_Address+17] != 0xC8 ) || + (in_data[PW_Start_Address+18] != 0x58 ) || + (in_data[PW_Start_Address+19] != 0x48 ) || + (in_data[PW_Start_Address+20] != 0x26 ) || + (in_data[PW_Start_Address+21] != 0x48 ) || + (in_data[PW_Start_Address+22] != 0x50 ) || + (in_data[PW_Start_Address+23] != 0x4B ) || + (in_data[PW_Start_Address+24] != 0x2C ) || + (in_data[PW_Start_Address+25] != 0x78 ) || + (in_data[PW_Start_Address+26] != 0x00 ) || + (in_data[PW_Start_Address+27] != 0x04 ) || + (in_data[PW_Start_Address+28] != 0x2F ) || + (in_data[PW_Start_Address+29] != 0x08 ) || + (in_data[PW_Start_Address+30] != 0xD1 ) || + (in_data[PW_Start_Address+31] != 0xFC ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+32]*256*256*256) + + (in_data[PW_Start_Address+33]*256*256) + + (in_data[PW_Start_Address+34]*256) + + in_data[PW_Start_Address+35] ); + + PW_l += 600; + + if ( PW_i >= 36 ) + { + if ( (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x03 ) || + (in_data[PW_Start_Address-33] != 0xF3 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x00 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x02 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + + return GOOD; + /* PW_l is the size of the pack */ +} diff --git a/prowizard/tests/powerp40.c b/prowizard/tests/powerp40.c new file mode 100755 index 00000000..ed03230a --- /dev/null +++ b/prowizard/tests/powerp40.c @@ -0,0 +1,78 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPowerpacker40 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0xD1 ) || + (in_data[PW_Start_Address+17] != 0xC8 ) || + (in_data[PW_Start_Address+18] != 0x58 ) || + (in_data[PW_Start_Address+19] != 0x48 ) || + (in_data[PW_Start_Address+20] != 0x26 ) || + (in_data[PW_Start_Address+21] != 0x48 ) || + (in_data[PW_Start_Address+22] != 0x50 ) || + (in_data[PW_Start_Address+23] != 0x4B ) || + (in_data[PW_Start_Address+24] != 0x2C ) || + (in_data[PW_Start_Address+25] != 0x78 ) || + (in_data[PW_Start_Address+26] != 0x00 ) || + (in_data[PW_Start_Address+27] != 0x04 ) || + (in_data[PW_Start_Address+28] != 0x2F ) || + (in_data[PW_Start_Address+29] != 0x08 ) || + (in_data[PW_Start_Address+30] != 0xD1 ) || + (in_data[PW_Start_Address+31] != 0xFC ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+32]*256*256*256) + + (in_data[PW_Start_Address+33]*256*256) + + (in_data[PW_Start_Address+34]*256) + + in_data[PW_Start_Address+35] ); + + PW_l += 684; + + if ( PW_i >= 36 ) + { + if ( (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x03 ) || + (in_data[PW_Start_Address-33] != 0xF3 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x00 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x02 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/powerp4l.c b/prowizard/tests/powerp4l.c new file mode 100755 index 00000000..b318bb22 --- /dev/null +++ b/prowizard/tests/powerp4l.c @@ -0,0 +1,78 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPowerpacker4lib ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+92] != 'p' ) || + (in_data[PW_Start_Address+93] != 'o' ) || + (in_data[PW_Start_Address+94] != 'w' ) || + (in_data[PW_Start_Address+95] != 'e' ) || + (in_data[PW_Start_Address+96] != 'r' ) || + (in_data[PW_Start_Address+97] != 'p' ) || + (in_data[PW_Start_Address+98] != 'a' ) || + (in_data[PW_Start_Address+99] != 'c' ) || + (in_data[PW_Start_Address+100]!= 'k' ) || + (in_data[PW_Start_Address+101]!= 'e' ) || + (in_data[PW_Start_Address+102]!= 'r' ) || + (in_data[PW_Start_Address+103]!= '.' ) || + (in_data[PW_Start_Address+104]!= 'l' ) || + (in_data[PW_Start_Address+105]!= 'i' ) || + (in_data[PW_Start_Address+106]!= 'b' ) || + (in_data[PW_Start_Address+107]!= 'r' ) || + (in_data[PW_Start_Address+108]!= 'a' ) || + (in_data[PW_Start_Address+109]!= 'r' ) || + (in_data[PW_Start_Address+110]!= 'y' ) ) + { +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+32]*256*256*256) + + (in_data[PW_Start_Address+33]*256*256) + + (in_data[PW_Start_Address+34]*256) + + in_data[PW_Start_Address+35] ); + + PW_l += 176; + + if ( PW_i >= 36 ) + { + if ( (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x03 ) || + (in_data[PW_Start_Address-33] != 0xF3 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x00 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x02 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} diff --git a/prowizard/tests/pp10.c b/prowizard/tests/pp10.c new file mode 100755 index 00000000..9b1355cf --- /dev/null +++ b/prowizard/tests/pp10.c @@ -0,0 +1,143 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPP10 ( void ) +{ + /* test #1 */ + if ( (PW_i < 3) || ((PW_i+246)>=PW_in_size)) + { +/*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + PW_Start_Address = PW_i-3; + + /* noisetracker byte */ + if ( in_data[PW_Start_Address+249] > 0x7f ) + { +/*printf ( "#1,1 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test #2 */ + PW_WholeSampleSize = 0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + PW_k = (((in_data[PW_Start_Address+PW_j*8]*256)+in_data[PW_Start_Address+1+PW_j*8])*2); + PW_l = (((in_data[PW_Start_Address+PW_j*8+4]*256)+in_data[PW_Start_Address+5+PW_j*8])*2); + /* loop size */ + PW_m = (((in_data[PW_Start_Address+PW_j*8+6]*256)+in_data[PW_Start_Address+7+PW_j*8])*2); + if ( (PW_m == 0) || (PW_m == PW_l) ) + { +/*printf ( "#1,98 (start:%ld) (PW_k:%ld) (PW_l:%ld) (PW_m:%ld)\n" , PW_Start_Address,PW_k,PW_l,PW_m );*/ + return BAD; + } + if ( (PW_l != 0) && (PW_m <= 2) ) + { +/*printf ( "#1,99 (start:%ld) (PW_k:%ld) (PW_l:%ld) (PW_m:%ld)\n" , PW_Start_Address,PW_k,PW_l,PW_m );*/ + return BAD; + } + if ( (PW_l+PW_m) > (PW_k+2) ) + { +/*printf ( "#2,0 (start:%ld) (PW_k:%ld) (PW_l:%ld) (PW_m:%ld)\n" , PW_Start_Address,PW_k,PW_l,PW_m );*/ + return BAD; + } + if ( (PW_l!=0) && (PW_m == 0) ) + { +/*printf ( "#2,01 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_WholeSampleSize += PW_k; + /* finetune > 0x0f ? */ + if ( in_data[PW_Start_Address+2+8*PW_j] > 0x0f ) + { +/*printf ( "#2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* volume > 0x40 ? */ + if ( in_data[PW_Start_Address+3+8*PW_j] > 0x40 ) + { +/*printf ( "#2,1 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* loop start > size ? */ + if ( (((in_data[PW_Start_Address+4+PW_j*8]*256)+in_data[PW_Start_Address+5+PW_j*8])*2) > PW_k ) + { +/*printf ( "#2,2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* size > 0xffff ? */ + if ( PW_k > 0xFFFF ) + { +/*printf ( "#2,3 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + if ( PW_WholeSampleSize <= 2 ) + { +/*printf ( "#2,4 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_WholeSampleSize = whole sample size */ + + /* test #3 about size of pattern list */ + PW_l = in_data[PW_Start_Address+248]; + if ( (PW_l > 127) || (PW_l==0) ) + { +/*printf ( "#3 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* get the highest track value */ + PW_k=0; + for ( PW_j=0 ; PW_j<512 ; PW_j++ ) + { + PW_l = in_data[PW_Start_Address+250+PW_j]; + if ( PW_l>PW_k ) + PW_k = PW_l; + } + /* PW_k is the highest track number */ + PW_k += 1; + PW_k *= 64; + + if ( PW_Start_Address + 762 + (PW_k*4) > PW_in_size ) + { + return BAD; + } + + /* track data test */ + PW_l=0; + for ( PW_j=0 ; PW_j 0x13 ) + { +/*printf ( "#3,1 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+762+PW_j*4]&0x0f) == 0x00 ) && (in_data[PW_Start_Address+763+PW_j*4] < 0x71) && (in_data[PW_Start_Address+763+PW_j*4] != 0x00)) + { + /* printf ( "#3,2 (start:%ld)(where:%ld)\n",PW_Start_Address,762+PW_j*4 );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+762+PW_j*4]&0x0f) != 0x00 ) || (in_data[PW_Start_Address+763+PW_j*4] != 0x00 )) + PW_l = 1; + } + if ( PW_l == 0 ) + { + /* only some empty patterns */ + return BAD; + } + PW_k *= 4; + + /* PW_WholeSampleSize is the sample data size */ + /* PW_k is the track data size */ + return GOOD; +} + + diff --git a/prowizard/tests/pp21.c b/prowizard/tests/pp21.c new file mode 100755 index 00000000..aa778344 --- /dev/null +++ b/prowizard/tests/pp21.c @@ -0,0 +1,104 @@ +/* + * 5th, oct 2001 : strenghtened a test that hanged the prog sometimes +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPP21 ( void ) +{ + /* test #1 */ + if ( (PW_i < 3) || ((PW_i+891)>=PW_in_size)) + { +/*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + + /* test #2 */ + PW_Start_Address = PW_i-3; + PW_WholeSampleSize=0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + PW_k = (((in_data[PW_Start_Address+PW_j*8]*256)+in_data[PW_Start_Address+1+PW_j*8])*2); + PW_WholeSampleSize += PW_k; + /* finetune > 0x0f ? */ + if ( in_data[PW_Start_Address+2+8*PW_j] > 0x0f ) + { +/*printf ( "#2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* loop start > size ? */ + if ( (((in_data[PW_Start_Address+4+PW_j*8]*256)+in_data[PW_Start_Address+5+PW_j*8])*2) > PW_k ) + { +/*printf ( "#2,1 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + if ( PW_WholeSampleSize <= 2 ) + { +/*printf ( "#2,2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test #3 about size of pattern list */ + PW_l = in_data[PW_Start_Address+248]; + if ( (PW_l > 127) || (PW_l==0) ) + { +/*printf ( "#3 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* get the highest track value */ + PW_k=0; + for ( PW_j=0 ; PW_j<512 ; PW_j++ ) + { + PW_l = in_data[PW_Start_Address+250+PW_j]; + if ( PW_l>PW_k ) + PW_k = PW_l; + } + /* PW_k is the highest track number */ + PW_k += 1; + PW_k *= 64; + if ( (PW_k*2) + PW_Start_Address + 763 > PW_in_size ) + { +/* printf ( "#3,5 (start:%ld)\n" , PW_Start_Address)*/ + return BAD; + } + + /* test #4 track data value > $4000 ? */ + PW_m = 0; + for ( PW_j=0 ; PW_j PW_m ) + PW_m = PW_l; + if ( PW_l > 0x4000 ) + { +/*printf ( "#4 (start:%ld)(where:%ld)\n" , PW_Start_Address,PW_Start_Address+PW_j*2+762 );*/ + return BAD; + } + } + + /* test #5 reference table size *4 ? */ + PW_k *= 2; + PW_l = (in_data[PW_Start_Address+PW_k+762]*256*256*256) + +(in_data[PW_Start_Address+PW_k+763]*256*256) + +(in_data[PW_Start_Address+PW_k+764]*256) + +in_data[PW_Start_Address+PW_k+765]; + if ( PW_l != ((PW_m+1)*4) ) + { +/*printf ( "#5 (start:%ld)(where:%ld)\n" , PW_Start_Address,(PW_Start_Address+PW_k+762) );*/ + return BAD; + } + + return GOOD; +} + + diff --git a/prowizard/tests/pp30.c b/prowizard/tests/pp30.c new file mode 100755 index 00000000..e3dbf20d --- /dev/null +++ b/prowizard/tests/pp30.c @@ -0,0 +1,143 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPP30 ( void ) +{ + /* test #1 */ + if ( (PW_i < 3) || ((PW_i+891)>=PW_in_size)) + { +/*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + + /* test #2 */ + PW_Start_Address = PW_i-3; + PW_WholeSampleSize=0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + PW_k = (((in_data[PW_Start_Address+PW_j*8]*256)+in_data[PW_Start_Address+PW_j*8+1])*2); + PW_WholeSampleSize += PW_k; + /* finetune > 0x0f ? */ + if ( in_data[PW_Start_Address+8*PW_j+2] > 0x0f ) + { +/*printf ( "#2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* volume > 0x40 ? */ + if ( in_data[PW_Start_Address+8*PW_j+3] > 0x40 ) + { +/*printf ( "#2,0 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* loop start > size ? */ + if ( (((in_data[PW_Start_Address+4+PW_j*8]*256)+in_data[PW_Start_Address+5+PW_j*8])*2) > PW_k ) + { +/*printf ( "#2,1 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + if ( PW_WholeSampleSize <= 2 ) + { +/*printf ( "#2,2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test #3 about size of pattern list */ + PW_l = in_data[PW_Start_Address+248]; + if ( (PW_l > 127) || (PW_l==0) ) + { +/*printf ( "#3 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* get the highest track value */ + PW_k=0; + for ( PW_j=0 ; PW_j<512 ; PW_j++ ) + { + PW_l = in_data[PW_Start_Address+250+PW_j]; + if ( PW_l>PW_k ) + PW_k = PW_l; + } + /* PW_k is the highest track number */ + PW_k += 1; + PW_k *= 64; + + /* test #4 track data value *4 ? */ + /* PW_WholeSampleSize is the whole sample size */ + PW_m = 0; + if ( ((PW_k*2)+PW_Start_Address+763) > PW_in_size ) + { + return BAD; + } + for ( PW_j=0 ; PW_j PW_m ) + PW_m = PW_l; + if ( ((PW_l*4)/4) != PW_l ) + { +/*printf ( "#4 (start:%ld)(where:%ld)\n" , PW_Start_Address,PW_Start_Address+PW_j*2+762 );*/ + return BAD; + } + } + + /* test #5 reference table size *4 ? */ + /* PW_m is the highest reference number */ + PW_k *= 2; + PW_m /= 4; + PW_l = (in_data[PW_Start_Address+PW_k+762]*256*256*256) + +(in_data[PW_Start_Address+PW_k+763]*256*256) + +(in_data[PW_Start_Address+PW_k+764]*256) + +in_data[PW_Start_Address+PW_k+765]; + if ( PW_l > 65535 ) + { + return BAD; + } + if ( PW_l != ((PW_m+1)*4) ) + { +/*printf ( "#5 (start:%ld)(where:%ld)\n" , PW_Start_Address,(PW_Start_Address+PW_k+762) );*/ + return BAD; + } + + /* test #6 data in reference table ... */ + for ( PW_j=0 ; PW_j<(PW_l/4) ; PW_j++ ) + { + /* volume > 41 ? */ + if ( ((in_data[PW_Start_Address+PW_k+766+PW_j*4+2]&0x0f)==0x0c) && + (in_data[PW_Start_Address+PW_k+766+PW_j*4+3] > 0x41 ) ) + { +/*printf ( "#6 (vol > 40 at : %ld)\n" , PW_Start_Address+PW_k+766+PW_j*4+2 );*/ + return BAD; + } + /* break > 40 ? */ + if ( ((in_data[PW_Start_Address+PW_k+766+PW_j*4+2]&0x0f)==0x0d) && + (in_data[PW_Start_Address+PW_k+766+PW_j*4+3] > 0x40 ) ) + { +/*printf ( "#6,1\n" );*/ + return BAD; + } + /* jump > 128 */ + if ( ((in_data[PW_Start_Address+PW_k+766+PW_j*4+2]&0x0f)==0x0b) && + (in_data[PW_Start_Address+PW_k+766+PW_j*4+3] > 0x7f ) ) + { +/*printf ( "#6,2\n" );*/ + return BAD; + } + /* smp > 1f ? */ + if ((in_data[PW_Start_Address+PW_k+766+PW_j*4]&0xf0)>0x10) + { +/*printf ( "#6,3\n" );*/ + return BAD; + } + } + /* PW_WholeSampleSize is the whole sample size */ + + return GOOD; +} diff --git a/prowizard/tests/ppbk.c b/prowizard/tests/ppbk.c new file mode 100755 index 00000000..eb08c699 --- /dev/null +++ b/prowizard/tests/ppbk.c @@ -0,0 +1,48 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPPbk ( void ) +{ + PW_Start_Address = PW_i; + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+12]*256*256*256) + + (in_data[PW_Start_Address+13]*256*256) + + (in_data[PW_Start_Address+14]*256) + + in_data[PW_Start_Address+15] ); + + if ( PW_l > PW_in_size ) + { +/*printf ( "#2 Start:%ld (header size:%ld) (in_size:%ld)\n" , PW_Start_Address,PW_l , PW_in_size);*/ + return BAD; + } + + + /* PP20 packed size */ + PW_k = ( (in_data[PW_Start_Address+20+PW_l]*256*256) + + (in_data[PW_Start_Address+21+PW_l]*256) + + in_data[PW_Start_Address+22+PW_l]); + /* PP20 packed size */ + PW_m = ( (in_data[PW_Start_Address+8]*256*256*256) + + (in_data[PW_Start_Address+9]*256*256) + + (in_data[PW_Start_Address+10]*256) + + in_data[PW_Start_Address+11] ); + + if ( PW_m != PW_k ) + { +/*printf ( "#2 Start:%ld (PP20 size:%ld) (Header size:%ld)\n" , PW_Start_Address , PW_k , PW_m );*/ + return BAD; + } + + PW_l += 8; + return GOOD; + /* PW_l is the size of the pack (PP20 subfile size !)*/ +} + diff --git a/prowizard/tests/prun1.c b/prowizard/tests/prun1.c new file mode 100755 index 00000000..2a3dd9f6 --- /dev/null +++ b/prowizard/tests/prun1.c @@ -0,0 +1,32 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPRUN1 ( void ) +{ + /* test 1 */ + if ( PW_i < 1080 ) + { + return BAD; + } + + /* test 2 */ + PW_Start_Address = PW_i-1080; + if ( in_data[PW_Start_Address+951] != 0x7f ) + { + return BAD; + } + + /* test 3 */ + if ( in_data[PW_Start_Address+950] > 0x7f ) + { + return BAD; + } + return GOOD; +} diff --git a/prowizard/tests/prun2.c b/prowizard/tests/prun2.c new file mode 100755 index 00000000..3a1d4c9d --- /dev/null +++ b/prowizard/tests/prun2.c @@ -0,0 +1,42 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPRUN2 ( void ) +{ + PW_Start_Address = PW_i; + PW_j = (in_data[PW_i+4]*256*256*256)+(in_data[PW_i+5]*256*256)+(in_data[PW_i+6]*256)+in_data[PW_i+7]; + + /* test sample_data address */ + if ( (PW_j+PW_Start_Address) > PW_in_size ) + { + return BAD; + } + + /* test volumes */ + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + if ( in_data[PW_Start_Address+11+PW_k*8] > 0x40 ) + { + return BAD; + } + } + + /* test finetunes */ + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + if ( in_data[PW_Start_Address+10+PW_k*8] > 0x0F ) + { + return BAD; + } + } + + return GOOD; +} + diff --git a/prowizard/tests/ptk.c b/prowizard/tests/ptk.c new file mode 100755 index 00000000..7903c6af --- /dev/null +++ b/prowizard/tests/ptk.c @@ -0,0 +1,100 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testPTK ( void ) +{ + /* test 1 */ + if ( PW_i < 1080 ) + { +/*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + + /* test 2 */ + PW_Start_Address = PW_i-1080; + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + /* size */ + PW_j = (((in_data[PW_Start_Address+42+PW_k*30]*256)+in_data[PW_Start_Address+43+PW_k*30])*2); + /* loop start */ + PW_m = (((in_data[PW_Start_Address+46+PW_k*30]*256)+in_data[PW_Start_Address+47+PW_k*30])*2); + /* loop size */ + PW_n = (((in_data[PW_Start_Address+48+PW_k*30]*256)+in_data[PW_Start_Address+49+PW_k*30])*2); + + if ( test_smps(PW_j*2, PW_m, PW_n, in_data[PW_Start_Address+45+30*PW_k], in_data[PW_Start_Address+44+30*PW_k] ) == BAD ) + { + /*printf ( "start : %ld\n", PW_Start_Address );*/ + return BAD; + } + + PW_WholeSampleSize += PW_j; + } + + /* test #4 pattern list size */ + PW_l = in_data[PW_Start_Address+950]; + if ( (PW_l>127) || (PW_l==0) ) + { + /*printf ( "#4,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_l holds the size of the pattern list */ + PW_k=0; + for ( PW_j=0 ; PW_j<128 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+952+PW_j] > PW_k ) + PW_k = in_data[PW_Start_Address+952+PW_j]; + if ( in_data[PW_Start_Address+952+PW_j] > 127 ) + { + /*printf ( "#4,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + /* PW_k holds the highest pattern number */ + /* test last patterns of the pattern list = 0 ? */ + PW_j += 2; /* found some obscure ptk :( */ + while ( PW_j < 128 ) + { + if ( in_data[PW_Start_Address+952+PW_j] > 0x7f ) + { + /*printf ( "#4,2 (Start:%ld) (PW_j:%ld) (at:%ld)\n" , PW_Start_Address,PW_j ,PW_Start_Address+952+PW_j );*/ + return BAD; + } + PW_j += 1; + } + /* PW_k is the number of pattern in the file (-1) */ + PW_k += 1; + + + /* test #5 pattern data ... */ + if ( ((PW_k*1024)+1084+PW_Start_Address) > PW_in_size ) + { +/*printf ( "#5,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + for ( PW_j=0 ; PW_j<(PW_k*256) ; PW_j++ ) + { + /* sample > 1f or pitch > 358 ? */ + if ( in_data[PW_Start_Address+1084+PW_j*4] > 0x13 ) + { +/*printf ( "#5.1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_l = ((in_data[PW_Start_Address+1084+PW_j*4]&0x0f)*256)+in_data[PW_Start_Address+1085+PW_j*4]; + if ( (PW_l>0) && (PW_l<0x1C) ) + { +/*printf ( "#5,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + return GOOD; +} + diff --git a/prowizard/tests/qc.c b/prowizard/tests/qc.c new file mode 100755 index 00000000..194733ed --- /dev/null +++ b/prowizard/tests/qc.c @@ -0,0 +1,46 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testQuadraComposer ( void ) +{ + /* test #1 */ + if ( PW_i < 8 ) + { +/*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + PW_Start_Address = PW_i-8; + + /* test #2 "FORM" & "EMIC" */ + if ( (in_data[PW_Start_Address] != 'F') || + (in_data[PW_Start_Address+1] != 'O') || + (in_data[PW_Start_Address+2] != 'R') || + (in_data[PW_Start_Address+3] != 'M') || + (in_data[PW_Start_Address+12] != 'E') || + (in_data[PW_Start_Address+13] != 'M') || + (in_data[PW_Start_Address+14] != 'I') || + (in_data[PW_Start_Address+15] != 'C') ) + { +/*printf ( "#2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test number of samples */ + PW_l = in_data[PW_Start_Address+63]; + if ( (PW_l == 0x00) || (PW_l > 0x20) ) + { +/*printf ( "#3 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + return GOOD; +} + + diff --git a/prowizard/tests/relokit.c b/prowizard/tests/relokit.c new file mode 100755 index 00000000..1004d2ca --- /dev/null +++ b/prowizard/tests/relokit.c @@ -0,0 +1,75 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testRelokIt10 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x00 ) || + (in_data[PW_Start_Address+17] != 0x00 ) || + (in_data[PW_Start_Address+18] != 0x01 ) || + (in_data[PW_Start_Address+19] != 0xF0 ) || + (in_data[PW_Start_Address+20] != 0x23 ) || + (in_data[PW_Start_Address+21] != 0xE8 ) || + (in_data[PW_Start_Address+22] != 0x00 ) || + (in_data[PW_Start_Address+23] != 0x06 ) || + (in_data[PW_Start_Address+24] != 0x00 ) || + (in_data[PW_Start_Address+25] != 0x00 ) || + (in_data[PW_Start_Address+26] != 0x01 ) || + (in_data[PW_Start_Address+27] != 0xEC ) || + (in_data[PW_Start_Address+28] != 0x20 ) || + (in_data[PW_Start_Address+29] != 0x28 ) || + (in_data[PW_Start_Address+30] != 0x00 ) || + (in_data[PW_Start_Address+31] != 0x0E ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + PW_j = in_data[PW_Start_Address+721]; + PW_l = ( (in_data[PW_Start_Address+734+(PW_j*8)]*256*256*256) + + (in_data[PW_Start_Address+735+(PW_j*8)]*256*256) + + (in_data[PW_Start_Address+736+(PW_j*8)]*256) + + in_data[PW_Start_Address+737+(PW_j*8)] ); + PW_l += (952 + (PW_j*8)); + + if ( PW_i >= 36 ) + { + if ( (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x03 ) || + (in_data[PW_Start_Address-33] != 0xF3 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x00 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x02 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/skyt.c b/prowizard/tests/skyt.c new file mode 100755 index 00000000..cb1a752c --- /dev/null +++ b/prowizard/tests/skyt.c @@ -0,0 +1,40 @@ +/* + * Even in these poor lines, I managed to insert a bug :) + * + * update: 19/04/00 + * - bug correction (really testing volume !) +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testSKYT ( void ) +{ + /* test 1 */ + if ( PW_i < 256 ) + { + return BAD; + } + + /* test 2 */ + PW_WholeSampleSize = 0; + PW_Start_Address = PW_i-256; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+3+8*PW_j] > 0x40 ) + { + return BAD; + } + PW_WholeSampleSize += (((in_data[PW_Start_Address+8*PW_j]*256)+in_data[PW_Start_Address+1+8*PW_j])*2); + } + + return GOOD; +} + diff --git a/prowizard/tests/soundfx.c b/prowizard/tests/soundfx.c new file mode 100755 index 00000000..27afafd2 --- /dev/null +++ b/prowizard/tests/soundfx.c @@ -0,0 +1,133 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testSoundFX13 ( void ) +{ + /* test 1 */ + if ( PW_i < 0x3C ) + { +/*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + + /* test 2 */ + /* samples tests */ + PW_Start_Address = PW_i-0x3C; + for ( PW_k=0 ; PW_k<15 ; PW_k++ ) + { + /* size */ + PW_j = ((in_data[PW_Start_Address+PW_k*4+2]*256)+in_data[PW_Start_Address+PW_k*4+3]); + /* loop start */ + PW_m = ((in_data[PW_Start_Address+106+PW_k*30]*256)+in_data[PW_Start_Address+107+PW_k*30]); + /* loop size */ + PW_n = (((in_data[PW_Start_Address+108+PW_k*30]*256)+in_data[PW_Start_Address+109+PW_k*30])*2); + /* all sample sizes */ + + /* size,loopstart,replen > 64k ? */ + if ( (PW_j > 0xFFFF) || (PW_m > 0xFFFF) || (PW_n > 0xFFFF) ) + { +/*printf ( "#2,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* replen > size ? */ + if ( PW_n > (PW_j+2) ) + { +/*printf ( "#2 (Start:%ld) (smp:%ld) (size:%ld) (replen:%ld)\n" + , PW_Start_Address , PW_k+1 , PW_j , PW_n );*/ + return BAD; + } + /* loop start > size ? */ + if ( PW_m > PW_j ) + { +/*printf ( "#2,0 (Start:%ld) (smp:%ld) (size:%ld) (lstart:%ld)\n" + , PW_Start_Address , PW_k+1 , PW_j , PW_m );*/ + return BAD; + } + /* loop size =0 & loop start != 0 ?*/ + if ( (PW_m != 0) && (PW_n==0) ) + { +/*printf ( "#2,1 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* size & loopstart !=0 & size=loopstart ? */ + if ( (PW_j != 0) && (PW_j==PW_m) ) + { +/*printf ( "#2,15 (start:%ld) (smp:%ld) (siz:%ld) (lstart:%ld)\n" + , PW_Start_Address,PW_k+1,PW_j,PW_m );*/ + return BAD; + } + /* size =0 & loop start !=0 */ + if ( (PW_j==0) && (PW_m!=0) ) + { +/*printf ( "#2,2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* get real whole sample size */ + PW_WholeSampleSize = 0; + for ( PW_j=0 ; PW_j<15 ; PW_j++ ) + { + PW_k = ((in_data[PW_Start_Address+PW_j*4]*256*256*256)+ + (in_data[PW_Start_Address+PW_j*4+1]*256*256)+ + (in_data[PW_Start_Address+PW_j*4+2]*256)+ + in_data[PW_Start_Address+PW_j*4+3] ); + if ( PW_k > 131072 ) + { +/*printf ( "#2,4 (start:%ld) (smp:%ld) (size:%ld)\n" + , PW_Start_Address,PW_j,PW_k );*/ + return BAD; + } + PW_WholeSampleSize += PW_k; + } + + /* test #3 finetunes & volumes */ + for ( PW_k=0 ; PW_k<15 ; PW_k++ ) + { + if ( in_data[PW_Start_Address+105+PW_k*30]>0x40 ) + { +/*printf ( "#3 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test #4 pattern list size */ + PW_l = in_data[PW_Start_Address+0x212]; + if ( (PW_l>127) || (PW_l==0) ) + { +/*printf ( "#4,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_l holds the size of the pattern list */ + PW_k=0; + for ( PW_j=0 ; PW_j PW_k ) + PW_k = in_data[PW_Start_Address+0x214+PW_j]; + if ( in_data[PW_Start_Address+0x214+PW_j] > 127 ) + { +/*printf ( "#4,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + /* PW_k is the number of pattern in the file (-1) */ + PW_k += 1; + + + /* test #5 pattern data ... */ + if ( ((PW_k*1024)+0x294+PW_Start_Address) > PW_in_size ) + { +/*printf ( "#5,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + return GOOD; +} + diff --git a/prowizard/tests/soundtk.c b/prowizard/tests/soundtk.c new file mode 100755 index 00000000..3f62039a --- /dev/null +++ b/prowizard/tests/soundtk.c @@ -0,0 +1,150 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testSoundTracker ( void ) +{ + /* test 1 */ + /* start of stk before start of file ? */ + if ( (PW_i < 45) || ((PW_i+555)>PW_in_size) ) + { +/*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + + /* test 2 */ + /* samples tests */ + PW_Start_Address = PW_i-45; + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<15 ; PW_k++ ) + { + /* size */ + PW_j = (((in_data[PW_Start_Address+42+PW_k*30]*256)+in_data[PW_Start_Address+43+PW_k*30])*2); + /* loop start */ + PW_m = (((in_data[PW_Start_Address+46+PW_k*30]*256)+in_data[PW_Start_Address+47+PW_k*30])*2); + /* loop size */ + PW_n = (((in_data[PW_Start_Address+48+PW_k*30]*256)+in_data[PW_Start_Address+49+PW_k*30])*2); + /* all sample sizes */ + PW_WholeSampleSize += PW_j; + + /* size,loopstart,replen > 64k ? */ + if ( (PW_j > 0xFFFF) || (PW_m > 0xFFFF) || (PW_n > 0xFFFF) ) + { +/*printf ( "#2,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* replen > size ? */ + if ( PW_n > (PW_j+2) ) + { +/*printf ( "#2 (Start:%ld) (smp:%ld) (size:%ld) (replen:%ld)\n" + , PW_Start_Address , PW_k+1 , PW_j , PW_n );*/ + return BAD; + } + /* loop start > size ? */ + if ( PW_m > PW_j ) + { +/*printf ( "#2,0 (Start:%ld) (smp:%ld) (size:%ld) (lstart:%ld)\n" + , PW_Start_Address , PW_k+1 , PW_j , PW_m );*/ + return BAD; + } + /* loop size =0 & loop start != 0 ?*/ + if ( (PW_m != 0) && (PW_n==0) ) + { +/*printf ( "#2,1\n" );*/ + return BAD; + } + /* size & loopstart !=0 & size=loopstart ? */ + if ( (PW_j != 0) && (PW_j==PW_m) ) + { +/*printf ( "#2,15\n" );*/ + return BAD; + } + /* size =0 & loop start !=0 */ + if ( (PW_j==0) && (PW_m!=0) ) + { +/*printf ( "#2,2\n" );*/ + return BAD; + } + } + /* all sample sizes < 8 ? */ + if ( PW_WholeSampleSize<8 ) + { +/*printf ( "#2,3\n" );*/ + return BAD; + } + + /* test #3 finetunes & volumes */ + for ( PW_k=0 ; PW_k<15 ; PW_k++ ) + { + if ( (in_data[PW_Start_Address+44+PW_k*30]>0x0f) || (in_data[PW_Start_Address+45+PW_k*30]>0x40) ) + { +/*printf ( "#3 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test #4 pattern list size */ + PW_l = in_data[PW_Start_Address+470]; + if ( (PW_l>127) || (PW_l==0) ) + { +/*printf ( "#4,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_l holds the size of the pattern list */ + PW_k=0; + for ( PW_j=0 ; PW_j PW_k ) + PW_k = in_data[PW_Start_Address+472+PW_j]; + if ( in_data[PW_Start_Address+472+PW_j] > 127 ) + { +/*printf ( "#4,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + /* PW_k holds the highest pattern number */ + /* test last patterns of the pattern list = 0 ? */ + PW_j += 2; /* found some obscure stk :( */ + while ( PW_j != 128 ) + { + if ( in_data[PW_Start_Address+472+PW_j] != 0 ) + { +/*printf ( "#4,2 (Start:%ld) (PW_j:%ld) (at:%ld)\n" , PW_Start_Address,PW_j ,PW_Start_Address+472+PW_j );*/ + return BAD; + } + PW_j += 1; + } + /* PW_k is the number of pattern in the file (-1) */ + PW_k += 1; + + + /* test #5 pattern data ... */ + if ( ((PW_k*1024)+600+PW_Start_Address) > PW_in_size ) + { +/*printf ( "#5,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + for ( PW_j=0 ; PW_j<(PW_k*256) ; PW_j++ ) + { + /* sample > 1f or pitch > 358 ? */ + if ( in_data[PW_Start_Address+600+PW_j*4] > 0x13 ) + { +/*printf ( "#5.1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_l = ((in_data[PW_Start_Address+600+PW_j*4]&0x0f)*256)+in_data[PW_Start_Address+601+PW_j*4]; + if ( (PW_l>0) && (PW_l<0x71) ) + { +/*printf ( "#5,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + return GOOD; +} diff --git a/prowizard/tests/spike.c b/prowizard/tests/spike.c new file mode 100755 index 00000000..a64d892f --- /dev/null +++ b/prowizard/tests/spike.c @@ -0,0 +1,77 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testSpikeCruncher ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+38] != 0x2C ) || + (in_data[PW_Start_Address+39] != 0x78 ) || + (in_data[PW_Start_Address+40] != 0x00 ) || + (in_data[PW_Start_Address+41] != 0x04 ) || + (in_data[PW_Start_Address+42] != 0x22 ) || + (in_data[PW_Start_Address+43] != 0x4B ) || + (in_data[PW_Start_Address+44] != 0x24 ) || + (in_data[PW_Start_Address+45] != 0x4B ) || + (in_data[PW_Start_Address+46] != 0x2F ) || + (in_data[PW_Start_Address+47] != 0x0B ) || + (in_data[PW_Start_Address+48] != 0x20 ) || + (in_data[PW_Start_Address+49] != 0x3A ) || + (in_data[PW_Start_Address+50] != 0xFF ) || + (in_data[PW_Start_Address+51] != 0xD8 ) || + (in_data[PW_Start_Address+52] != 0xD3 ) || + (in_data[PW_Start_Address+53] != 0xC0 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+10]*256*256*256) + + (in_data[PW_Start_Address+11]*256*256) + + (in_data[PW_Start_Address+12]*256) + + in_data[PW_Start_Address+13] ); + + PW_l += 648; + + if ( PW_i >= 36 ) + { + if ( (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x03 ) || + (in_data[PW_Start_Address-33] != 0xF3 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x00 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x02 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + + return GOOD; + /* PW_l is the size of the pack */ +} diff --git a/prowizard/tests/starpack.c b/prowizard/tests/starpack.c new file mode 100755 index 00000000..cf7cb2f1 --- /dev/null +++ b/prowizard/tests/starpack.c @@ -0,0 +1,180 @@ +/* + * 27 dec 2001 : added some checks to prevent readings outside of + * the input file. +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testSTARPACK ( void ) +{ + /* test 1 */ + if ( (PW_i < 23) || ((PW_i+269-23)>=PW_in_size) ) + { +/*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + + /* test 2 */ + PW_Start_Address = PW_i-23; + PW_l = (in_data[PW_Start_Address+268]*256)+in_data[PW_Start_Address+269]; + PW_k = PW_l/4; + if ( (PW_k*4) != PW_l ) + { +/*printf ( "#2,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_k>127 ) + { +/*printf ( "#2,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_k==0) || ((PW_Start_Address+784)>PW_in_size) ) + { +/*printf ( "#2,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + if ( in_data[PW_Start_Address+784] != 0 ) + { +/*printf ( "#3,-1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test #3 smp size < loop start + loop size ? */ + /* PW_l is still the size of the pattern list */ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + PW_j = (((in_data[PW_Start_Address+20+PW_k*8]*256)+in_data[PW_Start_Address+21+PW_k*8])*2); + PW_m = (((in_data[PW_Start_Address+24+PW_k*8]*256)+in_data[PW_Start_Address+25+PW_k*8])*2) + +(((in_data[PW_Start_Address+26+PW_k*8]*256)+in_data[PW_Start_Address+27+PW_k*8])*2); + if ( (PW_j+2) < PW_m ) + { +/*printf ( "#3 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_WholeSampleSize += PW_j; + } + + /* test #4 finetunes & volumes */ + /* PW_l is still the size of the pattern list */ + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + if ( (in_data[PW_Start_Address+22+PW_k*8]>0x0f) || (in_data[PW_Start_Address+23+PW_k*8]>0x40) ) + { +/*printf ( "#4 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test #5 pattern addresses > sample address ? */ + /* PW_l is still the size of the pattern list */ + /* get sample data address */ + if ( (PW_Start_Address + 0x314) > PW_in_size ) + { +/*printf ( "#5,-1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_k gets address of sample data */ + PW_k = (in_data[PW_Start_Address+784]*256*256*256) + +(in_data[PW_Start_Address+785]*256*256) + +(in_data[PW_Start_Address+786]*256) + +in_data[PW_Start_Address+787]; + if ( (PW_k+PW_Start_Address) > PW_in_size ) + { +/*printf ( "#5,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_k < 788 ) + { +/*printf ( "#5,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_k is the address of the sample data */ + /* pattern addresses > sample address ? */ + for ( PW_j=0 ; PW_j PW_k ) + { +/*printf ( "#5,2 (Start:%ld) (smp addy:%ld) (pat addy:%ld) (pat nbr:%ld) (max:%ld)\n" + , PW_Start_Address + , PW_k + , PW_m + , (PW_j/4) + , PW_l );*/ + return BAD; + } + } + /* test last patterns of the pattern list == 0 ? */ + PW_j += 2; + while ( PW_j<128 ) + { + PW_m = (in_data[PW_Start_Address+272+PW_j*4]*256*256*256) + +(in_data[PW_Start_Address+273+PW_j*4]*256*256) + +(in_data[PW_Start_Address+274+PW_j*4]*256) + +in_data[PW_Start_Address+275+PW_j*4]; + if ( PW_m != 0 ) + { +/*printf ( "#5,3 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_j += 1; + } + + + /* test pattern data */ + /* PW_k is the address of the sample data */ + PW_j = PW_Start_Address + 788; + /* PW_j points on pattern data */ +/*printf ( "PW_j:%ld , PW_k:%ld\n" , PW_j , PW_k );*/ + while ( PW_j<(PW_k+PW_Start_Address-4) ) + { + if ( in_data[PW_j] == 0x80 ) + { + PW_j += 1; + continue; + } + if ( in_data[PW_j] > 0x80 ) + { +/*printf ( "#6 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* empty row ? ... not possible ! */ + if ( (in_data[PW_j] == 0x00) && + (in_data[PW_j+1] == 0x00) && + (in_data[PW_j+2] == 0x00) && + (in_data[PW_j+3] == 0x00) ) + { +/*printf ( "#6,0 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* fx = C .. arg > 64 ? */ + if ( ((in_data[PW_j+2]*0x0f)==0x0C) && (in_data[PW_j+3]>0x40) ) + { +/*printf ( "#6,1 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* fx = D .. arg > 64 ? */ + if ( ((in_data[PW_j+2]*0x0f)==0x0D) && (in_data[PW_j+3]>0x40) ) + { +/*printf ( "#6,2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_j += 4; + } + + return GOOD; +} diff --git a/prowizard/tests/stc270.c b/prowizard/tests/stc270.c new file mode 100755 index 00000000..d78f2829 --- /dev/null +++ b/prowizard/tests/stc270.c @@ -0,0 +1,80 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testStoneCracker270 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x1E ) || + (in_data[PW_Start_Address+17] != 0x3A ) || + (in_data[PW_Start_Address+18] != 0x01 ) || + (in_data[PW_Start_Address+19] != 0x57 ) || + (in_data[PW_Start_Address+20] != 0x1A ) || + (in_data[PW_Start_Address+21] != 0x3A ) || + (in_data[PW_Start_Address+22] != 0x01 ) || + (in_data[PW_Start_Address+23] != 0x60 ) || + (in_data[PW_Start_Address+24] != 0x1C ) || + (in_data[PW_Start_Address+25] != 0x3A ) || + (in_data[PW_Start_Address+26] != 0x01 ) || + (in_data[PW_Start_Address+27] != 0x5D ) || + (in_data[PW_Start_Address+28] != 0x41 ) || + (in_data[PW_Start_Address+29] != 0xFA ) || + (in_data[PW_Start_Address+30] != 0x01 ) || + (in_data[PW_Start_Address+31] != 0x5A ) || + (in_data[PW_Start_Address+32] != 0xD1 ) || + (in_data[PW_Start_Address+33] != 0xFA ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+370]*256*256*256) + + (in_data[PW_Start_Address+371]*256*256) + + (in_data[PW_Start_Address+372]*256) + + in_data[PW_Start_Address+373] ); + + PW_l += 412; + + + if ( PW_i >= 32 ) + { + if ( (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x03 ) || + (in_data[PW_Start_Address-29] != 0xF3 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x01 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/stc299.c b/prowizard/tests/stc299.c new file mode 100755 index 00000000..81bcefc2 --- /dev/null +++ b/prowizard/tests/stc299.c @@ -0,0 +1,78 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testSTC299 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x45 ) || + (in_data[PW_Start_Address+17] != 0xFA ) || + (in_data[PW_Start_Address+18] != 0x00 ) || + (in_data[PW_Start_Address+19] != 0x5e ) || + (in_data[PW_Start_Address+20] != 0x3D ) || + (in_data[PW_Start_Address+21] != 0x5A ) || + (in_data[PW_Start_Address+22] != 0x00 ) || + (in_data[PW_Start_Address+23] != 0x9A ) || + (in_data[PW_Start_Address+24] != 0x18 ) || + (in_data[PW_Start_Address+25] != 0xBC ) || + (in_data[PW_Start_Address+26] != 0x00 ) || + (in_data[PW_Start_Address+27] != 0x81 ) || + (in_data[PW_Start_Address+28] != 0x3D ) || + (in_data[PW_Start_Address+29] != 0x5A ) || + (in_data[PW_Start_Address+30] != 0x00 ) || + (in_data[PW_Start_Address+31] != 0x96 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+352]*256*256*256) + + (in_data[PW_Start_Address+353]*256*256) + + (in_data[PW_Start_Address+354]*256) + + in_data[PW_Start_Address+355] ); + + PW_l += 392; + + + if ( PW_i >= 32 ) + { + if ( (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x03 ) || + (in_data[PW_Start_Address-29] != 0xF3 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x01 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/stc299b.c b/prowizard/tests/stc299b.c new file mode 100755 index 00000000..1bb92845 --- /dev/null +++ b/prowizard/tests/stc299b.c @@ -0,0 +1,78 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testSTC299b ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x45 ) || + (in_data[PW_Start_Address+17] != 0xFA ) || + (in_data[PW_Start_Address+18] != 0x00 ) || + (in_data[PW_Start_Address+19] != 0x5e ) || + (in_data[PW_Start_Address+20] != 0x3D ) || + (in_data[PW_Start_Address+21] != 0x5A ) || + (in_data[PW_Start_Address+22] != 0x00 ) || + (in_data[PW_Start_Address+23] != 0x9A ) || + (in_data[PW_Start_Address+24] != 0x18 ) || + (in_data[PW_Start_Address+25] != 0xBC ) || + (in_data[PW_Start_Address+26] != 0x00 ) || + (in_data[PW_Start_Address+27] != 0x81 ) || + (in_data[PW_Start_Address+28] != 0x3D ) || + (in_data[PW_Start_Address+29] != 0x5A ) || + (in_data[PW_Start_Address+30] != 0x00 ) || + (in_data[PW_Start_Address+31] != 0x96 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+348]*256*256*256) + + (in_data[PW_Start_Address+349]*256*256) + + (in_data[PW_Start_Address+350]*256) + + in_data[PW_Start_Address+351] ); + + PW_l += 388; + + + if ( PW_i >= 32 ) + { + if ( (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x03 ) || + (in_data[PW_Start_Address-29] != 0xF3 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x01 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/stc299d.c b/prowizard/tests/stc299d.c new file mode 100755 index 00000000..f134c00d --- /dev/null +++ b/prowizard/tests/stc299d.c @@ -0,0 +1,78 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testSTC299d ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x45 ) || + (in_data[PW_Start_Address+17] != 0xFA ) || + (in_data[PW_Start_Address+18] != 0x00 ) || + (in_data[PW_Start_Address+19] != 0x58 ) || + (in_data[PW_Start_Address+20] != 0x3D ) || + (in_data[PW_Start_Address+21] != 0x5A ) || + (in_data[PW_Start_Address+22] != 0x00 ) || + (in_data[PW_Start_Address+23] != 0x9A ) || + (in_data[PW_Start_Address+24] != 0x18 ) || + (in_data[PW_Start_Address+25] != 0xBC ) || + (in_data[PW_Start_Address+26] != 0x00 ) || + (in_data[PW_Start_Address+27] != 0x81 ) || + (in_data[PW_Start_Address+28] != 0x3D ) || + (in_data[PW_Start_Address+29] != 0x5A ) || + (in_data[PW_Start_Address+30] != 0x00 ) || + (in_data[PW_Start_Address+31] != 0x96 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+336]*256*256*256) + + (in_data[PW_Start_Address+337]*256*256) + + (in_data[PW_Start_Address+338]*256) + + in_data[PW_Start_Address+339] ); + + PW_l += 384; + + + if ( PW_i >= 32 ) + { + if ( (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x03 ) || + (in_data[PW_Start_Address-29] != 0xF3 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x01 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/stc300.c b/prowizard/tests/stc300.c new file mode 100755 index 00000000..73656d77 --- /dev/null +++ b/prowizard/tests/stc300.c @@ -0,0 +1,78 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testSTC300 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x45 ) || + (in_data[PW_Start_Address+17] != 0xfa ) || + (in_data[PW_Start_Address+18] != 0x00 ) || + (in_data[PW_Start_Address+19] != 0x58 ) || + (in_data[PW_Start_Address+20] != 0x3d ) || + (in_data[PW_Start_Address+21] != 0x5a ) || + (in_data[PW_Start_Address+22] != 0x00 ) || + (in_data[PW_Start_Address+23] != 0x04 ) || + (in_data[PW_Start_Address+24] != 0x18 ) || + (in_data[PW_Start_Address+25] != 0xbc ) || + (in_data[PW_Start_Address+26] != 0x00 ) || + (in_data[PW_Start_Address+27] != 0x81 ) || + (in_data[PW_Start_Address+28] != 0x3c ) || + (in_data[PW_Start_Address+29] != 0x9a ) || + (in_data[PW_Start_Address+30] != 0x18 ) || + (in_data[PW_Start_Address+31] != 0xbc ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+340]*256*256*256) + + (in_data[PW_Start_Address+341]*256*256) + + (in_data[PW_Start_Address+342]*256) + + in_data[PW_Start_Address+343] ); + + PW_l += 392; + + + if ( PW_i >= 32 ) + { + if ( (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x03 ) || + (in_data[PW_Start_Address-29] != 0xF3 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x01 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/stc310.c b/prowizard/tests/stc310.c new file mode 100755 index 00000000..06aa80a4 --- /dev/null +++ b/prowizard/tests/stc310.c @@ -0,0 +1,78 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testSTC310 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x3D ) || + (in_data[PW_Start_Address+17] != 0x58 ) || + (in_data[PW_Start_Address+18] != 0xff ) || + (in_data[PW_Start_Address+19] != 0x1a ) || + (in_data[PW_Start_Address+20] != 0x3d ) || + (in_data[PW_Start_Address+21] != 0x58 ) || + (in_data[PW_Start_Address+22] != 0xff ) || + (in_data[PW_Start_Address+23] != 0x16 ) || + (in_data[PW_Start_Address+24] != 0x16 ) || + (in_data[PW_Start_Address+25] != 0xbc ) || + (in_data[PW_Start_Address+26] != 0x00 ) || + (in_data[PW_Start_Address+27] != 0x81 ) || + (in_data[PW_Start_Address+28] != 0x45 ) || + (in_data[PW_Start_Address+29] != 0xfa ) || + (in_data[PW_Start_Address+30] != 0x01 ) || + (in_data[PW_Start_Address+31] != 0xea ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+524]*256*256*256) + + (in_data[PW_Start_Address+525]*256*256) + + (in_data[PW_Start_Address+526]*256) + + in_data[PW_Start_Address+527] ); + + PW_l += 564; + + + if ( PW_i >= 32 ) + { + if ( (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x03 ) || + (in_data[PW_Start_Address-29] != 0xF3 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x01 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/stim.c b/prowizard/tests/stim.c new file mode 100755 index 00000000..c49ac264 --- /dev/null +++ b/prowizard/tests/stim.c @@ -0,0 +1,81 @@ +/* update on the 3rd of april 2000 */ +/* bug pointes out by Thomas Neumann ... thx */ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testSTIM ( void ) +{ + PW_Start_Address = PW_i; + + /* */ + PW_j = ((in_data[PW_Start_Address+4]*256*256*256)+ + (in_data[PW_Start_Address+5]*256*256)+ + (in_data[PW_Start_Address+6]*256)+ + in_data[PW_Start_Address+7]); + if ( PW_j < 406 ) + { + return BAD; + } + + /* size of the pattern list */ + PW_k = ((in_data[PW_Start_Address+18]*256)+ + in_data[PW_Start_Address+19]); + if ( PW_k > 128 ) + { + return BAD; + } + + /* nbr of pattern saved */ + PW_k = ((in_data[PW_Start_Address+20]*256)+ + in_data[PW_Start_Address+21]); + if ( (PW_k > 64) || (PW_k == 0) ) + { + return BAD; + } + + /* pattern list */ + for ( PW_l=0 ; PW_l<128 ; PW_l++ ) + { + if ( in_data[PW_Start_Address+22+PW_l] > PW_k ) + { + return BAD; + } + } + + /* test sample sizes */ + PW_WholeSampleSize = 0; + for ( PW_l=0 ; PW_l<31 ; PW_l++ ) + { + /* addresse de la table */ + PW_o = PW_Start_Address+PW_j+PW_l*4; + + /* address du sample */ + PW_k = ((in_data[PW_o]*256*256*256)+ + (in_data[PW_o+1]*256*256)+ + (in_data[PW_o+2]*256)+ + in_data[PW_o+3]); + + /* taille du smp */ + PW_m = ((in_data[PW_o+PW_k-PW_l*4]*256)+ + in_data[PW_o+PW_k+1-PW_l*4])*2; + + PW_WholeSampleSize += PW_m; + } + + if ( PW_WholeSampleSize <= 4 ) + { + return BAD; + } + + /* PW_WholeSampleSize is the size of the sample data */ + /* PW_j is the address of the sample desc */ + return GOOD; +} diff --git a/prowizard/tests/stk26.c b/prowizard/tests/stk26.c new file mode 100755 index 00000000..080057a4 --- /dev/null +++ b/prowizard/tests/stk26.c @@ -0,0 +1,43 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +/* Soundtracker 2.6 & IceTracker 1.0 */ +short testSTK26 ( void ) +{ + /* test 1 */ + if ( PW_i < 1464 ) + { + return BAD; + } + + /* test 2 */ + PW_Start_Address = PW_i-1464; + PW_WholeSampleSize = 0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+45+30*PW_j] > 0x40 ) + { +/* printf ( "#1\n" );*/ + return BAD; + } + if ( in_data[PW_Start_Address+44+30*PW_j] > 0x0F ) + { +/* printf ( "#2\n" );*/ + return BAD; + } + PW_WholeSampleSize += (((in_data[PW_Start_Address+42+PW_j*30]*256)+ + in_data[PW_Start_Address+43+PW_j*30])*2); + } + + /* PW_WholeSampleSize is the whole sample size :) */ + return GOOD; +} + diff --git a/prowizard/tests/superc27.c b/prowizard/tests/superc27.c new file mode 100755 index 00000000..41c19a72 --- /dev/null +++ b/prowizard/tests/superc27.c @@ -0,0 +1,77 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testSuperCruncher27 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0xFF ) || + (in_data[PW_Start_Address+17] != 0xE8 ) || + (in_data[PW_Start_Address+18] != 0x22 ) || + (in_data[PW_Start_Address+19] != 0x68 ) || + (in_data[PW_Start_Address+20] != 0x00 ) || + (in_data[PW_Start_Address+21] != 0x04 ) || + (in_data[PW_Start_Address+22] != 0x42 ) || + (in_data[PW_Start_Address+23] != 0xA8 ) || + (in_data[PW_Start_Address+24] != 0x00 ) || + (in_data[PW_Start_Address+25] != 0x04 ) || + (in_data[PW_Start_Address+26] != 0xD3 ) || + (in_data[PW_Start_Address+27] != 0xC9 ) || + (in_data[PW_Start_Address+28] != 0xD3 ) || + (in_data[PW_Start_Address+29] != 0xC9 ) || + (in_data[PW_Start_Address+30] != 0x59 ) || + (in_data[PW_Start_Address+31] != 0x89 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+680]*256*256*256) + + (in_data[PW_Start_Address+681]*256*256) + + (in_data[PW_Start_Address+682]*256) + + in_data[PW_Start_Address+683] ); + + PW_l *= 4; + PW_l += 724; + + if ( PW_i >= 36 ) + { + if ( (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x03 ) || + (in_data[PW_Start_Address-33] != 0xF3 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x00 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x02 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/syncro.c b/prowizard/tests/syncro.c new file mode 100755 index 00000000..1f6d2c4f --- /dev/null +++ b/prowizard/tests/syncro.c @@ -0,0 +1,89 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testSyncroPacker ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x45 ) || + (in_data[PW_Start_Address+17] != 0xFA ) || + (in_data[PW_Start_Address+18] != 0x01 ) || + (in_data[PW_Start_Address+19] != 0x35 ) || + (in_data[PW_Start_Address+20] != 0x14 ) || + (in_data[PW_Start_Address+21] != 0xA0 ) || + (in_data[PW_Start_Address+22] != 0x61 ) || + (in_data[PW_Start_Address+23] != 0x3E ) || + (in_data[PW_Start_Address+24] != 0x67 ) || + (in_data[PW_Start_Address+25] != 0x34 ) || + (in_data[PW_Start_Address+26] != 0x61 ) || + (in_data[PW_Start_Address+27] != 0x3A ) || + (in_data[PW_Start_Address+28] != 0x66 ) || + (in_data[PW_Start_Address+29] != 0x28 ) || + (in_data[PW_Start_Address+30] != 0x70 ) || + (in_data[PW_Start_Address+31] != 0x01 ) || + (in_data[PW_Start_Address+32] != 0x61 ) || + (in_data[PW_Start_Address+33] != 0x36 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+364]*256*256*256) + + (in_data[PW_Start_Address+365]*256*256) + + (in_data[PW_Start_Address+366]*256) + + in_data[PW_Start_Address+367] ); + + PW_l += 405; + PW_m = (PW_l/4)*4; + if ( PW_m != PW_l ) + PW_l = PW_m + 4; + + if ( ((PW_l - 32)+PW_Start_Address) > PW_in_size ) + { +/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + if ( PW_i >= 32 ) + { + if ( (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x03 ) || + (in_data[PW_Start_Address-29] != 0xF3 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x01 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} diff --git a/prowizard/tests/tdd.c b/prowizard/tests/tdd.c new file mode 100755 index 00000000..19a9c8d1 --- /dev/null +++ b/prowizard/tests/tdd.c @@ -0,0 +1,189 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testTheDarkDemon ( void ) +{ + /* test #1 */ + if ( PW_i < 137 ) + { +/*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + PW_Start_Address = PW_i-137; + + /* len of file */ + if ( (PW_Start_Address + 564) >= PW_in_size ) + { +/*printf ( "#1,1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + + /* test #2 (volumes,sample addresses and whole sample size) */ + PW_WholeSampleSize = 0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + /* sample address */ + PW_k = (in_data[PW_Start_Address+PW_j*14+130]*256*256*256) + +(in_data[PW_Start_Address+PW_j*14+131]*256*256) + +(in_data[PW_Start_Address+PW_j*14+132]*256) + + in_data[PW_Start_Address+PW_j*14+133]; + /* sample size */ + PW_l = (((in_data[PW_Start_Address+PW_j*14+134]*256)+in_data[PW_Start_Address+PW_j*14+135])*2); + /* loop start address */ + PW_m = (in_data[PW_Start_Address+PW_j*14+138]*256*256*256) + +(in_data[PW_Start_Address+PW_j*14+139]*256*256) + +(in_data[PW_Start_Address+PW_j*14+140]*256) + + in_data[PW_Start_Address+PW_j*14+141]; + /* loop size (replen) */ + PW_n = (((in_data[PW_Start_Address+PW_j*14+142]*256)+in_data[PW_Start_Address+PW_j*14+143])*2); + + /* volume > 40h ? */ + if ( in_data[PW_Start_Address+PW_j*14+137] > 0x40 ) + { +/*printf ( "#2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* loop start addy < sampl addy ? */ + if ( PW_m < PW_k ) + { +/*printf ( "#2,1 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* addy < 564 ? */ + if ( (PW_k < 564) || (PW_m < 564) ) + { +/*printf ( "#2,2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* loop start > size ? */ + if ( (PW_m-PW_k) > PW_l ) + { +/*printf ( "#2,3 (start:%ld)(SmpAddy:%ld)(loopAddy:%ld)(Size:%ld)\n" + , PW_Start_Address , PW_k , PW_m , PW_l );*/ + return BAD; + } + + /* loop start+replen > size ? */ + if ( ((PW_m-PW_k)+PW_n) > (PW_l+2) ) + { +/*printf ( "#2,31 (start:%ld)(size:%ld)(loopstart:%ld)(replen:%ld)\n" + , PW_Start_Address , PW_l , PW_m-PW_k , PW_n );*/ + return BAD; + } + PW_WholeSampleSize += PW_l; + } + + if ( (PW_WholeSampleSize <= 2) || (PW_WholeSampleSize>(31*65535)) ) + { +/*printf ( "#2,4 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + + /* test #3 (addresses of pattern in file ... possible ?) */ + /* PW_WholeSampleSize is the whole sample size :) */ + if ( (PW_WholeSampleSize + 564) > PW_in_size ) + { +/*printf ( "#3 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test size of pattern list */ + if ( (in_data[PW_Start_Address] > 0x7f) || (in_data[PW_Start_Address]==0x00) ) + { +/*printf ( "#4 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test pattern list */ + PW_k=0; + for ( PW_j=0 ; PW_j<128 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+PW_j+2] > 0x7f ) + { +/*printf ( "#4,01 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + if ( in_data[PW_Start_Address+PW_j+2] > PW_k ) + PW_k = in_data[PW_Start_Address+PW_j+2]; + } + PW_k += 1; + PW_k *= 1024; + + /* test end of pattern list */ + for ( PW_j=in_data[PW_Start_Address]+2 ; PW_j<128 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+PW_j+2] != 0 ) + { +/*printf ( "#4,02 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + + /* test if not out of file range */ + if ( (PW_Start_Address + PW_WholeSampleSize+564+PW_k) > PW_in_size ) + { +/*printf ( "#4,1 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + + /* PW_WholeSampleSize is the whole sample data size */ + /* PW_k is the whole pattern data size */ + /* test pattern data now ... */ + PW_l = PW_Start_Address+564+PW_WholeSampleSize; + /* PW_l points on pattern data */ + for ( PW_j=0 ; PW_j 31 ? */ + if ( in_data[PW_l+PW_j] > 0x1f ) + { +/*printf ( "#5,0 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* note > 0x48 (36*2) */ + if ( (in_data[PW_l+PW_j+1] > 0x48) || ((in_data[PW_l+PW_j+1]&0x01) == 0x01 ) ) + { +/*printf ( "#5,1 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* fx=C and FxArg > 64 ? */ + if ( ((in_data[PW_l+PW_j+2]&0x0f)==0x0c)&&(in_data[PW_l+PW_j+3]>0x40) ) + { +/*printf ( "#5,2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* fx=D and FxArg > 64 ? */ + if ( ((in_data[PW_l+PW_j+2]&0x0f)==0x0d)&&(in_data[PW_l+PW_j+3]>0x40) ) + { +/*printf ( "#5,3 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* fx=B and FxArg > 127 ? */ + if ( ((in_data[PW_l+PW_j+2]&0x0f)==0x0b)&&(in_data[PW_l+PW_j+3]>0x7f) ) + { +/*printf ( "#5,3 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + + + /* let's get free another var .. */ + PW_WholeSampleSize += PW_k; + + return GOOD; +} + + diff --git a/prowizard/tests/time17.c b/prowizard/tests/time17.c new file mode 100755 index 00000000..611d58b9 --- /dev/null +++ b/prowizard/tests/time17.c @@ -0,0 +1,75 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testTimeCruncher17 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+22] != 0x72 ) || + (in_data[PW_Start_Address+23] != 0x03 ) || + (in_data[PW_Start_Address+24] != 0x61 ) || + (in_data[PW_Start_Address+25] != 0x00 ) || + (in_data[PW_Start_Address+26] != 0x00 ) || + (in_data[PW_Start_Address+27] != 0xFC ) || + (in_data[PW_Start_Address+28] != 0x4A ) || + (in_data[PW_Start_Address+29] != 0x02 ) || + (in_data[PW_Start_Address+30] != 0x67 ) || + (in_data[PW_Start_Address+31] != 0x5A ) || + (in_data[PW_Start_Address+32] != 0x0C ) || + (in_data[PW_Start_Address+33] != 0x42 ) || + (in_data[PW_Start_Address+34] != 0x00 ) || + (in_data[PW_Start_Address+35] != 0x07 ) || + (in_data[PW_Start_Address+36] != 0x66 ) || + (in_data[PW_Start_Address+37] != 0x24 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+6]*256*256*256) + + (in_data[PW_Start_Address+7]*256*256) + + (in_data[PW_Start_Address+8]*256) + + in_data[PW_Start_Address+9] ); + + PW_l += 376; + + if ( PW_i >= 36 ) + { + if ( (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x03 ) || + (in_data[PW_Start_Address-33] != 0xF3 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x00 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x02 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} diff --git a/prowizard/tests/tnmc11.c b/prowizard/tests/tnmc11.c new file mode 100755 index 00000000..bd6680fc --- /dev/null +++ b/prowizard/tests/tnmc11.c @@ -0,0 +1,84 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testTNMCruncher11 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x4B ) || + (in_data[PW_Start_Address+17] != 0xFA ) || + (in_data[PW_Start_Address+18] != 0x01 ) || + (in_data[PW_Start_Address+19] != 0x9A ) || + (in_data[PW_Start_Address+20] != 0x41 ) || + (in_data[PW_Start_Address+21] != 0xFA ) || + (in_data[PW_Start_Address+22] != 0xFF ) || + (in_data[PW_Start_Address+23] != 0xE6 ) || + (in_data[PW_Start_Address+24] != 0x20 ) || + (in_data[PW_Start_Address+25] != 0x50 ) || + (in_data[PW_Start_Address+26] != 0xD1 ) || + (in_data[PW_Start_Address+27] != 0xC8 ) || + (in_data[PW_Start_Address+28] != 0xD1 ) || + (in_data[PW_Start_Address+29] != 0xC8 ) || + (in_data[PW_Start_Address+30] != 0x22 ) || + (in_data[PW_Start_Address+31] != 0x50 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+428]*256*256*256) + + (in_data[PW_Start_Address+429]*256*256) + + (in_data[PW_Start_Address+430]*256) + + in_data[PW_Start_Address+431] ); + + PW_l += 680; + + /* unpacked size */ + PW_m = ( (in_data[PW_Start_Address+432]*256*256*256) + + (in_data[PW_Start_Address+433]*256*256) + + (in_data[PW_Start_Address+434]*256) + + in_data[PW_Start_Address+435] ); + + + if ( PW_i >= 40 ) + { + if ( (in_data[PW_Start_Address-40] != 0x00 ) || + (in_data[PW_Start_Address-39] != 0x00 ) || + (in_data[PW_Start_Address-38] != 0x03 ) || + (in_data[PW_Start_Address-37] != 0xF3 ) || + (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x00 ) || + (in_data[PW_Start_Address-33] != 0x00 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x03 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/tp1.c b/prowizard/tests/tp1.c new file mode 100755 index 00000000..9cd3f2fd --- /dev/null +++ b/prowizard/tests/tp1.c @@ -0,0 +1,91 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testTP1 ( void ) +{ + PW_Start_Address = PW_i; + + /* size of the module */ + PW_WholeSampleSize = ( (in_data[PW_Start_Address+4]*256*256*256)+ + (in_data[PW_Start_Address+5]*256*256)+ + (in_data[PW_Start_Address+6]*256)+ + in_data[PW_Start_Address+7] ); + if ( (PW_WholeSampleSize < 794) || (PW_WholeSampleSize > 2129178l) ) + { + return BAD; + } + + /* test finetunes */ + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + if ( in_data[PW_Start_Address+32+PW_k*8] > 0x0f ) + { + return BAD; + } + } + + /* test volumes */ + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + if ( in_data[PW_Start_Address+33+PW_k*8] > 0x40 ) + { + return BAD; + } + } + + /* sample data address */ + PW_l = ( (in_data[PW_Start_Address+28]*256*256*256)+ + (in_data[PW_Start_Address+29]*256*256)+ + (in_data[PW_Start_Address+30]*256)+ + in_data[PW_Start_Address+31] ); + if ( (PW_l == 0) || (PW_l > PW_WholeSampleSize ) ) + { + return BAD; + } + + /* test sample sizes */ + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + PW_j = (in_data[PW_Start_Address+PW_k*8+34]*256)+in_data[PW_Start_Address+PW_k*8+35]; + PW_m = (in_data[PW_Start_Address+PW_k*8+36]*256)+in_data[PW_Start_Address+PW_k*8+37]; + PW_n = (in_data[PW_Start_Address+PW_k*8+38]*256)+in_data[PW_Start_Address+PW_k*8+39]; + PW_j *= 2; + PW_m *= 2; + PW_n *= 2; + if ( (PW_j > 0xFFFF) || + (PW_m > 0xFFFF) || + (PW_n > 0xFFFF) ) + { +/*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_m + PW_n) > (PW_j+2) ) + { +/*printf ( "#5,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_m != 0) && (PW_n <= 2) ) + { +/*printf ( "#5,2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* pattern list size */ + PW_l = in_data[PW_Start_Address+281]; + if ( (PW_l==0) || (PW_l>128) ) + { + return BAD; + } + + /* PW_WholeSampleSize is the size of the module :) */ + return GOOD; +} + diff --git a/prowizard/tests/tp2.c b/prowizard/tests/tp2.c new file mode 100755 index 00000000..b6596280 --- /dev/null +++ b/prowizard/tests/tp2.c @@ -0,0 +1,108 @@ +/* + * bug correction in the lqst test ... + * (Thomas Neumann again ...) +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testTP2 ( void ) +{ + if ( (in_data[PW_i+4] != '_') || + (in_data[PW_i+5] != 'T') || + (in_data[PW_i+6] != 'P') || + (in_data[PW_i+7] != '2') ) + { + /*printf ( "#1 Start: %ld\n" , PW_i );*/ + return BAD; + } + + PW_Start_Address = PW_i; + + /* number of sample */ + PW_l = ( (in_data[PW_Start_Address+28]*256)+ + in_data[PW_Start_Address+29] ); + if ( (((PW_l/8)*8) != PW_l) || (PW_l == 0) ) + { + /*printf ( "#2 Start: %ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_l /= 8; + /* PW_l is the number of sample */ + + /* test finetunes */ + for ( PW_k=0 ; PW_k 0x0f ) + { + /*printf ( "#3 Start: %ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test volumes */ + for ( PW_k=0 ; PW_k 0x40 ) + { + /*printf ( "#4 Start: %ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test sample sizes */ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k 0xFFFF) || + (PW_m > 0xFFFF) || + (PW_n > 0xFFFF) ) + { + /*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_m + PW_n) > (PW_j+2) ) + { + /*printf ( "#5,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_m != 0) && (PW_n <= 2) ) + { + /*printf ( "#5,2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_WholeSampleSize += PW_j; + } + if ( PW_WholeSampleSize <= 4 ) + { + /*printf ( "#5,3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* pattern list size */ + PW_j = in_data[PW_Start_Address+PW_l*8+31]; + if ( (PW_j==0) || (PW_j>128) ) + { + /*printf ( "#6 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* PW_j is the size of the pattern list */ + /* PW_l is the number of sample */ + /* PW_WholeSampleSize is the sample data size */ + return GOOD; +} + diff --git a/prowizard/tests/tp3.c b/prowizard/tests/tp3.c new file mode 100755 index 00000000..0f0b8687 --- /dev/null +++ b/prowizard/tests/tp3.c @@ -0,0 +1,98 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testTP3 ( void ) +{ + + PW_Start_Address = PW_i; + + /* number of sample */ + PW_l = ( (in_data[PW_Start_Address+28]*256)+ + in_data[PW_Start_Address+29] ); + if ( (((PW_l/8)*8) != PW_l) || (PW_l == 0) ) + { +/*printf ( "#2 Start: %ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_l /= 8; + /* PW_l is the number of sample */ + + /* test finetunes */ + for ( PW_k=0 ; PW_k 0x0f ) + { +/*printf ( "#3 Start: %ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test volumes */ + for ( PW_k=0 ; PW_k 0x40 ) + { +/*printf ( "#4 Start: %ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test sample sizes */ + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k 0xFFFF) || + (PW_m > 0xFFFF) || + (PW_n > 0xFFFF) ) + { +/*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_m + PW_n) > (PW_j+2) ) + { +/*printf ( "#5,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + if ( (PW_m != 0) && (PW_n == 0) ) + { +/*printf ( "#5,2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + PW_WholeSampleSize += PW_j; + } + if ( PW_WholeSampleSize <= 4 ) + { +/*printf ( "#5,3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* pattern list size */ + PW_j = in_data[PW_Start_Address+PW_l*8+31]; + if ( (PW_j==0) || (PW_j>128) ) + { +/*printf ( "#6 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* PW_j is the size of the pattern list */ + /* PW_l is the number of sample */ + /* PW_WholeSampleSize is the sample data size */ + return GOOD; +} + diff --git a/prowizard/tests/tpack102.c b/prowizard/tests/tpack102.c new file mode 100755 index 00000000..e2585eee --- /dev/null +++ b/prowizard/tests/tpack102.c @@ -0,0 +1,75 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testTetrapack102 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+20] != 0x20 ) || + (in_data[PW_Start_Address+21] != 0x20 ) || + (in_data[PW_Start_Address+22] != 0xE2 ) || + (in_data[PW_Start_Address+23] != 0x88 ) || + (in_data[PW_Start_Address+24] != 0x66 ) || + (in_data[PW_Start_Address+25] != 0x02 ) || + (in_data[PW_Start_Address+26] != 0x61 ) || + (in_data[PW_Start_Address+27] != 0x34 ) || + (in_data[PW_Start_Address+28] != 0x65 ) || + (in_data[PW_Start_Address+29] != 0x7E ) || + (in_data[PW_Start_Address+30] != 0x72 ) || + (in_data[PW_Start_Address+32] != 0x76 ) || + (in_data[PW_Start_Address+33] != 0x01 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+6]*256*256*256) + + (in_data[PW_Start_Address+7]*256*256) + + (in_data[PW_Start_Address+8]*256) + + in_data[PW_Start_Address+9] ); + + PW_l += 268; + + + if ( PW_i >= 32 ) + { + if ( (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x03 ) || + (in_data[PW_Start_Address-29] != 0xF3 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x01 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/tpack21.c b/prowizard/tests/tpack21.c new file mode 100755 index 00000000..c159f87f --- /dev/null +++ b/prowizard/tests/tpack21.c @@ -0,0 +1,74 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testTetrapack_2_1 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+18] != 0x43 ) || + (in_data[PW_Start_Address+19] != 0xF9 ) || + (in_data[PW_Start_Address+24] != 0x24 ) || + (in_data[PW_Start_Address+25] != 0x60 ) || + (in_data[PW_Start_Address+26] != 0xD5 ) || + (in_data[PW_Start_Address+27] != 0xC9 ) || + (in_data[PW_Start_Address+28] != 0x20 ) || + (in_data[PW_Start_Address+29] != 0x20 ) || + (in_data[PW_Start_Address+30] != 0xE2 ) || + (in_data[PW_Start_Address+31] != 0x88 ) || + (in_data[PW_Start_Address+32] != 0x66 ) || + (in_data[PW_Start_Address+33] != 0x02 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+14]*256*256*256) + + (in_data[PW_Start_Address+15]*256*256) + + (in_data[PW_Start_Address+16]*256) + + in_data[PW_Start_Address+17] ); + + PW_l += 268; + + + if ( PW_i >= 32 ) + { + if ( (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x03 ) || + (in_data[PW_Start_Address-29] != 0xF3 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x01 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/tpack22.c b/prowizard/tests/tpack22.c new file mode 100755 index 00000000..eaa513b4 --- /dev/null +++ b/prowizard/tests/tpack22.c @@ -0,0 +1,100 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testTetrapack_2_2 ( void ) +{ + PW_Start_Address = PW_i; + + if ( in_data[PW_Start_Address] == 0x7E ) + { + if ( (in_data[PW_Start_Address+16] != 0x20 ) || + (in_data[PW_Start_Address+17] != 0x4C ) || + (in_data[PW_Start_Address+18] != 0xD1 ) || + (in_data[PW_Start_Address+19] != 0xFC ) || + (in_data[PW_Start_Address+24] != 0xB3 ) || + (in_data[PW_Start_Address+25] != 0xCC ) || + (in_data[PW_Start_Address+26] != 0x6E ) || + (in_data[PW_Start_Address+27] != 0x08 ) || + (in_data[PW_Start_Address+28] != 0x20 ) || + (in_data[PW_Start_Address+29] != 0x49 ) || + (in_data[PW_Start_Address+30] != 0xD1 ) || + (in_data[PW_Start_Address+31] != 0xFA ) || + (in_data[PW_Start_Address+32] != 0xFF ) || + (in_data[PW_Start_Address+33] != 0xF4 ) ) + { + /* should be enough :))) */ + printf ( "#2 Start:%ld\n" , PW_Start_Address ); + return BAD; + } + } + if ( in_data[PW_Start_Address] == 0x61 ) + { + if ( (in_data[PW_Start_Address+16] != 0x20 ) || + (in_data[PW_Start_Address+17] != 0x4C ) || + (in_data[PW_Start_Address+18] != 0xD1 ) || + (in_data[PW_Start_Address+19] != 0xFC ) || + (in_data[PW_Start_Address+20] != 0xB3 ) || + (in_data[PW_Start_Address+21] != 0xCC ) || + (in_data[PW_Start_Address+22] != 0x6E ) || + (in_data[PW_Start_Address+23] != 0x08 ) || + (in_data[PW_Start_Address+24] != 0x20 ) || + (in_data[PW_Start_Address+25] != 0x49 ) || + (in_data[PW_Start_Address+26] != 0xD1 ) || + (in_data[PW_Start_Address+27] != 0xFA ) || + (in_data[PW_Start_Address+28] != 0xFF ) || + (in_data[PW_Start_Address+29] != 0xF4 ) ) + { + /* should be enough :))) */ + /*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+20]*256*256*256) + + (in_data[PW_Start_Address+21]*256*256) + + (in_data[PW_Start_Address+22]*256) + + in_data[PW_Start_Address+23] ); + + PW_l += 292; + + + if ( PW_i >= 32 ) + { + if ( (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x03 ) || + (in_data[PW_Start_Address-29] != 0xF3 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) || + (in_data[PW_Start_Address-24] != 0x00 ) || + (in_data[PW_Start_Address-23] != 0x00 ) || + (in_data[PW_Start_Address-22] != 0x00 ) || + (in_data[PW_Start_Address-21] != 0x01 ) || + (in_data[PW_Start_Address-20] != 0x00 ) || + (in_data[PW_Start_Address-19] != 0x00 ) || + (in_data[PW_Start_Address-18] != 0x00 ) || + (in_data[PW_Start_Address-17] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/tryit101.c b/prowizard/tests/tryit101.c new file mode 100755 index 00000000..abb951d4 --- /dev/null +++ b/prowizard/tests/tryit101.c @@ -0,0 +1,81 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testTryIt101 ( void ) +{ + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+16] != 0x22 ) || + (in_data[PW_Start_Address+17] != 0x2D ) || + (in_data[PW_Start_Address+18] != 0x00 ) || + (in_data[PW_Start_Address+19] != 0x10 ) || + (in_data[PW_Start_Address+20] != 0x10 ) || + (in_data[PW_Start_Address+21] != 0xD9 ) || + (in_data[PW_Start_Address+22] != 0x53 ) || + (in_data[PW_Start_Address+23] != 0x81 ) || + (in_data[PW_Start_Address+24] != 0x66 ) || + (in_data[PW_Start_Address+25] != 0xFA ) || + (in_data[PW_Start_Address+26] != 0x22 ) || + (in_data[PW_Start_Address+27] != 0x4A ) || + (in_data[PW_Start_Address+28] != 0x20 ) || + (in_data[PW_Start_Address+29] != 0x2D ) || + (in_data[PW_Start_Address+30] != 0x00 ) || + (in_data[PW_Start_Address+31] != 0x14 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+358]*256*256*256) + + (in_data[PW_Start_Address+359]*256*256) + + (in_data[PW_Start_Address+360]*256) + + in_data[PW_Start_Address+361] ); + + PW_l += 1470; + /* not sure about this '+=2' to the size ... */ + /* I have but two exemple filesm so ... exemples please ! */ + PW_l = (((PW_l/4)*4)!=PW_l) ? PW_l + 2 : PW_l; + + + if ( PW_i >= 64 ) + { + if ( (in_data[PW_Start_Address-64] != 0x00 ) || + (in_data[PW_Start_Address-63] != 0x00 ) || + (in_data[PW_Start_Address-62] != 0x03 ) || + (in_data[PW_Start_Address-61] != 0xF3 ) || + (in_data[PW_Start_Address-60] != 0x00 ) || + (in_data[PW_Start_Address-59] != 0x00 ) || + (in_data[PW_Start_Address-58] != 0x00 ) || + (in_data[PW_Start_Address-57] != 0x00 ) || + (in_data[PW_Start_Address-56] != 0x00 ) || + (in_data[PW_Start_Address-55] != 0x00 ) || + (in_data[PW_Start_Address-54] != 0x00 ) || + (in_data[PW_Start_Address-53] != 0x01 ) || + (in_data[PW_Start_Address-52] != 0x00 ) || + (in_data[PW_Start_Address-51] != 0x00 ) || + (in_data[PW_Start_Address-50] != 0x00 ) || + (in_data[PW_Start_Address-49] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else + Amiga_EXE_Header = GOOD; + } + else + Amiga_EXE_Header = BAD; + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/turbosqueezer61.c b/prowizard/tests/turbosqueezer61.c new file mode 100755 index 00000000..7225fba0 --- /dev/null +++ b/prowizard/tests/turbosqueezer61.c @@ -0,0 +1,81 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testTurboSqueezer61 ( void ) +{ + + PW_Start_Address = PW_i; + + if ( (in_data[PW_Start_Address+12] != 0xFF ) || + (in_data[PW_Start_Address+13] != 0xF0 ) || + (in_data[PW_Start_Address+14] != 0xD1 ) || + (in_data[PW_Start_Address+15] != 0xC8 ) || + (in_data[PW_Start_Address+16] != 0xD1 ) || + (in_data[PW_Start_Address+17] != 0xC8 ) || + (in_data[PW_Start_Address+18] != 0x22 ) || + (in_data[PW_Start_Address+19] != 0x58 ) || + (in_data[PW_Start_Address+20] != 0x28 ) || + (in_data[PW_Start_Address+21] != 0x48 ) || + (in_data[PW_Start_Address+22] != 0xD3 ) || + (in_data[PW_Start_Address+23] != 0xC9 ) || + (in_data[PW_Start_Address+24] != 0xD3 ) || + (in_data[PW_Start_Address+25] != 0xC9 ) || + (in_data[PW_Start_Address+26] != 0x58 ) || + (in_data[PW_Start_Address+27] != 0x89 ) || + (in_data[PW_Start_Address+28] != 0x2A ) || + (in_data[PW_Start_Address+29] != 0x49 ) ) + { + /* should be enough :))) */ +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + + } + + + /* packed size */ + PW_l = ( (in_data[PW_Start_Address+484]*256*256*256) + + (in_data[PW_Start_Address+485]*256*256) + + (in_data[PW_Start_Address+486]*256) + + in_data[PW_Start_Address+487] ); + + PW_l += 572; + /* + if ( PW_i >= 40 ) + { + if ( (in_data[PW_Start_Address-40] != 0x00 ) || + (in_data[PW_Start_Address-39] != 0x00 ) || + (in_data[PW_Start_Address-38] != 0x03 ) || + (in_data[PW_Start_Address-37] != 0xF3 ) || + (in_data[PW_Start_Address-36] != 0x00 ) || + (in_data[PW_Start_Address-35] != 0x00 ) || + (in_data[PW_Start_Address-34] != 0x00 ) || + (in_data[PW_Start_Address-33] != 0x00 ) || + (in_data[PW_Start_Address-32] != 0x00 ) || + (in_data[PW_Start_Address-31] != 0x00 ) || + (in_data[PW_Start_Address-30] != 0x00 ) || + (in_data[PW_Start_Address-29] != 0x03 ) || + (in_data[PW_Start_Address-28] != 0x00 ) || + (in_data[PW_Start_Address-27] != 0x00 ) || + (in_data[PW_Start_Address-26] != 0x00 ) || + (in_data[PW_Start_Address-25] != 0x00 ) ) + { + Amiga_EXE_Header = BAD; + } + else*/ + Amiga_EXE_Header = GOOD; + /*} + else + Amiga_EXE_Header = BAD;*/ + + + return GOOD; + /* PW_l is the size of the pack */ +} + diff --git a/prowizard/tests/unic.c b/prowizard/tests/unic.c new file mode 100755 index 00000000..a51cb800 --- /dev/null +++ b/prowizard/tests/unic.c @@ -0,0 +1,444 @@ +/* + * 27 dec 2001 : added some checks to prevent reading outside of input file. + * 18 mar 2003 : a small bug in first test ... +*/ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testUNIC_withID ( void ) +{ + /* test 1 */ + if ( PW_i < 1080 ) + { +/*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + + /* test 2 */ + PW_Start_Address = PW_i-1080; + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + PW_j = (((in_data[PW_Start_Address+42+PW_k*30]*256)+in_data[PW_Start_Address+43+PW_k*30])*2); + PW_WholeSampleSize += PW_j; + PW_n = (((in_data[PW_Start_Address+46+PW_k*30]*256)+in_data[PW_Start_Address+47+PW_k*30])*2) + +(((in_data[PW_Start_Address+48+PW_k*30]*256)+in_data[PW_Start_Address+49+PW_k*30])*2); + if ( (PW_j+2) < PW_n ) + { + /*printf ( "#2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + if ( PW_WholeSampleSize <= 2 ) + { + /*printf ( "#2,1 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test #3 finetunes & volumes */ + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + if ( (in_data[PW_Start_Address+44+PW_k*30]>0x0f) || (in_data[PW_Start_Address+45+PW_k*30]>0x40) ) + { + /*printf ( "#3 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test #4 pattern list size */ + PW_l = in_data[PW_Start_Address+950]; + if ( (PW_l>127) || (PW_l==0) ) + { + /*printf ( "#4,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_l holds the size of the pattern list */ + PW_k=0; + for ( PW_j=0 ; PW_j PW_k ) + PW_k = in_data[PW_Start_Address+952+PW_j]; + if ( in_data[PW_Start_Address+952+PW_j] > 127 ) + { + /*printf ( "#4,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + /* PW_k holds the highest pattern number */ + /* test last patterns of the pattern list = 0 ? */ + while ( PW_j != 128 ) + { + if ( in_data[PW_Start_Address+952+PW_j] != 0 ) + { + /*printf ( "#4,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_j += 1; + } + /* PW_k is the number of pattern in the file (-1) */ + PW_k += 1; + + + /* test #5 pattern data ... */ + if ( ((PW_k*768)+1084+PW_Start_Address) > PW_in_size ) + { + /*printf ( "#5,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + for ( PW_j=0 ; PW_j<(PW_k*256) ; PW_j++ ) + { + /* relative note number + last bit of sample > $34 ? */ + if ( in_data[PW_Start_Address+1084+PW_j*3] > 0x74 ) + { + /*printf ( "#5,1 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1084+PW_j*3 );*/ + return BAD; + } + } + + return GOOD; +} + + +short testUNIC_withemptyID ( void ) +{ + /* test 1 */ + if ( (PW_i < 45) || ((PW_i-45+1084)>=PW_in_size) ) + { + /*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + + /* test #2 ID = $00000000 ? */ + PW_Start_Address = PW_i-45; + if ( (in_data[PW_Start_Address+1080] != 00) + &&(in_data[PW_Start_Address+1081] != 00) + &&(in_data[PW_Start_Address+1082] != 00) + &&(in_data[PW_Start_Address+1083] != 00) ) + { +/*printf ( "#2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test 2,5 :) */ + PW_WholeSampleSize = 0; + PW_o = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + PW_j = (((in_data[PW_Start_Address+42+PW_k*30]*256)+in_data[PW_Start_Address+43+PW_k*30])*2); + PW_m = (((in_data[PW_Start_Address+46+PW_k*30]*256)+in_data[PW_Start_Address+47+PW_k*30])*2); + PW_n = (((in_data[PW_Start_Address+48+PW_k*30]*256)+in_data[PW_Start_Address+49+PW_k*30])*2); + PW_WholeSampleSize += PW_j; + + if ( (PW_n != 0) && ((PW_j+2) < (PW_m+PW_n)) ) + { +/*printf ( "#2 (Start:%ld) (size:%ld)(lstart:%ld)(replen:%ld)\n" , PW_Start_Address,PW_j,PW_m,PW_n );*/ + return BAD; + } + if ( (PW_j>0xffff) || + (PW_m>0xffff) || + (PW_n>0xffff) ) + { +/*printf ( "#2,2 (Start:%ld) (at:%x)\n" , PW_Start_Address,PW_Start_Address+42+PW_k*30 );*/ + return BAD; + } + if ( in_data[PW_Start_Address+45+PW_k*30]>0x40 ) + { +/*printf ( "#3 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* finetune ... */ + if ( ( (((in_data[PW_Start_Address+40+PW_k*30]*256)+in_data[PW_Start_Address+41+PW_k*30]) != 0) && (PW_j == 0) ) || + ( (((in_data[PW_Start_Address+40+PW_k*30]*256)+in_data[PW_Start_Address+41+PW_k*30]) > 8 ) && + (((in_data[PW_Start_Address+40+PW_k*30]*256)+in_data[PW_Start_Address+41+PW_k*30]) < 247) ) ) + { +/*printf ( "#3,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* loop start but no replen ? */ + if ( (PW_m!=0) && (PW_n<=2) ) + { +/*printf ( "#3,15 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + if ( (in_data[PW_Start_Address+45+PW_k*30]!=0) && (PW_j == 0) ) + { +/*printf ( "#3,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* get the highest !0 sample */ + if ( PW_j != 0 ) + PW_o = PW_j+1; + } + if ( PW_WholeSampleSize <= 2 ) + { +/*printf ( "#2,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + + /* test #4 pattern list size */ + PW_l = in_data[PW_Start_Address+950]; + if ( (PW_l>127) || (PW_l==0) ) + { +/*printf ( "#4,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_l holds the size of the pattern list */ + PW_k=0; + for ( PW_j=0 ; PW_j PW_k ) + PW_k = in_data[PW_Start_Address+952+PW_j]; + if ( in_data[PW_Start_Address+952+PW_j] > 127 ) + { +/*printf ( "#4,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + /* PW_k holds the highest pattern number */ + /* test last patterns of the pattern list = 0 ? */ + while ( PW_j != 128 ) + { + if ( in_data[PW_Start_Address+952+PW_j] != 0 ) + { +/*printf ( "#4,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_j += 1; + } + /* PW_k is the number of pattern in the file (-1) */ + PW_k += 1; + + + /* test #5 pattern data ... */ + if ( ((PW_k*768)+1084+PW_Start_Address) > PW_in_size ) + { +/*printf ( "#5,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + for ( PW_j=0 ; PW_j<(PW_k*256) ; PW_j++ ) + { + /* relative note number + last bit of sample > $34 ? */ + if ( in_data[PW_Start_Address+1084+PW_j*3] > 0x74 ) + { +/*printf ( "#5,1 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1084+PW_j*3 );*/ + return BAD; + } + if ( (in_data[PW_Start_Address+1084+PW_j*3]&0x3F) > 0x24 ) + { +/*printf ( "#5,2 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1084+PW_j*3 );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+1084+PW_j*3+1]&0x0F) == 0x0C) && + (in_data[PW_Start_Address+1084+PW_j*3+2] > 0x40) ) + { +/*printf ( "#5,3 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1084+PW_j*3+1 );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+1084+PW_j*3+1]&0x0F) == 0x0B) && + (in_data[PW_Start_Address+1084+PW_j*3+2] > 0x7F) ) + { +/*printf ( "#5,4 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1084+PW_j*3+1 );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+1084+PW_j*3+1]&0x0F) == 0x0D) && + (in_data[PW_Start_Address+1084+PW_j*3+2] > 0x40) ) + { +/*printf ( "#5,5 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1084+PW_j*3+2 );*/ + return BAD; + } + PW_n = ((in_data[PW_Start_Address+1084+PW_j*3]>>2)&0x30)|((in_data[PW_Start_Address+1085+PW_j*3+1]>>4)&0x0F); + if ( PW_n > PW_o ) + { +/*printf ( "#5,3 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1084+PW_j*3 );*/ + return BAD; + } + } + + return GOOD; +} + + + +short testUNIC_noID ( void ) +{ + /* test 1 */ + if ( (PW_i < 45) || ((PW_i-45+1083)>=PW_in_size) ) + { + /* printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + + /* test #2 ID = $00000000 ? */ + PW_Start_Address = PW_i-45; + if ( (in_data[PW_Start_Address+1080] == 00) + &&(in_data[PW_Start_Address+1081] == 00) + &&(in_data[PW_Start_Address+1082] == 00) + &&(in_data[PW_Start_Address+1083] == 00) ) + { +/*printf ( "#2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test 2,5 :) */ + PW_WholeSampleSize=0; + PW_o = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + PW_j = (((in_data[PW_Start_Address+42+PW_k*30]*256)+in_data[PW_Start_Address+43+PW_k*30])*2); + PW_m = (((in_data[PW_Start_Address+46+PW_k*30]*256)+in_data[PW_Start_Address+47+PW_k*30])*2); + PW_n = (((in_data[PW_Start_Address+48+PW_k*30]*256)+in_data[PW_Start_Address+49+PW_k*30])*2); + PW_WholeSampleSize += PW_j; + if ( (PW_n!=0) && ((PW_j+2) < (PW_m+PW_n)) ) + { +/*printf ( "#2,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* samples too big ? */ + if ( (PW_j>0xffff) || + (PW_m>0xffff) || + (PW_n>0xffff) ) + { +/*printf ( "#2,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* volume too big */ + if ( in_data[PW_Start_Address+45+PW_k*30]>0x40 ) + { +/*printf ( "#3 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* finetune ... */ + if ( ( (((in_data[PW_Start_Address+40+PW_k*30]*256)+in_data[PW_Start_Address+41+PW_k*30]) != 0) && (PW_j == 0) ) || + ( (((in_data[PW_Start_Address+40+PW_k*30]*256)+in_data[PW_Start_Address+41+PW_k*30]) > 8 ) && + (((in_data[PW_Start_Address+40+PW_k*30]*256)+in_data[PW_Start_Address+41+PW_k*30]) < 247) ) ) + { +/*printf ( "#3,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* loop start but no replen ? */ + if ( (PW_m!=0) && (PW_n<=2) ) + { +/*printf ( "#3,15 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + if ( (in_data[PW_Start_Address+45+PW_k*30]!=0) && (PW_j == 0) ) + { +/*printf ( "#3,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* get the highest !0 sample */ + if ( PW_j != 0 ) + PW_o = PW_j+1; + } + if ( PW_WholeSampleSize <= 2 ) + { +/*printf ( "#3,3 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + + /* test #4 pattern list size */ + PW_l = in_data[PW_Start_Address+950]; + if ( (PW_l>127) || (PW_l==0) ) + { +/*printf ( "#4,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_l holds the size of the pattern list */ + PW_k=0; + for ( PW_j=0 ; PW_j PW_k ) + PW_k = in_data[PW_Start_Address+952+PW_j]; + if ( in_data[PW_Start_Address+952+PW_j] > 127 ) + { +/*printf ( "#4,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + /* PW_k holds the highest pattern number */ + /* test last patterns of the pattern list = 0 ? */ + while ( PW_j != 128 ) + { + if ( in_data[PW_Start_Address+952+PW_j] != 0 ) + { +/*printf ( "#4,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_j += 1; + } + /* PW_k is the number of pattern in the file (-1) */ + PW_k += 1; + + + /* test #5 pattern data ... */ + /* PW_o is the highest !0 sample */ + if ( ((PW_k*768)+1080+PW_Start_Address) > PW_in_size ) + { +/*printf ( "#5,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + for ( PW_j=0 ; PW_j<(PW_k*256) ; PW_j++ ) + { + /* relative note number + last bit of sample > $34 ? */ + if ( in_data[PW_Start_Address+1080+PW_j*3] > 0x74 ) + { +/*printf ( "#5,1 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1080+PW_j*3 );*/ + return BAD; + } + if ( (in_data[PW_Start_Address+1080+PW_j*3]&0x3F) > 0x24 ) + { +/*printf ( "#5,2 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1080+PW_j*3 );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+1080+PW_j*3+1]&0x0F) == 0x0C) && + (in_data[PW_Start_Address+1080+PW_j*3+2] > 0x40) ) + { +/*printf ( "#5,3 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1080+PW_j*3+1 );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+1080+PW_j*3+1]&0x0F) == 0x0B) && + (in_data[PW_Start_Address+1080+PW_j*3+2] > 0x7F) ) + { +/*printf ( "#5,4 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1080+PW_j*3+1 );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+1080+PW_j*3+1]&0x0F) == 0x0D) && + (in_data[PW_Start_Address+1080+PW_j*3+2] > 0x40) ) + { +/*printf ( "#5,5 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1080+PW_j*3+2 );*/ + return BAD; + } + PW_n = ((in_data[PW_Start_Address+1080+PW_j*3]>>2)&0x30)|((in_data[PW_Start_Address+1081+PW_j*3+1]>>4)&0x0F); + if ( PW_n > PW_o ) + { +/*printf ( "#5,9 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1080+PW_j*3 );*/ + return BAD; + } + } + + /* test #6 title coherent ? */ + for ( PW_j=0 ; PW_j<20 ; PW_j++ ) + { + if ( ((in_data[PW_Start_Address+PW_j] != 0) + &&(in_data[PW_Start_Address+PW_j] < 32)) + ||(in_data[PW_Start_Address+PW_j] > 180) ) + { +/*printf ( "#6 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + return GOOD; + /* PW_k is still the number of pattern */ +} + diff --git a/prowizard/tests/unic2.c b/prowizard/tests/unic2.c new file mode 100755 index 00000000..3d284586 --- /dev/null +++ b/prowizard/tests/unic2.c @@ -0,0 +1,158 @@ +/* update on the 3rd of april 2000 */ +/* bugs pointed out by Thomas Neumann .. thx :) */ + +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testUNIC2 ( void ) +{ + /* test 1 */ + if ( (PW_i < 25) || ((PW_i+1828)>=PW_in_size) ) /* 1828=Head+1 pat */ + { +/*printf ( "#1 (PW_i:%ld)\n" , PW_i );*/ + return BAD; + } + + /* test #2 ID = $00000000 ? */ + PW_Start_Address = PW_i-25; + if ( (in_data[PW_Start_Address+1060] == 00) + &&(in_data[PW_Start_Address+1061] == 00) + &&(in_data[PW_Start_Address+1062] == 00) + &&(in_data[PW_Start_Address+1063] == 00) ) + { +/*printf ( "#2 (start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test 2,5 :) */ + PW_o=0; + PW_WholeSampleSize = 0; + for ( PW_k=0 ; PW_k<31 ; PW_k++ ) + { + PW_j = ((in_data[PW_Start_Address+22+PW_k*30]*256)+in_data[PW_Start_Address+23+PW_k*30]); + PW_m = ((in_data[PW_Start_Address+26+PW_k*30]*256)+in_data[PW_Start_Address+27+PW_k*30]); + PW_n = ((in_data[PW_Start_Address+28+PW_k*30]*256)+in_data[PW_Start_Address+29+PW_k*30]); + PW_WholeSampleSize += (PW_j*2); + if ( test_smps ( PW_j, PW_m, PW_n, in_data[PW_Start_Address+25+PW_k*30], 0) == BAD ) + { +/*printf ( "#2,1 (Start:%ld) (PW_j:%ld) (PW_m:%ld) (PW_n:%ld) (PW_k:%ld)\n" , PW_Start_Address,PW_j,PW_m,PW_n,PW_k );*/ + return BAD; + } + if ( (PW_j>0x7fff) || + (PW_m>0x7fff) || + (PW_n>0x7fff) ) + { +/*printf ( "#2,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + if ( (((in_data[PW_Start_Address+20+PW_k*30]*256)+in_data[PW_Start_Address+21+PW_k*30]) != 0) && (PW_j == 0) ) + { +/*printf ( "#3,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + if ( (in_data[PW_Start_Address+25+PW_k*30]!=0) && (PW_j == 0) ) + { +/*printf ( "#3,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* get the highest !0 sample */ + if ( PW_j != 0 ) + PW_o = PW_j+1; + } + if ( PW_WholeSampleSize <= 2 ) + { +/*printf ( "#3,3 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + + /* test #4 pattern list size */ + PW_l = in_data[PW_Start_Address+930]; + if ( (PW_l>127) || (PW_l==0) ) + { +/*printf ( "#4,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_l holds the size of the pattern list */ + PW_k=0; + for ( PW_j=0 ; PW_j PW_k ) + PW_k = in_data[PW_Start_Address+932+PW_j]; + if ( in_data[PW_Start_Address+932+PW_j] > 127 ) + { +/*printf ( "#4,1 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + /* PW_k holds the highest pattern number */ + /* test last patterns of the pattern list = 0 ? */ + PW_j += 2; /* just to be sure .. */ + while ( PW_j != 128 ) + { + if ( in_data[PW_Start_Address+932+PW_j] != 0 ) + { +/*printf ( "#4,2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_j += 1; + } + /* PW_k is the number of pattern in the file (-1) */ + PW_k += 1; + + + /* test #5 pattern data ... */ + if ( ((PW_k*768)+1060+PW_Start_Address+PW_WholeSampleSize) > PW_in_size ) + { +/*printf ( "#5,0 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + for ( PW_j=0 ; PW_j<(PW_k*256) ; PW_j++ ) + { + /* relative note number + last bit of sample > $34 ? */ + if ( in_data[PW_Start_Address+1060+PW_j*3] > 0x74 ) + { +/*printf ( "#5,1 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1060+PW_j*3 );*/ + return BAD; + } + if ( (in_data[PW_Start_Address+1060+PW_j*3]&0x3F) > 0x24 ) + { +/*printf ( "#5,2 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1060+PW_j*3 );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+1060+PW_j*3+1]&0x0F) == 0x0C) && + (in_data[PW_Start_Address+1060+PW_j*3+2] > 0x40) ) + { +/*printf ( "#5,3 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1060+PW_j*3+1 );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+1060+PW_j*3+1]&0x0F) == 0x0B) && + (in_data[PW_Start_Address+1060+PW_j*3+2] > 0x7F) ) + { +/*printf ( "#5,4 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1060+PW_j*3+1 );*/ + return BAD; + } + if ( ((in_data[PW_Start_Address+1060+PW_j*3+1]&0x0F) == 0x0D) && + (in_data[PW_Start_Address+1060+PW_j*3+2] > 0x40) ) + { +/*printf ( "#5,5 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1060+PW_j*3+2 );*/ + return BAD; + } + PW_n = ((in_data[PW_Start_Address+1060+PW_j*3]>>2)&0x30)|((in_data[PW_Start_Address+1061+PW_j*3+1]>>4)&0x0F); + if ( PW_n > PW_o ) + { +/*printf ( "#5,6 (Start:%ld) (where:%ld)\n" , PW_Start_Address,PW_Start_Address+1060+PW_j*3 );*/ + return BAD; + } + } + + return GOOD; +} + diff --git a/prowizard/tests/wn.c b/prowizard/tests/wn.c new file mode 100755 index 00000000..5653daa7 --- /dev/null +++ b/prowizard/tests/wn.c @@ -0,0 +1,35 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + + +short testWN ( void ) +{ + /* test 1 */ + if ( PW_i < 1080 ) + { + return BAD; + } + + /* test 2 */ + PW_Start_Address = PW_i-1080; + if ( in_data[PW_Start_Address+951] != 0x7f ) + { + return BAD; + } + + /* test 3 */ + if ( in_data[PW_Start_Address+950] > 0x7f ) + { + return BAD; + } + + return GOOD; +} + diff --git a/prowizard/tests/xann.c b/prowizard/tests/xann.c new file mode 100755 index 00000000..335e3814 --- /dev/null +++ b/prowizard/tests/xann.c @@ -0,0 +1,104 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testXANN ( void ) +{ + /* test 1 */ + if ( PW_i < 3 ) + { + return BAD; + } + + /* test 2 */ + PW_Start_Address = PW_i - 3; + for ( PW_l=0 ; PW_l<128 ; PW_l++ ) + { + PW_j = (in_data[PW_Start_Address+PW_l*4]*256*256*256) + +(in_data[PW_Start_Address+PW_l*4+1]*256*256) + +(in_data[PW_Start_Address+PW_l*4+2]*256) + +in_data[PW_Start_Address+PW_l*4+3]; + PW_k = (PW_j/4)*4; + if ( (PW_k != PW_j) || (PW_j>132156) ) + { +/*printf ( "#2 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test 3 */ + if ( (PW_in_size - PW_Start_Address) < 2108) + { +/*printf ( "#3 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + + /* test 4 */ + for ( PW_j=0 ; PW_j<64 ; PW_j++ ) + { + if ( (in_data[PW_Start_Address+3+PW_j*4] != 0x3c) && + (in_data[PW_Start_Address+3+PW_j*4] != 0x00) ) + { +/*printf ( "#4 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* test 5 */ + PW_WholeSampleSize = 0; + for ( PW_j=0 ; PW_j<31 ; PW_j++ ) + { + if ( in_data[PW_Start_Address+519+16*PW_j] > 0x40 ) + { +/*printf ( "#5 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + PW_WholeSampleSize += (((in_data[PW_Start_Address+530+PW_j*16]*256)+in_data[PW_Start_Address+531+PW_j*16])*2); + } + + /* test #6 (address of samples) */ + for ( PW_l=0 ; PW_l<30 ; PW_l++ ) + { + PW_k = (in_data[PW_Start_Address+526+16*PW_l]*256*256*256) + +(in_data[PW_Start_Address+527+16*PW_l]*256*256) + +(in_data[PW_Start_Address+528+16*PW_l]*256) + +in_data[PW_Start_Address+529+16*PW_l]; + PW_j = (((in_data[PW_Start_Address+524+16*PW_l]*256) + +in_data[PW_Start_Address+525+16*PW_l])*2); + PW_m = (in_data[PW_Start_Address+520+16*(PW_l+1)]*256*256*256) + +(in_data[PW_Start_Address+521+16*(PW_l+1)]*256*256) + +(in_data[PW_Start_Address+522+16*(PW_l+1)]*256) + +in_data[PW_Start_Address+523+16*(PW_l+1)]; + if ( (PW_k<2108) || (PW_m<2108) ) + { +/*printf ( "#6 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + if ( PW_k > PW_m ) + { +/*printf ( "#6,1 (Start:%ld) (PW_k:%ld) (PW_j:%ld) (PW_m:%ld)\n" , PW_Start_Address,PW_k,PW_j,PW_m );*/ + return BAD; + } + } + + /* test #7 first pattern data .. */ + for ( PW_j=0 ; PW_j<256 ; PW_j++ ) + { + PW_k = (in_data[PW_Start_Address+PW_j*4+1085]/2); + PW_l = PW_k*2; + if ( in_data[PW_Start_Address+PW_j*4+1085] != PW_l ) + { +/*printf ( "#7 (Start:%ld)\n" , PW_Start_Address );*/ + return BAD; + } + } + + return GOOD; +} + diff --git a/prowizard/tests/xm.c b/prowizard/tests/xm.c new file mode 100755 index 00000000..03facb09 --- /dev/null +++ b/prowizard/tests/xm.c @@ -0,0 +1,51 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testXM ( void ) +{ + /* test #1 */ + PW_Start_Address = PW_i; + if ( (PW_Start_Address + 336) > PW_in_size) + { + /*printf ( "#1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + if ( (in_data[PW_Start_Address + 37] != 0x1A ) || (in_data[PW_Start_Address+58] != 0x04) ) + { + /*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* get header siz */ + PW_l = ( (in_data[PW_Start_Address+63]*256*256*256)+ + (in_data[PW_Start_Address+62]*256*256)+ + (in_data[PW_Start_Address+61]*256)+ + in_data[PW_Start_Address+60] ); + /* get number of patterns */ + PW_j = (in_data[PW_Start_Address + 71]*256) + in_data[PW_Start_Address + 70]; + /* get number of instruments */ + PW_k = (in_data[PW_Start_Address + 73]*256) + in_data[PW_Start_Address + 72]; + + if ( (PW_j>256)||(PW_k>128) ) + { +printf ( "#3 Start:%ld\n" , PW_Start_Address ); + return BAD; + } + + PW_l += 60; /* points now on the first pattern data */ + + + /* PW_l is the header size and points on the first pattern */ + /* PW_j is the number of pattern */ + /* PW_k is the number of instruments */ + return GOOD; +} + diff --git a/prowizard/tests/zen.c b/prowizard/tests/zen.c new file mode 100755 index 00000000..d70ac2bb --- /dev/null +++ b/prowizard/tests/zen.c @@ -0,0 +1,118 @@ +#ifdef DOS +#include "..\include\globals.h" +#include "..\include\extern.h" +#endif + +#ifdef UNIX +#include "../include/globals.h" +#include "../include/extern.h" +#endif + +short testZEN ( void ) +{ + /* test #1 */ + if ( PW_i<9 ) + { + return BAD; + } + + /* test #2 */ + PW_Start_Address = PW_i-9; + PW_l = ( (in_data[PW_Start_Address]*256*256*256)+ + (in_data[PW_Start_Address+1]*256*256)+ + (in_data[PW_Start_Address+2]*256)+ + in_data[PW_Start_Address+3] ); + if ( (PW_l<502) || (PW_l>2163190l) || (PW_l>(PW_in_size-PW_Start_Address)) ) + { +/*printf ( "#1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* PW_l is the address of the pattern list */ + + /* volumes */ + for ( PW_k = 0 ; PW_k < 31 ; PW_k ++ ) + { + if ( (( PW_Start_Address + 9 + (16*PW_k) ) > PW_in_size )|| + (( in_data[PW_Start_Address + 9 + (16*PW_k)] > 0x40 ))) + { +/*printf ( "#2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* fine */ + for ( PW_k = 0 ; PW_k < 31 ; PW_k ++ ) + { + PW_j = (in_data[PW_Start_Address+6+(PW_k*16)]*256)+in_data[PW_Start_Address+7+(PW_k*16)]; + if ( ((PW_j/72)*72) != PW_j ) + { +/*printf ( "#3 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + } + + /* smp sizes .. */ + PW_n = 0; + for ( PW_k = 0 ; PW_k < 31 ; PW_k ++ ) + { + PW_o = (in_data[PW_Start_Address+10+PW_k*16]*256)+in_data[PW_Start_Address+11+PW_k*16]; + PW_m = (in_data[PW_Start_Address+12+PW_k*16]*256)+in_data[PW_Start_Address+13+PW_k*16]; + PW_j = ((in_data[PW_Start_Address+14+PW_k*16]*256*256*256)+ + (in_data[PW_Start_Address+15+PW_k*16]*256*256)+ + (in_data[PW_Start_Address+16+PW_k*16]*256)+ + in_data[PW_Start_Address+17+PW_k*16] ); + PW_o *= 2; + PW_m *= 2; + /* sample size and loop size > 64k ? */ + if ( (PW_o > 0xFFFF)|| + (PW_m > 0xFFFF) ) + { +/*printf ( "#4 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* sample address < pattern table address ? */ + if ( PW_j < PW_l ) + { +/*printf ( "#4,1 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* too big an address ? */ + if ( PW_j > PW_in_size ) + { +/*printf ( "#4,2 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + /* get the nbr of the highest sample address and its size */ + if ( PW_j > PW_n ) + { + PW_n = PW_j; + PW_WholeSampleSize = PW_o; + } + } + /* PW_n is the highest sample data address */ + /* PW_WholeSampleSize is the size of the same sample */ + + /* test size of the pattern list */ + PW_j = in_data[PW_Start_Address+5]; + if ( (PW_j > 0x7f) || (PW_j == 0) ) + { +/*printf ( "#5 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + + /* test if the end of pattern list is $FFFFFFFF */ + if ( (in_data[PW_Start_Address+PW_l+PW_j*4] != 0xFF ) || + (in_data[PW_Start_Address+PW_l+PW_j*4+1] != 0xFF ) || + (in_data[PW_Start_Address+PW_l+PW_j*4+2] != 0xFF ) || + (in_data[PW_Start_Address+PW_l+PW_j*4+3] != 0xFF ) ) + { +/*printf ( "#6 Start:%ld\n" , PW_Start_Address );*/ + return BAD; + } + + /* PW_n is the highest address of a sample data */ + /* PW_WholeSampleSize is its size */ + return GOOD; +} + diff --git a/savestate.c b/savestate.c index bf4a5f98..c7db03a7 100755 --- a/savestate.c +++ b/savestate.c @@ -76,7 +76,7 @@ static uae_u8 *replaybuffer, *replaybufferend; static int savestate_docompress, savestate_ramdump; static int replaybuffersize; -char savestate_fname[MAX_PATH]; +char savestate_fname[MAX_DPATH]; static struct staterecord staterecords[MAX_STATERECORDS]; static unsigned long crc_table[256]; diff --git a/zfile.c b/zfile.c index 3cec8f2c..52e88e24 100755 --- a/zfile.c +++ b/zfile.c @@ -231,7 +231,7 @@ static struct zfile *gunzip (struct zfile *z) int i, size, ret, first; uae_u8 flags; long offset; - char name[MAX_PATH]; + char name[MAX_DPATH]; uae_u8 buffer[8192]; struct zfile *z2; uae_u8 b; @@ -354,19 +354,17 @@ static char *ignoreextensions[] = static char *diskimageextensions[] = { ".adf", ".adz", ".ipf", ".fdi", 0 }; -static void maybe_add_disk_history (char *zname, char *name) +static int isdiskimage (char *name) { - char tmp[2048]; int i; i = 0; while (diskimageextensions[i]) { - if (strlen (name) > 3 && !strcasecmp (name + strlen (name) - 4, diskimageextensions[i])) { - sprintf (tmp, "%s/%s", zname, name); - DISK_history_add (tmp, -1); - } + if (strlen (name) > 3 && !strcasecmp (name + strlen (name) - 4, diskimageextensions[i])) + return 1; i++; } + return 0; } static struct zfile *unzip (struct zfile *z) @@ -376,6 +374,8 @@ static struct zfile *unzip (struct zfile *z) char filename_inzip[2048]; struct zfile *zf; int err, zipcnt, select, i, we_have_file = 0; + char tmphist[MAX_DPATH]; + int first = 1; if (!zlib_test ()) return z; @@ -387,6 +387,7 @@ static struct zfile *unzip (struct zfile *z) return z; write_log("checking zip file '%s':\n", z->name); zipcnt = 1; + tmphist[0] = 0; for (;;) { err = unzGetCurrentFileInfo(uz,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); if (err != UNZ_OK) @@ -403,7 +404,19 @@ static struct zfile *unzip (struct zfile *z) if (ignoreextensions[i]) { write_log ("[ignored]"); } else { - maybe_add_disk_history (z->name, filename_inzip); + if (tmphist[0]) { + DISK_history_add (tmphist, -1); + tmphist[0] = 0; + first = 0; + } + if (first) { + if (isdiskimage (filename_inzip)) + sprintf (tmphist," %s/%s", z->name, filename_inzip); + } else { + sprintf (tmphist," %s/%s", z->name, filename_inzip); + DISK_history_add (tmphist, -1); + tmphist[0] = 0; + } write_log ("[check]"); select = 0; if (!z->zipname) -- 2.47.3