From c5f4f6ba252985d9c07a45cee7821b66eaa22032 Mon Sep 17 00:00:00 2001 From: Gwen Gourevich <=> Date: Wed, 27 Oct 2021 10:34:18 +0200 Subject: [PATCH] Initial commit --- LIB386/LIB_3D/BUILD.BAT | 13 + LIB386/LIB_3D/LIB_3D.H | 123 + LIB386/LIB_3D/MAKEFILE | 60 + LIB386/LIB_3D/P_ANIM.ASM | 1115 ++++++ LIB386/LIB_3D/P_DEFINE.ASH | 38 + LIB386/LIB_3D/P_FUNC.ASM | 1259 +++++++ LIB386/LIB_3D/P_OBJET.ASM | 1749 ++++++++++ LIB386/LIB_3D/P_OBJ_3D.ASM | 1712 ++++++++++ LIB386/LIB_3D/P_OB_ISO.ASM | 1736 ++++++++++ LIB386/LIB_3D/P_SINTAB.ASM | 276 ++ LIB386/LIB_3D/P_TRIGO.ASM | 1764 ++++++++++ LIB386/LIB_CD/BUILD.BAT | 5 + LIB386/LIB_CD/CDROM.ASM | 1124 ++++++ LIB386/LIB_CD/LIB_CD.H | 79 + LIB386/LIB_CD/LIB_CD.MAK | 31 + LIB386/LIB_CD/M.BAT | 2 + LIB386/LIB_MENU/ASM_SORT.ASM | 41 + LIB386/LIB_MENU/BUILD.BAT | 13 + LIB386/LIB_MENU/LIB_MENU.H | 157 + LIB386/LIB_MENU/MAKEFILE | 61 + LIB386/LIB_MENU/MENU.C | 1056 ++++++ LIB386/LIB_MENU/MENUFUNC.C | 489 +++ LIB386/LIB_MENU/SELECTOR.C | 554 +++ LIB386/LIB_MIDI/BUILD.BAT | 15 + LIB386/LIB_MIDI/INCLUDE.C | 7 + LIB386/LIB_MIDI/LIB_MIDI.H | 28 + LIB386/LIB_MIDI/MAKEFILE | 57 + LIB386/LIB_MIDI/MIDI.C | 461 +++ LIB386/LIB_MIDI/README.md | 41 + LIB386/LIB_MIX/BUILD.BAT | 13 + LIB386/LIB_MIX/BUILDDLL.BAT | 3 + LIB386/LIB_MIX/LIB_MIX.H | 85 + LIB386/LIB_MIX/MAKEFILE | 54 + LIB386/LIB_MIX/MIXER.C | 50 + LIB386/LIB_MIX/MIXER_A.ASM | 1384 ++++++++ LIB386/LIB_MIX/MIXER_I.ASM | 83 + LIB386/LIB_MIX/MIX_DLL.MAK | 52 + LIB386/LIB_SAMP/BALANCE.ASM | 44 + LIB386/LIB_SAMP/BALANCE.H | 3 + LIB386/LIB_SAMP/BUILD.BAT | 15 + LIB386/LIB_SAMP/BUILDDLL.BAT | 3 + LIB386/LIB_SAMP/DMA_CODE.ASM | 378 +++ LIB386/LIB_SAMP/GUS.BAT | 1 + LIB386/LIB_SAMP/GUS.C | 87 + LIB386/LIB_SAMP/GUS.INC | 25 + LIB386/LIB_SAMP/LIB_WAVE.H | 206 ++ LIB386/LIB_SAMP/MAKEFILE | 54 + LIB386/LIB_SAMP/N_WAVE.ASM | 3436 +++++++++++++++++++ LIB386/LIB_SAMP/PATCH.INC | 141 + LIB386/LIB_SAMP/README.md | 30 + LIB386/LIB_SAMP/REAL.ASM | 26 + LIB386/LIB_SAMP/TEST.C | 10 + LIB386/LIB_SAMP/VOL.INC | 26 + LIB386/LIB_SAMP/WAVE.C | 123 + LIB386/LIB_SAMP/WAVE.INC | 114 + LIB386/LIB_SAMP/WAVE_A.ASM | 3769 +++++++++++++++++++++ LIB386/LIB_SAMP/WAVE_A.LST | 6190 ++++++++++++++++++++++++++++++++++ LIB386/LIB_SAMP/WAVE_DLL.MAK | 102 + LIB386/LIB_SAMP/WAVE_I.ASM | 227 ++ LIB386/LIB_SVGA/BLOC.C | 6 + LIB386/LIB_SVGA/BUILD.BAT | 13 + LIB386/LIB_SVGA/BUILDDLL.BAT | 3 + LIB386/LIB_SVGA/CPYMASK.ASM | 405 +++ LIB386/LIB_SVGA/DB.BAT | 1 + LIB386/LIB_SVGA/DLL.ASM | 628 ++++ LIB386/LIB_SVGA/DLL.MAK | 91 + LIB386/LIB_SVGA/DLL_I.ASM | 129 + LIB386/LIB_SVGA/FONT6X6.ASM | 522 +++ LIB386/LIB_SVGA/FONT8X8.ASM | 1 + LIB386/LIB_SVGA/FONT_A.ASM | 216 ++ LIB386/LIB_SVGA/GIF.C | 401 +++ LIB386/LIB_SVGA/GRAPHMSK.ASM | 154 + LIB386/LIB_SVGA/GRAPH_A.ASM | 358 ++ LIB386/LIB_SVGA/INITMODE.C | 50 + LIB386/LIB_SVGA/INITSVGA.ASM | 317 ++ LIB386/LIB_SVGA/LBM.C | 340 ++ LIB386/LIB_SVGA/LIB_SVGA.H | 209 ++ LIB386/LIB_SVGA/MAKEFILE | 66 + LIB386/LIB_SVGA/MASKGPH.C | 62 + LIB386/LIB_SVGA/MASK_A.ASM | 318 ++ LIB386/LIB_SVGA/MODEL.INC | 4 + LIB386/LIB_SVGA/MOUSE.GPH | Bin 0 -> 1031 bytes LIB386/LIB_SVGA/MOUSE.PCX | Bin 0 -> 12148 bytes LIB386/LIB_SVGA/PCX.C | 218 ++ LIB386/LIB_SVGA/RECT.C | 17 + LIB386/LIB_SVGA/SAVEPCX.C | 108 + LIB386/LIB_SVGA/SVGA.ASH | 36 + LIB386/LIB_SVGA/S_BLOCK.ASM | 285 ++ LIB386/LIB_SVGA/S_BLOCK2.ASM | 124 + LIB386/LIB_SVGA/S_BLOCK3.ASM | 75 + LIB386/LIB_SVGA/S_BOX.ASM | 93 + LIB386/LIB_SVGA/S_CPYBOX.ASM | 346 ++ LIB386/LIB_SVGA/S_DLL.C | 57 + LIB386/LIB_SVGA/S_FILLV.ASM | 1118 ++++++ LIB386/LIB_SVGA/S_FIND.ASM | 1567 +++++++++ LIB386/LIB_SVGA/S_LINE.ASM | 289 ++ LIB386/LIB_SVGA/S_MODE.ASM | 217 ++ LIB386/LIB_SVGA/S_MOUSE.C | 238 ++ LIB386/LIB_SVGA/S_MOUSEA.ASM | 153 + LIB386/LIB_SVGA/S_PAL.ASM | 142 + LIB386/LIB_SVGA/S_PHYS.ASM | 929 +++++ LIB386/LIB_SVGA/S_PLOT.ASM | 101 + LIB386/LIB_SVGA/S_POLY.ASM | 1376 ++++++++ LIB386/LIB_SVGA/S_SCREEN.ASM | 84 + LIB386/LIB_SVGA/S_STRING.ASM | 434 +++ LIB386/LIB_SVGA/S_TEXT.C | 190 ++ LIB386/LIB_SVGA/TA.BAT | 2 + LIB386/LIB_SVGA/TEXTURE.ASM | 2257 +++++++++++++ LIB386/LIB_SVGA/VESA.ASH | 33 + LIB386/LIB_SVGA/VESA.ASM | 138 + LIB386/LIB_SVGA/VESA.INC | 33 + LIB386/LIB_SVGA/ZOOM.ASM | 288 ++ LIB386/LIB_SYS/ADELINE.C | 332 ++ LIB386/LIB_SYS/ADELINE.H | 51 + LIB386/LIB_SYS/BUFFER_A.ASM | 95 + LIB386/LIB_SYS/BUILD.BAT | 13 + LIB386/LIB_SYS/DEFINES.H | 113 + LIB386/LIB_SYS/DEF_FILE.C | 639 ++++ LIB386/LIB_SYS/DIVERS.C | 15 + LIB386/LIB_SYS/DLL.H | 80 + LIB386/LIB_SYS/DLLLOAD.C | 639 ++++ LIB386/LIB_SYS/EXPAND.ASM | 69 + LIB386/LIB_SYS/FILES.C | 184 + LIB386/LIB_SYS/FILES_A.ASM | 110 + LIB386/LIB_SYS/HARDERR.ASM | 43 + LIB386/LIB_SYS/HQR.ASM | 45 + LIB386/LIB_SYS/HQ_MEM.C | 175 + LIB386/LIB_SYS/HQ_RESS.C | 629 ++++ LIB386/LIB_SYS/HQ_R_M.C | 72 + LIB386/LIB_SYS/KEYB.C | 124 + LIB386/LIB_SYS/KEYBOARD.ASM | 436 +++ LIB386/LIB_SYS/LIB_SYS.ASH | 23 + LIB386/LIB_SYS/LIB_SYS.H | 346 ++ LIB386/LIB_SYS/LIB_SYS.MAK | 39 + LIB386/LIB_SYS/LOADMALL.C | 48 + LIB386/LIB_SYS/LOADSAVE.C | 58 + LIB386/LIB_SYS/MAKEFILE | 60 + LIB386/LIB_SYS/MALLOC.C | 326 ++ LIB386/LIB_SYS/SYSTEM.C | 60 + LIB386/LIB_SYS/TIMER.C | 112 + LIB386/LIB_SYS/TIMER_A.ASM | 179 + LIB386/LIB_SYS/WINBOX.H | 69 + README.md | 56 + SOURCES/ADFLI_A.ASM | 244 ++ SOURCES/AMBIANCE.C | 504 +++ SOURCES/AMBIANCE.DEF | 20 + SOURCES/BALANCE.ASM | 72 + SOURCES/BALANCE.H | 4 + SOURCES/BUBSORT.C | 29 + SOURCES/COMMON.H | 561 +++ SOURCES/CPYMASK.ASM | 376 +++ SOURCES/C_EXTERN.H | 352 ++ SOURCES/DEFINES.H | 259 ++ SOURCES/DISKFUNC.C | 228 ++ SOURCES/DISKFUNC.DEF | 3 + SOURCES/EXTRA.C | 1275 +++++++ SOURCES/EXTRA.DEF | 21 + SOURCES/FICHE.C | 689 ++++ SOURCES/FICHE.DEF | 4 + SOURCES/FIRE.ASM | 177 + SOURCES/FLA.H | 138 + SOURCES/FLIPBOX.C | 140 + SOURCES/FLIPBOX.DEF | 5 + SOURCES/FUNC.ASM | 415 +++ SOURCES/GAMEMENU.C | 2849 ++++++++++++++++ SOURCES/GAMEMENU.DEF | 45 + SOURCES/GERELIFE.C | 1280 +++++++ SOURCES/GERELIFE.DEF | 3 + SOURCES/GERETRAK.C | 604 ++++ SOURCES/GERETRAK.DEF | 1 + SOURCES/GLOBAL.C | 260 ++ SOURCES/GRAPH_A.ASM | 317 ++ SOURCES/GRILLE.C | 735 ++++ SOURCES/GRILLE.DEF | 15 + SOURCES/GRILLE.H | 4 + SOURCES/GRILLE_A.ASM | 565 ++++ SOURCES/HOLOMAP.C | 1075 ++++++ SOURCES/HOLOMAP.DEF | 17 + SOURCES/INCRUST.C | 108 + SOURCES/INCRUST.DEF | 3 + SOURCES/M.BAT | 10 + SOURCES/MAKEFILE | 66 + SOURCES/MALLOC.C | 315 ++ SOURCES/MALLOC.DEF | 6 + SOURCES/MASK_A.ASM | 600 ++++ SOURCES/MCGA.ASM | 53 + SOURCES/MESSAGE.C | 1562 +++++++++ SOURCES/MESSAGE.DEF | 27 + SOURCES/MIXER.C | 50 + SOURCES/MIXER.DEF | 1 + SOURCES/OBJECT.C | 3444 +++++++++++++++++++ SOURCES/OBJECT.DEF | 28 + SOURCES/PERSO.C | 1478 ++++++++ SOURCES/PERSO.DEF | 11 + SOURCES/PLAYFLA.C | 703 ++++ SOURCES/PLAYFLA.DEF | 10 + SOURCES/SETUP.DBG | 108 + SOURCES/VERSION.C | 17 + SOURCES/WD.BAT | 1 + 199 files changed, 73169 insertions(+) create mode 100644 LIB386/LIB_3D/BUILD.BAT create mode 100644 LIB386/LIB_3D/LIB_3D.H create mode 100644 LIB386/LIB_3D/MAKEFILE create mode 100644 LIB386/LIB_3D/P_ANIM.ASM create mode 100644 LIB386/LIB_3D/P_DEFINE.ASH create mode 100644 LIB386/LIB_3D/P_FUNC.ASM create mode 100644 LIB386/LIB_3D/P_OBJET.ASM create mode 100644 LIB386/LIB_3D/P_OBJ_3D.ASM create mode 100644 LIB386/LIB_3D/P_OB_ISO.ASM create mode 100644 LIB386/LIB_3D/P_SINTAB.ASM create mode 100644 LIB386/LIB_3D/P_TRIGO.ASM create mode 100644 LIB386/LIB_CD/BUILD.BAT create mode 100644 LIB386/LIB_CD/CDROM.ASM create mode 100644 LIB386/LIB_CD/LIB_CD.H create mode 100644 LIB386/LIB_CD/LIB_CD.MAK create mode 100644 LIB386/LIB_CD/M.BAT create mode 100644 LIB386/LIB_MENU/ASM_SORT.ASM create mode 100644 LIB386/LIB_MENU/BUILD.BAT create mode 100644 LIB386/LIB_MENU/LIB_MENU.H create mode 100644 LIB386/LIB_MENU/MAKEFILE create mode 100644 LIB386/LIB_MENU/MENU.C create mode 100644 LIB386/LIB_MENU/MENUFUNC.C create mode 100644 LIB386/LIB_MENU/SELECTOR.C create mode 100644 LIB386/LIB_MIDI/BUILD.BAT create mode 100644 LIB386/LIB_MIDI/INCLUDE.C create mode 100644 LIB386/LIB_MIDI/LIB_MIDI.H create mode 100644 LIB386/LIB_MIDI/MAKEFILE create mode 100644 LIB386/LIB_MIDI/MIDI.C create mode 100644 LIB386/LIB_MIDI/README.md create mode 100644 LIB386/LIB_MIX/BUILD.BAT create mode 100644 LIB386/LIB_MIX/BUILDDLL.BAT create mode 100644 LIB386/LIB_MIX/LIB_MIX.H create mode 100644 LIB386/LIB_MIX/MAKEFILE create mode 100644 LIB386/LIB_MIX/MIXER.C create mode 100644 LIB386/LIB_MIX/MIXER_A.ASM create mode 100644 LIB386/LIB_MIX/MIXER_I.ASM create mode 100644 LIB386/LIB_MIX/MIX_DLL.MAK create mode 100644 LIB386/LIB_SAMP/BALANCE.ASM create mode 100644 LIB386/LIB_SAMP/BALANCE.H create mode 100644 LIB386/LIB_SAMP/BUILD.BAT create mode 100644 LIB386/LIB_SAMP/BUILDDLL.BAT create mode 100644 LIB386/LIB_SAMP/DMA_CODE.ASM create mode 100644 LIB386/LIB_SAMP/GUS.BAT create mode 100644 LIB386/LIB_SAMP/GUS.C create mode 100644 LIB386/LIB_SAMP/GUS.INC create mode 100644 LIB386/LIB_SAMP/LIB_WAVE.H create mode 100644 LIB386/LIB_SAMP/MAKEFILE create mode 100644 LIB386/LIB_SAMP/N_WAVE.ASM create mode 100644 LIB386/LIB_SAMP/PATCH.INC create mode 100644 LIB386/LIB_SAMP/README.md create mode 100644 LIB386/LIB_SAMP/REAL.ASM create mode 100644 LIB386/LIB_SAMP/TEST.C create mode 100644 LIB386/LIB_SAMP/VOL.INC create mode 100644 LIB386/LIB_SAMP/WAVE.C create mode 100644 LIB386/LIB_SAMP/WAVE.INC create mode 100644 LIB386/LIB_SAMP/WAVE_A.ASM create mode 100644 LIB386/LIB_SAMP/WAVE_A.LST create mode 100644 LIB386/LIB_SAMP/WAVE_DLL.MAK create mode 100644 LIB386/LIB_SAMP/WAVE_I.ASM create mode 100644 LIB386/LIB_SVGA/BLOC.C create mode 100644 LIB386/LIB_SVGA/BUILD.BAT create mode 100644 LIB386/LIB_SVGA/BUILDDLL.BAT create mode 100644 LIB386/LIB_SVGA/CPYMASK.ASM create mode 100644 LIB386/LIB_SVGA/DB.BAT create mode 100644 LIB386/LIB_SVGA/DLL.ASM create mode 100644 LIB386/LIB_SVGA/DLL.MAK create mode 100644 LIB386/LIB_SVGA/DLL_I.ASM create mode 100644 LIB386/LIB_SVGA/FONT6X6.ASM create mode 100644 LIB386/LIB_SVGA/FONT8X8.ASM create mode 100644 LIB386/LIB_SVGA/FONT_A.ASM create mode 100644 LIB386/LIB_SVGA/GIF.C create mode 100644 LIB386/LIB_SVGA/GRAPHMSK.ASM create mode 100644 LIB386/LIB_SVGA/GRAPH_A.ASM create mode 100644 LIB386/LIB_SVGA/INITMODE.C create mode 100644 LIB386/LIB_SVGA/INITSVGA.ASM create mode 100644 LIB386/LIB_SVGA/LBM.C create mode 100644 LIB386/LIB_SVGA/LIB_SVGA.H create mode 100644 LIB386/LIB_SVGA/MAKEFILE create mode 100644 LIB386/LIB_SVGA/MASKGPH.C create mode 100644 LIB386/LIB_SVGA/MASK_A.ASM create mode 100644 LIB386/LIB_SVGA/MODEL.INC create mode 100644 LIB386/LIB_SVGA/MOUSE.GPH create mode 100644 LIB386/LIB_SVGA/MOUSE.PCX create mode 100644 LIB386/LIB_SVGA/PCX.C create mode 100644 LIB386/LIB_SVGA/RECT.C create mode 100644 LIB386/LIB_SVGA/SAVEPCX.C create mode 100644 LIB386/LIB_SVGA/SVGA.ASH create mode 100644 LIB386/LIB_SVGA/S_BLOCK.ASM create mode 100644 LIB386/LIB_SVGA/S_BLOCK2.ASM create mode 100644 LIB386/LIB_SVGA/S_BLOCK3.ASM create mode 100644 LIB386/LIB_SVGA/S_BOX.ASM create mode 100644 LIB386/LIB_SVGA/S_CPYBOX.ASM create mode 100644 LIB386/LIB_SVGA/S_DLL.C create mode 100644 LIB386/LIB_SVGA/S_FILLV.ASM create mode 100644 LIB386/LIB_SVGA/S_FIND.ASM create mode 100644 LIB386/LIB_SVGA/S_LINE.ASM create mode 100644 LIB386/LIB_SVGA/S_MODE.ASM create mode 100644 LIB386/LIB_SVGA/S_MOUSE.C create mode 100644 LIB386/LIB_SVGA/S_MOUSEA.ASM create mode 100644 LIB386/LIB_SVGA/S_PAL.ASM create mode 100644 LIB386/LIB_SVGA/S_PHYS.ASM create mode 100644 LIB386/LIB_SVGA/S_PLOT.ASM create mode 100644 LIB386/LIB_SVGA/S_POLY.ASM create mode 100644 LIB386/LIB_SVGA/S_SCREEN.ASM create mode 100644 LIB386/LIB_SVGA/S_STRING.ASM create mode 100644 LIB386/LIB_SVGA/S_TEXT.C create mode 100644 LIB386/LIB_SVGA/TA.BAT create mode 100644 LIB386/LIB_SVGA/TEXTURE.ASM create mode 100644 LIB386/LIB_SVGA/VESA.ASH create mode 100644 LIB386/LIB_SVGA/VESA.ASM create mode 100644 LIB386/LIB_SVGA/VESA.INC create mode 100644 LIB386/LIB_SVGA/ZOOM.ASM create mode 100644 LIB386/LIB_SYS/ADELINE.C create mode 100644 LIB386/LIB_SYS/ADELINE.H create mode 100644 LIB386/LIB_SYS/BUFFER_A.ASM create mode 100644 LIB386/LIB_SYS/BUILD.BAT create mode 100644 LIB386/LIB_SYS/DEFINES.H create mode 100644 LIB386/LIB_SYS/DEF_FILE.C create mode 100644 LIB386/LIB_SYS/DIVERS.C create mode 100644 LIB386/LIB_SYS/DLL.H create mode 100644 LIB386/LIB_SYS/DLLLOAD.C create mode 100644 LIB386/LIB_SYS/EXPAND.ASM create mode 100644 LIB386/LIB_SYS/FILES.C create mode 100644 LIB386/LIB_SYS/FILES_A.ASM create mode 100644 LIB386/LIB_SYS/HARDERR.ASM create mode 100644 LIB386/LIB_SYS/HQR.ASM create mode 100644 LIB386/LIB_SYS/HQ_MEM.C create mode 100644 LIB386/LIB_SYS/HQ_RESS.C create mode 100644 LIB386/LIB_SYS/HQ_R_M.C create mode 100644 LIB386/LIB_SYS/KEYB.C create mode 100644 LIB386/LIB_SYS/KEYBOARD.ASM create mode 100644 LIB386/LIB_SYS/LIB_SYS.ASH create mode 100644 LIB386/LIB_SYS/LIB_SYS.H create mode 100644 LIB386/LIB_SYS/LIB_SYS.MAK create mode 100644 LIB386/LIB_SYS/LOADMALL.C create mode 100644 LIB386/LIB_SYS/LOADSAVE.C create mode 100644 LIB386/LIB_SYS/MAKEFILE create mode 100644 LIB386/LIB_SYS/MALLOC.C create mode 100644 LIB386/LIB_SYS/SYSTEM.C create mode 100644 LIB386/LIB_SYS/TIMER.C create mode 100644 LIB386/LIB_SYS/TIMER_A.ASM create mode 100644 LIB386/LIB_SYS/WINBOX.H create mode 100644 README.md create mode 100644 SOURCES/ADFLI_A.ASM create mode 100644 SOURCES/AMBIANCE.C create mode 100644 SOURCES/AMBIANCE.DEF create mode 100644 SOURCES/BALANCE.ASM create mode 100644 SOURCES/BALANCE.H create mode 100644 SOURCES/BUBSORT.C create mode 100644 SOURCES/COMMON.H create mode 100644 SOURCES/CPYMASK.ASM create mode 100644 SOURCES/C_EXTERN.H create mode 100644 SOURCES/DEFINES.H create mode 100644 SOURCES/DISKFUNC.C create mode 100644 SOURCES/DISKFUNC.DEF create mode 100644 SOURCES/EXTRA.C create mode 100644 SOURCES/EXTRA.DEF create mode 100644 SOURCES/FICHE.C create mode 100644 SOURCES/FICHE.DEF create mode 100644 SOURCES/FIRE.ASM create mode 100644 SOURCES/FLA.H create mode 100644 SOURCES/FLIPBOX.C create mode 100644 SOURCES/FLIPBOX.DEF create mode 100644 SOURCES/FUNC.ASM create mode 100644 SOURCES/GAMEMENU.C create mode 100644 SOURCES/GAMEMENU.DEF create mode 100644 SOURCES/GERELIFE.C create mode 100644 SOURCES/GERELIFE.DEF create mode 100644 SOURCES/GERETRAK.C create mode 100644 SOURCES/GERETRAK.DEF create mode 100644 SOURCES/GLOBAL.C create mode 100644 SOURCES/GRAPH_A.ASM create mode 100644 SOURCES/GRILLE.C create mode 100644 SOURCES/GRILLE.DEF create mode 100644 SOURCES/GRILLE.H create mode 100644 SOURCES/GRILLE_A.ASM create mode 100644 SOURCES/HOLOMAP.C create mode 100644 SOURCES/HOLOMAP.DEF create mode 100644 SOURCES/INCRUST.C create mode 100644 SOURCES/INCRUST.DEF create mode 100644 SOURCES/M.BAT create mode 100644 SOURCES/MAKEFILE create mode 100644 SOURCES/MALLOC.C create mode 100644 SOURCES/MALLOC.DEF create mode 100644 SOURCES/MASK_A.ASM create mode 100644 SOURCES/MCGA.ASM create mode 100644 SOURCES/MESSAGE.C create mode 100644 SOURCES/MESSAGE.DEF create mode 100644 SOURCES/MIXER.C create mode 100644 SOURCES/MIXER.DEF create mode 100644 SOURCES/OBJECT.C create mode 100644 SOURCES/OBJECT.DEF create mode 100644 SOURCES/PERSO.C create mode 100644 SOURCES/PERSO.DEF create mode 100644 SOURCES/PLAYFLA.C create mode 100644 SOURCES/PLAYFLA.DEF create mode 100644 SOURCES/SETUP.DBG create mode 100644 SOURCES/VERSION.C create mode 100644 SOURCES/WD.BAT diff --git a/LIB386/LIB_3D/BUILD.BAT b/LIB386/LIB_3D/BUILD.BAT new file mode 100644 index 0000000..3b9991b --- /dev/null +++ b/LIB386/LIB_3D/BUILD.BAT @@ -0,0 +1,13 @@ +call watcom10 + +pkunzip -o obj >NUL +wmake +pkzip -m obj *.obj >NUL + +call watcom9 + +pkunzip -o obj9 >NUL +wmake WATCOM9=yes +pkzip -m obj9 *.obj >NUL + +call watcom10 diff --git a/LIB386/LIB_3D/LIB_3D.H b/LIB386/LIB_3D/LIB_3D.H new file mode 100644 index 0000000..a5866ca --- /dev/null +++ b/LIB386/LIB_3D/LIB_3D.H @@ -0,0 +1,123 @@ +#ifdef WATCOM9 + #pragma library ("f:\projet\lib386\lib_3d\lb9_3d.lib"); +#else + #pragma library ("f:\projet\lib386\lib_3d\lib_3d.lib"); +#endif + +#define NORMAL_UNIT 64 + +#define INFO_TRI 1 +#define INFO_ANIM 2 + +#define TYPE_ROTATE 0 +#define TYPE_TRANSLATE 1 +#define TYPE_ZOOM 2 + +#define MAT_TRISTE 0 +#define MAT_PIERRE 1 +#define MAT_COPPER 2 +#define MAT_BOPPER 3 +#define MAT_MARBRE 4 +#define MAT_TRANS 5 +#define MAT_TRAME 6 +#define MAT_FLAT 7 +#define MAT_GRANIT 8 +#define MAT_GOURAUD 9 +#define MAT_DITHER 10 + +/* structures */ + +typedef struct { WORD X ; + WORD Y ; + WORD Z ; } T_GROUPE_INFO ; + +typedef struct { WORD StartValue ; + WORD EndValue ; + UWORD TimeValue ; + ULONG MemoTicks ; } T_REAL_VALUE ; + +typedef struct { WORD Xp ; + WORD Yp ; + WORD Zrot ; } T_LIST_POINT ; + + +extern WORD AnimMasterRot ; +extern WORD AnimStepAlpha, AnimStepBeta, AnimStepGamma ; +extern WORD AnimStepX, AnimStepY, AnimStepZ ; +extern WORD ScreenXmin, ScreenXmax, ScreenYmin, ScreenYmax ; + +extern WORD XCentre, YCentre ; +extern WORD IsoScale ; + +extern WORD Xp, Yp ; +extern WORD Z_Min, Z_Max ; + +extern WORD NbPoints ; +extern T_LIST_POINT List_Point ; + +extern LONG KFactor, LFactorY, LFactorX ; + +extern LONG X0, Y0, Z0 ; +extern LONG EX0, EY0 ; /* Rot2D sur LONG */ + +extern LONG CameraX, CameraY, CameraZ ; +extern LONG CameraXr, CameraYr, CameraZr ; + +extern LONG Alpha, Beta, Gamma ; +extern LONG lAlpha, lBeta, lGamma ; + +extern LONG AlphaLight, BetaLight, GammaLight ; +extern LONG NormalXLight, NormalYLight, NormalZLight ; + +extern LONG MatriceWorld, MatriceTempo; +extern LONG MatriceRot, MatriceDummy; + +extern LONG Distance ; + +extern LONG CmptMemoTimerRef ; + +void InitRealValue( WORD start, + WORD end, + WORD time, + T_REAL_VALUE *ptrstruct ) ; + +void InitRealAngle( WORD start, + WORD end, + WORD time, + T_REAL_VALUE *ptrstruct ) ; + +WORD GetRealValue( T_REAL_VALUE *ptrstruct ) ; +WORD GetRealAngle( T_REAL_VALUE *ptrstruct ) ; + +WORD StockInterAnim( UBYTE *BufferAnim, UBYTE *PtrObj ) ; + +LONG RegleTrois32( LONG val1, LONG val2, LONG nbstep, LONG step ) ; + +LONG Distance2D( LONG x0, LONG z0, LONG x1, LONG z1 ) ; +LONG Distance3D( LONG x0, LONG y0, LONG z0, + LONG x1, LONG y1, LONG z1 ) ; + +void Rot2D( LONG x, LONG y, LONG angle ) ; + +void WorldRotatePoint( LONG x, LONG y, LONG angle ) ; +void LongWorldRotatePoint( LONG x, LONG y, LONG angle ) ; + +void LongInverseRotatePoint( LONG x, LONG y, LONG angle ) ; + +void SetLightVector( WORD alpha, WORD beta, WORD gamma ) ; + +void CopyMatrice( LONG *MatSrc, LONG *MatDest ); + +LONG AffObjetIso(LONG xwr, LONG ywr, LONG zwr, + LONG palpha, LONG pbeta, LONG pgamma, + void *ptrobj); + +void PatchObjet(void *ptrobj); + +LONG ProjettePoint(LONG CoorX, LONG CoorY, LONG CoorZ); +LONG LongProjettePoint(LONG CoorX, LONG CoorY, LONG CoorZ); + +void SetProjection(LONG xc, LONG yc, LONG kfact, LONG lfactx, LONG lfacty); +void SetIsoProjection(LONG xc, LONG yc, LONG scale); + +ULONG Sqr(ULONG x); diff --git a/LIB386/LIB_3D/MAKEFILE b/LIB386/LIB_3D/MAKEFILE new file mode 100644 index 0000000..a23320d --- /dev/null +++ b/LIB386/LIB_3D/MAKEFILE @@ -0,0 +1,60 @@ +# name the compiler +!ifdef %HOME +!ifeq WATCOM9 yes +CC = c:\compil\watcom\bin\wcc386p +WL = c:\compil\watcom\binb\wlib +!else +CC = c:\compil\watcom10\binb\wcc386 +WL = c:\compil\watcom10\binb\wlib +!endif +!else +!ifeq WATCOM9 yes +CC = f:\compil\watcom\bin\wcc386p +WL = f:\compil\watcom\binb\wlib +!else +CC = f:\compil\watcom10\binb\wcc386 +WL = f:\compil\watcom10\binb\wlib +!endif +!endif + +ASM = ml + +!ifeq WATCOM9 yes +CFLAGS = /oeaxt /zp2 /4s /zq /s /DWATCOM9 +!else +CFLAGS = /oeaxt /zp2 /5s /zq /s +!endif +LFLAGS = /c /q /b /n +#AFLAGS = /m2 /mx /z /p /q /t /jMASM51 /jQUIRKS +AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=; + +OBJETS1 = P_SINTAB.obj P_ANIM.obj +OBJETS2 = P_OB_ISO.obj P_TRIGO.obj +OBJETS3 = P_FUNC.obj +OBJETS4 = + +!ifeq WATCOM9 yes +LIB = LB9_3D +!else +LIB = LIB_3D +!endif + +$(LIB).LIB: $(OBJETS1) $(OBJETS2) $(OBJETS3) $(OBJETS4) + + @echo $(OBJETS1) > clibmak.rsp + @echo $(OBJETS2) >> clibmak.rsp + @echo $(OBJETS3) >> clibmak.rsp +# @echo $(OBJETS4) >> clibmak.rsp + + + @$(WL) $(WLIBFLAGS) $(LIB) @clibmak.rsp + @del clibmak.rsp + @prntitre G "$(LIB)" + +.asm.obj: + @PRNTITRE M "$*.ASM" + @$(ASM) $(AFLAGS) $*.ASM + +.c.obj: + @PRNTITRE M "$*.C" + @$(CC) $(WCFLAGS) $* diff --git a/LIB386/LIB_3D/P_ANIM.ASM b/LIB386/LIB_3D/P_ANIM.ASM new file mode 100644 index 0000000..cecbc24 --- /dev/null +++ b/LIB386/LIB_3D/P_ANIM.ASM @@ -0,0 +1,1115 @@ + + .386p + jumps + + .model SMALL, SYSCALL + + include P_define.ash + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; P_ ÛßßßÛ ÛÛÜ Û Û ÛÜ ÜÛ +; ÛÛßßÛ ÛÛßÛÛ ÛÛ ÛÛß Û +; ßß ß ßß ß ßß ßß ß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + + .data + + include \projet\lib386\lib_sys\lib_sys.ash + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +ALIGN 4 + + extrn NoLanguage List_Anim_Point:WORD + +Offset_Source dd 0000 +Offset_Dest dd 0000 + +StartInfos dd 0000 + + public NoLanguage MemoTimerRef + public NoLanguage CmptMemoTimerRef + +MemoTimerRef dd 0000 +CmptMemoTimerRef dd 0000 + + public NoLanguage AnimStepX + public NoLanguage AnimStepY + public NoLanguage AnimStepZ + +AnimStepX dw 00 +AnimStepY dw 00 +AnimStepZ dw 00 + + public NoLanguage AnimMasterRot + public NoLanguage AnimStepAlpha + public NoLanguage AnimStepBeta + public NoLanguage AnimStepGamma + +AnimMasterRot dw 00 +AnimStepAlpha dw 00 +AnimStepBeta dw 00 +AnimStepGamma dw 00 + +CXSetInterAnim dw 00 + + .code + + public NoLanguage SetAngleGroupe + public NoLanguage GetAngleGroupe + public NoLanguage GetNbFramesAnim + public NoLanguage GetBouclageAnim + public NoLanguage SetAnimObjet + + public NoLanguage SetInterAnimObjet + public NoLanguage SetInterAnimObjet2 + public NoLanguage SetInterDepObjet + + public NoLanguage StockInterAnim + public NoLanguage CopyInterAnim + public NoLanguage SaveTimer + public NoLanguage RestoreTimer + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +SaveTimer proc + + cmp [CmptMemoTimerRef], 0 + jnz st0 + + mov eax, [ TimerRef ] + mov [MemoTimerRef], eax + +st0: inc [CmptMemoTimerRef] + + ret + +SaveTimer endp + +RestoreTimer proc + + dec [CmptMemoTimerRef] + jnz rt0 + + mov eax, [MemoTimerRef] + mov [ TimerRef ], eax + +rt0: ret + +RestoreTimer endp + + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +SetAngleGroupe proc uses esi,\ + numgroupe:DWORD, palpha:DWORD, pbeta:DWORD, pgamma:DWORD,\ + ptrobj:DWORD + + mov esi, ptrobj + + mov ax, [esi] ; lit infos + test ax, INFO_ANIM ; test si objet possede anim + jz serr + + add esi, 14 ; saute ZV + + xor eax, eax + mov ax, [esi] ; size info to skip + lea esi, [esi+eax+4] + + mov ax, [esi-2] ; nb points + lea ecx, [eax+eax*2] ; *3 + lea esi, [esi+ecx*2] ; saute def points + + mov ax, [esi] ; nb groupes + + cmp eax, numgroupe + jb serr ; mauvais numgroupe + imul eax, 38 + lea esi, [esi+eax+2+10] ; si sur def groupe + + mov eax, palpha + mov word ptr[esi], ax + mov eax, pbeta + mov word ptr[esi+2], ax + mov eax, pgamma + mov word ptr[esi+4], ax + +serr: ret + +SetAngleGroupe endp + +comment @ + +SetAngleGroupe proc uses esi ebx,\ + numgroupe:DWORD, palpha:DWORD, pbeta:DWORD, pgamma:DWORD,\ + ptrobj:DWORD + + mov esi, ptrobj + + lodsw ; lit infos + test ax, INFO_ANIM ; test si objet possede anim + jz serr + + add esi, 12 ; saute ZV + + lodsw ; size info to skip + movzx eax, ax + add esi, eax + + lodsw ; nb points + movzx eax, ax + mov ebx, eax + shl eax, 1 + add eax, ebx ; *3 + shl eax, 1 ; WORD + add esi, eax ; saute def points + + lodsw ; nb groupes + movzx ebx, ax + + mov eax, numgroupe + cmp eax, ebx + jae serr ; mauvais numgroupe + mov ecx, 38 + mul ecx + add esi, eax ; si sur def groupe + +; mov word ptr[esi+8], TYPE_ROTATE + + mov eax, palpha + mov word ptr[esi+10], ax + mov eax, pbeta + mov word ptr[esi+12], ax + mov eax, pgamma + mov word ptr[esi+14], ax + +serr: ret + +SetAngleGroupe endp + + @ + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +GetAngleGroupe proc uses esi,\ + numgroupe:DWORD,\ + ptrobj:DWORD + + mov esi, ptrobj + + mov ax, [esi] ; lit infos + test ax, INFO_ANIM ; test si objet possede anim + jz serr + + add esi, 14 ; saute ZV + + xor eax, eax + mov ax, [esi] ; size info to skip + lea esi, [esi+eax+4] + + mov ax, [esi-2] ; nb points + mov ecx, eax + lea ecx, [ecx+eax*2] ; *3 + lea esi, [esi+ecx*2] ; saute def points + + mov ax, [esi] ; nb groupes + + cmp eax, numgroupe + jb serr ; mauvais numgroupe + imul eax, 38 + lea edi, [edi+eax+2+10] ; si sur def groupe + + mov ax, word ptr[esi] + mov word ptr[AnimStepAlpha], ax + mov ax, word ptr[esi+2] + mov word ptr[AnimStepBeta], ax + mov ax, word ptr[esi+4] + mov word ptr[AnimStepGamma], ax + +serr: ret + +GetAngleGroupe endp + +comment @ + +GetAngleGroupe proc uses esi ebx,\ + numgroupe:DWORD,\ + ptrobj:DWORD + + mov esi, ptrobj + + lodsw ; lit infos + test ax, INFO_ANIM ; test si objet possede anim + jz serr + + add esi, 12 ; saute ZV + + lodsw ; size info to skip + movzx eax, ax + add esi, eax + + lodsw ; nb points + movzx eax, ax + mov ebx, eax + shl eax, 1 + add eax, ebx ; *3 + shl eax, 1 ; WORD + add esi, eax ; saute def points + + lodsw ; nb groupes + movzx ebx, ax + + mov eax, numgroupe + cmp eax, ebx + jae serr ; mauvais numgroupe + mov ecx, 38 + mul ecx + add esi, eax ; si sur def groupe + + mov ax, word ptr[esi+10] + mov word ptr[AnimStepAlpha], ax + mov ax, word ptr[esi+12] + mov word ptr[AnimStepBeta], ax + mov ax, word ptr[esi+14] + mov word ptr[AnimStepGamma], ax + +serr: ret + +GetAngleGroupe endp + + @ + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +GetNbFramesAnim proc \ + ptranim:DWORD + + mov ecx, ptranim + xor eax, eax + mov ax, word ptr[ecx] + ret + +GetNbFramesAnim endp + +GetBouclageAnim proc \ + ptranim:DWORD + + mov ecx, ptranim + add ecx, 4 + xor eax, eax + mov ax, word ptr[ecx] + ret + +GetBouclageAnim endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +SetAnimObjet proc uses esi edi,\ + numframe:DWORD, ptranim:DWORD,ptrobj:DWORD + + mov esi, ptranim + + xor eax, eax + mov ax, [esi] ; nbframes + + mov edx, numframe + cmp edx, eax ; si numframe >= nbframes + jb noerr + + ret + +noerr: mov ax, [esi+2] ; nb groupes + + mov ecx, eax + + lea eax, [eax*8+8] ; infos frame + *4 WORD ax size 1 frame + imul eax, edx + lea esi, [esi+eax+8] ; si sur start frame + + mov edi, ptrobj + + mov ax, [edi] ; lit infos + test ax, INFO_ANIM ; test si objet possede anim + jz serr ; non tanpis au revoir + + add edi, 12 + 2 ; saute ZV + word infos + + mov [edi+0+2], esi ; memo offset + + mov eax, [ TimerRef ] + mov [edi+4+2], eax ; memoticks reset + + xor eax, eax + mov ax, word ptr[edi] + lea edi, [edi+eax+2] + mov ax, word ptr[edi] ; nb points + mov edx, eax + lea edx, [edx+eax*2] ; *3 + lea edi, [edi+edx*2+2+8+2] + mov ax, word ptr[edi-8-2] ; nb groupes + + cmp cx, ax + jbe ok + mov cx, ax ; ? - de groupes que d'anim +ok: + mov edx, esi + add esi, 8 ; saute Infos frame + +sao0: movsd ; type ; alpha + movsd ; beta ; gamma + add edi, 12+18 + dec cx + jnz sao0 ; set tous groupes + + mov esi, edx ; sur infos frame + add esi, 2 ; sur stepX + + mov edi, offset AnimStepX + movsd + movsw ; stock var DGROUP + + mov edi, offset AnimMasterRot + movsd + movsd + + mov eax, 1 ; retourne flag anim atteinte + ret + +serr: xor eax, eax + ret + +SetAnimObjet endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;comment # +PatchInterAngle proc near + + mov esi, [Offset_Source] + mov cx, [esi] ; lastalpha + add esi, 2 + mov [Offset_Source], esi + + mov esi, [Offset_Dest] + lodsw ; newalpha + mov [Offset_Dest], esi + + and ax, 1023 + and cx, 1023 + + sub ax, cx + jz optequal + + cmp ax, -512 + jl art1 + cmp ax, 512 + jle ok + +art0: sub ax, 2048 +art1: add ax, 1024 +ok: + imul bp ; resul DX:AX + idiv bx ; bx ; /NbStep + add cx, ax ; cx = Valeur1 +optequal: and cx, 1023 + mov word ptr[edi], cx + add edi, 2 + ret + +PatchInterAngle endp +; # +comment # +PatchInterAngle MACRO + local arta, bart, ok, optequal + + mov esi, [Offset_Source] + mov cx, [esi] ; lastalpha + add esi, 2 + mov [Offset_Source], esi + + mov esi, [Offset_Dest] + lodsw ; newalpha + mov [Offset_Dest], esi + + and ax, 1023 + and cx, 1023 + + sub ax, cx + jz optequal + + cmp ax, -512 + jl arta + cmp ax, 512 + jle ok + +arta: sub ax, 2048 +bart: add ax, 1024 +ok: + imul bp ; resul DX:AX + idiv bx ; bx ; /NbStep + add cx, ax ; cx = Valeur1 +optequal: and cx, 1023 + mov word ptr[edi], cx + add edi, 2 + + ENDM + # +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +PatchInterStep proc near + + mov esi, [Offset_Source] + mov cx, [esi] ; laststepX + add esi, 2 + mov [Offset_Source], esi + + mov esi, [Offset_Dest] + lodsw ; newstepX + mov [Offset_Dest], esi + + sub ax, cx + jz optequal + + + imul bp ; resul DX:AX + idiv bx ; bx ; /NbStep + add cx, ax ; cx = Valeur1 + +optequal: mov word ptr[edi], cx + add edi, 2 ; stock valeur interm‚diare + ; dans struct groupe de l'obj + ret + +PatchInterStep endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +PatchType proc near + + mov esi, [Offset_Dest] + lodsw + mov [Offset_Dest], esi + mov word ptr[edi], ax + add edi, 2 ; stock type + add [Offset_Source], 2 ; saute type source + + ret + +PatchType endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +SetInterAnimObjet proc uses esi edi ebx ebp,\ + framedest:DWORD, ptranimdest:DWORD,\ + ptrobj:DWORD + + mov esi, ptranimdest + + xor eax, eax + xor edx, edx + mov ax, word ptr[esi+2] ; nb groupes dest + mov cx, ax + lea eax, [eax*8+8] ; infos frame + *4 WORD ax size 1 frame + imul eax, framedest + lea esi, [esi+eax+8] ; si sur time frame dest + + mov [Offset_Dest], esi + + mov dx, word ptr[esi] ; dx time to come here + + mov edi, ptrobj + + mov ax, [edi] ; lit infos + test ax, INFO_ANIM ; test si objet possede anim + jz serr ; non tanpis au revoir + + add edi, 12 + 2 + 2 ; saute ZV (+ info) + + mov [StartInfos], edi ; memo start info + + mov ebx, [edi+0] ; memo offset source anim + mov ebp, [edi+4] ; lit memoticks + + or ebx, ebx ; test init ? + jnz sao3 + + mov ebp, edx ; first anim poke last frame + mov ebx, esi + +sao3: mov [Offset_Source], ebx + +cont: xor eax, eax + mov ax, word ptr[edi-2] + add edi, eax + mov ax, word ptr[edi] ; nb points + lea eax, [eax+eax*2] ; *3 + lea edi, [edi+eax*2+2+8+2] + mov ax, word ptr[edi-8-2] ; nb groupes + + cmp cx, ax + jbe ok + mov cx, ax ; - de group obj que de group d'anim ? +ok: + mov eax, [ TimerRef ] ; Cmpt 50 hz + + sub eax, ebp + cmp eax, edx ; if step >= nbstep + + jae sao2 ; poke dest frame + + mov ebx, edx ; nb step = time to come here + mov ebp, eax ; step en cours + + push [Offset_Dest] + + add [Offset_Source], 8 ; saute infos frame + add [Offset_Dest], 8 ; saute infos frame + + ; la 1ere fois pour le G0 ne tiens pas compte du type + ; et stock valeur calcul‚es + + mov esi, [Offset_Dest] + mov ax, [esi] + mov [AnimMasterRot], ax + + mov ax, [esi + 2] ; StepAlpha + imul bp ; resul DX:AX + idiv bx ; /NbStep + mov [AnimStepAlpha], ax + + mov ax, [esi + 4] ; StepBeta + imul bp ; resul DX:AX + idiv bx ; /NbStep + mov [AnimStepBeta], ax + + mov ax, [esi + 6] ; StepGamma + imul bp ; resul DX:AX + idiv bx ; /NbStep + mov [AnimStepGamma], ax + + add [Offset_Dest], 8 + add [Offset_Source], 8 + add edi, 38 + + dec cx + jz sao4 + + ; suite des groupes + + mov [CXSetInterAnim], cx + +sao0: call PatchType + + cmp ax,TYPE_ROTATE + jnz ttrans + + call PatchInterAngle + call PatchInterAngle + call PatchInterAngle + +; PatchInterAngle +; PatchInterAngle +; PatchInterAngle + + add edi, 12+18 + dec word ptr[CXSetInterAnim] + jnz sao0 ; set tous groupes + jmp short sao4 + +ttrans: cmp ax,TYPE_TRANSLATE + jnz tzoom + + call PatchInterStep + call PatchInterStep + call PatchInterStep + + add edi, 12+18 + dec word ptr[CXSetInterAnim] + jnz sao0 ; set tous groupes + jmp short sao4 + +tzoom: cmp ax,TYPE_ZOOM + jnz argbug + + call PatchInterStep + call PatchInterStep + call PatchInterStep + +argbug: add edi, 12+18 + dec word ptr[CXSetInterAnim] + jnz sao0 ; set tous groupes +sao4: + + ; calcul StepXYZ + + pop esi ; esi anim dest info frame + mov edi, offset AnimStepX + + mov ax, [esi + 2] ; StepX + imul bp ; resul DX:AX + idiv bx ; /NbStep + mov word ptr[edi], ax + + mov ax, [esi + 4] ; StepY + imul bp ; resul DX:AX + idiv bx ; /NbStep + mov word ptr[edi+2], ax + + mov ax, [esi + 6] ; StepZ + imul bp ; resul DX:AX + idiv bx ; /NbStep + mov word ptr[edi+4], ax + +; mov word ptr[TimeFrame],bx +; mov word ptr[StepFrame],bp + +serr: xor eax, eax ; anim pas finie + ret + + + + + ; poke dest frame directly + +sao2: +;// add ebp, edx + + mov edx, esi + add esi, 8 ; saute infos frame + +sao1: movsd ; type ; alpha + movsd ; beta ; gamma + add edi, 12+18 + dec cx + jnz sao1 ; set tous groupes + + mov edi, [StartInfos] + + mov eax, [Offset_Dest] + mov [edi+0], eax ; memo offset + + mov eax, [ TimerRef ] + mov [edi+4], eax ; memoticks reset +comment @ + mov eax, [ TimerRef ] + cmp eax, ebp + jae okmemo + + mov ebp, eax +okmemo: + mov [edi+4], ebp ; memoticks reset + @ + ; stock step X Y Z + + mov esi, edx ; sur infos frame + add esi, 2 ; sur stepX + + mov edi, offset AnimStepX + movsd + movsw ; stock var DGROUP + + mov edi, offset AnimMasterRot + movsd + movsd ; + AnimStepAlpha, ... + + + mov eax, 1 ; retourne flag anim atteinte + + ret + +SetInterAnimObjet endp +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +SetInterAnimObjet2 proc uses esi edi ebx ebp,\ + framedest:DWORD, ptranimdest:DWORD,\ + ptrobj:DWORD + + mov esi, ptranimdest + mov edx, framedest + + xor eax, eax + mov ax, word ptr[esi + 2] ; nb groupes dest + mov cx, ax + lea eax, [8+eax*8] ; (eax+1)*4 WORD ax size 1 frame + mul edx + lea esi, [esi+eax+8] ; si sur time frame dest + + mov [Offset_Dest], esi + + xor edx, edx + mov dx, word ptr[esi] ; dx time to come here + + mov edi, ptrobj + + mov ax, [edi] ; lit infos + test ax, INFO_ANIM ; test si objet possede anim + jz serr ; non tanpis au revoir + + lea edi,[edi+12+2+2] ; saute ZV (+ info) + + mov [StartInfos], edi ; memo start info + + mov ebx, [edi+0] ; memo offset source anim + mov ebp, [edi+4] ; lit memoticks + + or ebx, ebx ; test init ? + jnz sao3 + + mov ebp, edx ; first anim poke last frame + mov ebx, esi + +sao3: mov [Offset_Source], ebx + +cont: xor eax, eax + mov ax, word ptr[edi-2] + lea edi, [edi+eax] + mov ax, word ptr[edi] ; nb points + lea eax, [eax+eax*2] ; *3 + lea edi, [edi+eax*2+2+8+2] + mov ax, word ptr[edi-8-2] ; nb groupes + + cmp cx, ax + jbe ok + mov cx, ax ; - de group obj que de group d'anim ? +ok: + mov eax, [ TimerRef ] ; Cmpt 50 hz + + sub eax, ebp + cmp eax, edx ; if step >= nbstep + + mov ebx, edx ; nb step = time to come here + mov ebp, eax ; step en cours + + jae sao2 ; poke dest frame + + add [Offset_Dest], 16 + add [Offset_Source], 16 + add edi, 38 + + dec cx + jz sao4 + + ; suite des groupes + + mov [CXSetInterAnim], cx + +sao0: call PatchType + + cmp ax,TYPE_ROTATE + jnz ttrans + + call PatchInterAngle ; ax val2 cx val1 bp step bx nbstep + call PatchInterAngle ; ax val2 cx val1 bp step bx nbstep + call PatchInterAngle ; ax val2 cx val1 bp step bx nbstep + +; call PatchInterStep +; call PatchInterStep +; call PatchInterStep + + add edi, 12+18 + dec word ptr[CXSetInterAnim] + jnz sao0 ; set tous groupes + jmp short sao4 + +ttrans: cmp ax,TYPE_TRANSLATE + jnz tzoom + + call PatchInterStep ; ax val2 cx val1 bp step bx nbstep + call PatchInterStep ; ax val2 cx val1 bp step bx nbstep + call PatchInterStep ; ax val2 cx val1 bp step bx nbstep + + add edi, 12+18 + dec word ptr[CXSetInterAnim] + jnz sao0 ; set tous groupes + jmp short sao4 + +tzoom: cmp ax,TYPE_ZOOM + jnz argbug + + call PatchInterStep ; ax val2 cx val1 bp step bx nbstep + call PatchInterStep ; ax val2 cx val1 bp step bx nbstep + call PatchInterStep ; ax val2 cx val1 bp step bx nbstep + +argbug: add edi, 12+18 + dec word ptr[CXSetInterAnim] + jnz sao0 ; set tous groupes +sao4: + +serr: xor eax, eax ; anim pas finie + ret + + ; poke dest frame directly + +sao2: add esi, 8 ; saute infos frame + +sao1: movsd ; type ; alpha + movsd ; beta ; gamma + add edi, 12+18 + dec cx + jnz sao1 ; set tous groupes + + mov edi, [StartInfos] + + mov eax, [Offset_Dest] + mov [edi+0], eax ; memo offset + +; mov eax, [ TimerRef ] +; mov [edi+4], eax ; memoticks reset + + mov eax, 1 ; retourne flag anim atteinte + + ret + +SetInterAnimObjet2 endp + + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +SetInterDepObjet proc uses esi edi ebx ebp,\ + framedest:DWORD, ptranimdest:DWORD,\ + ptrobj:DWORD + + mov esi, ptranimdest + mov edx, framedest + + xor eax, eax + mov ax, [esi+2] + lea eax, [8+eax*8] ; (ax+1)*4 WORD ax size 1 frame + mul edx + lea esi, [esi+eax+8] ; si sur time frame dest + + mov [Offset_Dest], esi + + xor edx, edx + mov dx, word ptr[esi] ; dx time to come here + + mov edi, ptrobj + + mov ax, [edi] ; lit infos + test ax, INFO_ANIM ; test si objet possede anim + jz serr ; non tanpis au revoir + + lea edi, [edi+12+2+2] ; saute ZV (+ info) + + mov [StartInfos], edi ; memo start info + + mov eax, [edi+0] ; memo offset source anim + mov ebp, [edi+4] ; lit memoticks + + or eax, eax ; test init ? + jnz sao3 + + mov eax, esi + mov ebp, edx ; first anim poke last frame +sao3: + mov [Offset_Source], eax + + mov eax, ebp + neg ebp + add ebp, [ TimerRef ] ; Cmpt 50 hz + cmp ebp, edx ; if step >= nbstep + jae sao2 ; poke dest frame + + mov ebx, edx ; nb step = time to come here + + mov ecx, [Offset_Dest] + + add [Offset_Source], 8 ; saute infos frame + add [Offset_Dest], 8 ; saute infos frame + + ; la 1ere fois pour le G0 ne tiens pas compte du type + ; et stock valeur calcul‚es + + mov esi, [Offset_Dest] + mov ax, [esi] + mov [AnimMasterRot], ax + + mov ax, [esi+2] ; StepAlpha + imul bp ; resul DX:AX + idiv bx ; /NbStep + mov [AnimStepAlpha], ax + + mov ax, [esi+4] ; StepBeta + imul bp ; resul DX:AX + idiv bx ; /NbStep + mov [AnimStepBeta], ax + + mov ax, [esi+6] ; StepGamma + imul bp ; resul DX:AX + idiv bx ; /NbStep + mov [AnimStepGamma], ax + + add [Offset_Dest], 8 + add [Offset_Source], 8 + +sao4: ; calcul StepXYZ + + mov edi, offset AnimStepX + + mov ax, [ecx+2] ; StepX + imul bp ; resul DX:AX + idiv bx ; /NbStep + mov word ptr[edi], ax + + mov ax, [ecx+4] ; StepY + imul bp ; resul DX:AX + idiv bx ; /NbStep + mov word ptr[edi+2], ax + + mov ax, [ecx+6] ; StepZ + imul bp ; resul DX:AX + idiv bx ; /NbStep + mov word ptr[edi+4], ax + +serr: xor eax, eax ; anim pas finie + ret + + ; poke dest frame directly + +sao2: +;// lea ebp, [eax+edx] + + mov edi, [StartInfos] + + mov eax, [Offset_Dest] + mov [edi+0], eax ; memo offset + + mov eax, [ TimerRef ] + mov [edi+4], eax ; memoticks reset +comment @ + mov eax, [ TimerRef ] + cmp eax, ebp + jae okmemo + + mov ebp, eax +okmemo: + mov [edi+4], ebp ; memoticks reset + @ + ; stock step X Y Z + + add esi, 2 ; sur stepX + + mov edi, offset AnimStepX + movsd + movsw ; stock var DGROUP + + mov edi, offset AnimMasterRot + movsd + movsd ; + AnimStepAlpha, ... + + mov eax, 1 ; retourne flag anim atteinte + + ret + +SetInterDepObjet endp + + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +StockInterAnim proc uses esi edi,\ + ptranimbuf:DWORD,\ + ptrobj:DWORD + + mov edi, ptranimbuf + + mov esi, ptrobj + mov ax, [esi] ; lit infos + test ax, INFO_ANIM ; test si objet possede anim + jz serr ; non tanpis au revoir + + lea esi, [esi+12+2+2] ; saute ZV (+ info) + + mov eax, [ TimerRef ] + mov [esi+4], eax ; reset memoticks + mov [esi+0], edi ; memo off source anim + +cont: xor eax, eax + mov ecx, eax + mov ax, word ptr[esi-2] ; skip param infos + lea esi, [esi+eax] ; skip param infos + mov ax, word ptr[esi] ; nb points + lea eax, [eax+eax*2] ; *3 + lea esi, [esi+eax*2+2] ; saute def points + mov cx, word ptr[esi] ; nb groupes + + lea eax, [ecx*8+8] ; trick pour calculer ecx*8+8 :-) + + lea edi, [edi+8] ; fausse frame info + lea esi, [esi+8+2] ; saute groupe info + +sao1: movsd ; type ; alpha + movsd ; beta ; gamma + add esi, 12+18 + dec cx + jnz sao1 ; set tous groupes + + ret + +serr: xor eax, eax + ret + +StockInterAnim endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +CopyInterAnim proc uses esi edi,\ + ptrobjs:DWORD,\ + ptrobjd:DWORD + + mov esi, ptrobjs + mov ax, word ptr[esi] ; lit infos + test ax, INFO_ANIM ; test si objet possede anim + jz serr ; non tanpis au revoir + + mov edi, ptrobjd + mov ax, word ptr[edi] ; lit infos + test ax, INFO_ANIM ; test si objet possede anim + jz serr ; non tanpis au revoir + + add esi, 12 + 2 + 2 ; saute ZV (+ info) + add edi, 12 + 2 + 2 ; saute ZV (+ info) + + mov eax, [esi+0] + mov [edi+0], eax ; copy memoticks + mov eax, [esi+4] + mov [edi+4], eax ; copy off source anim + + xor eax, eax + mov ax, word ptr[esi-2] ; skip param infos + lea esi, [esi+eax] ; skip param infos + mov ax, word ptr[esi] ; nb points + lea eax, [eax+eax*2] ; *3 + lea esi, [esi+eax*2+2] + mov cx, word ptr[esi] ; nb groupes + + mov ax, word ptr[edi-2] ; skip param infos + lea edi, [edi+eax] ; skip param infos + mov ax, word ptr[edi] ; nb points + lea eax, [eax+eax*2] ; *3 + lea edi, [edi+eax*2+2] + mov ax, word ptr[edi] ; nb groupes + + cmp cx, ax ; 2 body nb groups different ? + jbe ok + mov cx, ax +ok: + add esi, 8 + 2 + add edi, 8 + 2 + +cia0: movsd + movsd + add esi, 22 + 8 + add edi, 22 + 8 + dec cx + jnz cia0 + +serr: ret + +CopyInterAnim endp + + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + + END diff --git a/LIB386/LIB_3D/P_DEFINE.ASH b/LIB386/LIB_3D/P_DEFINE.ASH new file mode 100644 index 0000000..4714748 --- /dev/null +++ b/LIB386/LIB_3D/P_DEFINE.ASH @@ -0,0 +1,38 @@ + +NORMAL_UNIT equ 64 + +INFO_TRI equ 1 +INFO_ANIM equ 2 +INFO_TORTUE equ 4 + +E_LIGNE equ 0 ; drawing entite +E_POLY equ 1 +E_SPHERE equ 2 +E_POINT equ 3 + +TYPE_ROTATE equ 0 +TYPE_TRANSLATE equ 1 +TYPE_ZOOM equ 2 + +TYPE_3D equ 0 +TYPE_ISO equ 1 + +T00 equ 0 +T01 equ 2 +T02 equ 4 +T10 equ 6 +T11 equ 8 +T12 equ 10 +T20 equ 12 +T21 equ 14 +T22 equ 16 + +LT00 equ 0 +LT01 equ 4 +LT02 equ 8 +LT10 equ 12 +LT11 equ 16 +LT12 equ 20 +LT20 equ 24 +LT21 equ 28 +LT22 equ 32 diff --git a/LIB386/LIB_3D/P_FUNC.ASM b/LIB386/LIB_3D/P_FUNC.ASM new file mode 100644 index 0000000..36d955c --- /dev/null +++ b/LIB386/LIB_3D/P_FUNC.ASM @@ -0,0 +1,1259 @@ + + .386p + jumps + + .model SMALL, SYSCALL + + include P_define.ash + + .data + + include \projet\lib386\lib_sys\lib_sys.ash + +Comment @ + +SqrTab dw 0807Fh,0817Dh,08279h,08374h,0846Ch,08562h,08657h,0874Ah + dw 0883Ch,0892Bh,08A19h,08B06h,08BF1h,08CDAh,08DC2h,08EA9h + dw 08F8Eh,09071h,09153h,09234h,09314h,093F2h,094CFh,095AAh + dw 09684h,0975Dh,09835h,0990Ch,099E2h,09AB6h,09B89h,09C5Bh + dw 09D2Ch,09DFCh,09ECBh,09F99h,0A066h,0A132h,0A1FCh,0A2C6h + dw 0A38Fh,0A457h,0A51Eh,0A5E4h,0A6A9h,0A76Dh,0A830h,0A8F3h + dw 0A9B4h,0AA75h,0AB35h,0ABF4h,0ACB2h,0AD6Fh,0AE2Ch,0AEE7h + dw 0AFA2h,0B05Ch,0B116h,0B1CFh,0B286h,0B33Eh,0B3F4h,0B4AAh + dw 0B55Fh,0B613h,0B6C7h,0B77Ah,0B82Ch,0B8DEh,0B98Fh,0BA3Fh + dw 0BAEEh,0BB9Dh,0BC4Ch,0BCF9h,0BDA6h,0BE53h,0BEFFh,0BFAAh + dw 0C055h,0C0FFh,0C1A8h,0C251h,0C2FAh,0C3A1h,0C449h,0C4EFh + dw 0C595h,0C63Bh,0C6E0h,0C784h,0C828h,0C8CCh,0C96Fh,0CA11h + dw 0CAB3h,0CB55h,0CBF5h,0CC96h,0CD36h,0CDD5h,0CE74h,0CF13h + dw 0CFB1h,0D04Eh,0D0EBh,0D188h,0D224h,0D2C0h,0D35Bh,0D3F6h + dw 0D490h,0D52Ah,0D5C4h,0D65Dh,0D6F5h,0D78Eh,0D825h,0D8BDh + dw 0D954h,0D9EAh,0DA81h,0DB16h,0DBACh,0DC41h,0DCD5h,0DD69h + dw 0DDFDh,0DE91h,0DF24h,0DFB6h,0E049h,0E0DBh,0E16Ch,0E1FDh + dw 0E28Eh,0E31Fh,0E3AFh,0E43Eh,0E4CEh,0E55Dh,0E5EBh,0E67Ah + dw 0E708h,0E795h,0E823h,0E8B0h,0E93Ch,0E9C9h,0EA55h,0EAE0h + dw 0EB6Ch,0EBF7h,0EC82h,0ED0Ch,0ED96h,0EE20h,0EEA9h,0EF32h + dw 0EFBBh,0F044h,0F0CCh,0F154h,0F1DCh,0F263h,0F2EAh,0F371h + dw 0F3F7h,0F47Dh,0F503h,0F589h,0F60Eh,0F693h,0F718h,0F79Ch + dw 0F821h,0F8A4h,0F928h,0F9ABh,0FA2Fh,0FAB1h,0FB34h,0FBB6h + dw 0FC38h,0FCBAh,0FD3Ch,0FDBDh,0FE3Eh,0FEBFh,0FF3Fh,0FFBFh + + @ + +ALIGN 4 + + public NoLanguage Distance + public NoLanguage Sqr + +Distance dd 0000 + + public NoLanguage EX0 + public NoLanguage EY0 + +EX0 dd 0000 +EY0 dd 0000 + + extrn nolanguage P_SinTab:WORD + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + .code + + public NoLanguage Rot2D + public NoLanguage Distance2D + public NoLanguage Distance3D + public NoLanguage GetAngle + public NoLanguage RegleTrois32 + public NoLanguage BoundRegleTrois + public NoLanguage InitRealValue + public NoLanguage InitRealAngle + public NoLanguage InitRealAngleConst + public NoLanguage GetRealValue + public NoLanguage GetRealAngle + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ Ûßßßß ÛßßßÛ Û ßßÛßß Û ÛÜ ÜÛ Ûßßßß +; ÛÛßÛß ÛÛßß ÛÛßßÛ ÛÛ ÛÛ ÛÛ ÛÛß Û ÛÛßß +; ßß ß ßßßßß ßß ß ßßßßß ßßßßß ßß ßß ßß ß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +InitRealValue proc \ + StartValue:DWORD,\ + EndValue:DWORD,\ + TimeValue:DWORD,\ + ptrstruct:DWORD + + mov edx, ptrstruct + + mov ax, word ptr[StartValue] + mov word ptr[edx], ax + mov ax, word ptr[EndValue] + mov word ptr[edx+2], ax + mov ax, word ptr[TimeValue] + mov word ptr[edx+4], ax + + mov eax, [ TimerRef ] + mov dword ptr[edx+6], eax ; memoticks init + + ret + +InitRealValue endp + +comment @ + +InitRealValue proc uses edi,\ + StartValue:DWORD,\ + EndValue:DWORD,\ + TimeValue:DWORD,\ + ptrstruct:DWORD + + mov edi, ptrstruct + + mov ax, word ptr[StartValue] + mov word ptr[edi], ax + mov ax, word ptr[EndValue] + mov word ptr[edi+2], ax + mov ax, word ptr[TimeValue] + mov word ptr[edi+4], ax + + mov eax, [ TimerRef ] + mov dword ptr[edi+6], eax ; memoticks init + + ret + +InitRealValue endp + + @ + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +InitRealAngle proc \ + StartValue:DWORD,\ + EndValue:DWORD,\ + TimeValue:DWORD,\ + ptrstruct:DWORD + + mov edx, ptrstruct + + mov ax, word ptr[StartValue] + and ax, 1023 + mov word ptr[edx], ax + mov ax, word ptr[EndValue] + and ax, 1023 + mov word ptr[edx+2], ax + + mov ax, word ptr[TimeValue] + mov word ptr[edx+4], ax + + mov eax, [TimerRef] + mov dword ptr[edx+6], eax ; memoticks init + + ret + +InitRealAngle endp + +comment @ + +InitRealAngle proc uses edi,\ + StartValue:DWORD,\ + EndValue:DWORD,\ + TimeValue:DWORD,\ + ptrstruct:DWORD + + mov edi, ptrstruct + + mov ax, word ptr[StartValue] + and ax, 1023 + mov word ptr[edi], ax + mov ax, word ptr[EndValue] + and ax, 1023 + mov word ptr[edi+2], ax + + mov ax, word ptr[TimeValue] + mov word ptr[edi+4], ax + + mov eax, [TimerRef] + mov dword ptr[edi+6], eax ; memoticks init + + ret + +InitRealAngle endp + + @ + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +InitRealAngleConst proc \ + StartValue:DWORD,\ + EndValue:DWORD,\ + TimeValue:DWORD,\ + ptrstruct:DWORD + + mov edx, ptrstruct + + xor eax, eax ; for imul later on + mov ax, word ptr[StartValue] + and ax, 1023 + mov word ptr[edx], ax + mov cx, word ptr[EndValue] + and cx, 1023 + mov word ptr[edx+2], cx + + sub ax, cx + shl ax, 6 + jns short irac0 + + neg ax +irac0: + shr ax, 6 + imul eax, dword ptr[TimeValue] + shr eax, 8 ; /256 + mov word ptr[edx+4], ax + + mov eax, [TimerRef] + mov dword ptr[edx+6], eax ; memoticks init + + ret + +InitRealAngleConst endp + +comment @ + +InitRealAngleConst proc uses edi ebx,\ + StartValue:DWORD,\ + EndValue:DWORD,\ + TimeValue:DWORD,\ + ptrstruct:DWORD + + mov edi, ptrstruct + + mov ax, word ptr[StartValue] + and ax, 1023 + mov bx, ax + mov word ptr[edi], ax + mov ax, word ptr[EndValue] + and ax, 1023 + mov cx, ax + mov word ptr[edi+2], ax + + + add bx, 1024 + sub bx, cx + and bx, 1023 + cmp bx, 512 + jle irac0 + sub bx, 1024 + neg bx + +irac0: mov ax, word ptr[TimeValue] + imul bx + mov al, ah + mov ah, dl ; /256 + + mov word ptr[edi+4], ax + + mov eax, [TimerRef] + mov dword ptr[edi+6], eax ; memoticks init + + ret + +InitRealAngleConst endp + + @ + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + + +GetRealValue proc uses ebx,\ + ptrstruct:DWORD + + mov ebx, ptrstruct + + movsx eax, word ptr[ebx+2] ; End Value + + mov cx, word ptr[ebx+4] ; TimeValue + or cx, cx ; TimeValue Reach = 0 + jz elapsed + + mov edx, [TimerRef] + sub edx, [ebx+6] ; memoticks + cmp dx, cx ; if step >= nbstep + jae sao2 ; poke EndValue + + ; nb step = time to come here + + sub ax, word ptr[ebx+0] ; start value + imul dx ; resul DX:AX + idiv cx ; /NbStep + add ax, word ptr[ebx+0] ; Valeur1 + movsx eax, ax + + ret + +sao2: mov word ptr[ebx+4], 0 ; TimeValue reset +elapsed: ; return EndValue + ret + +GetRealValue endp + +comment @ + +GetRealValue proc uses esi ebx ebp,\ + ptrstruct:DWORD + + mov esi, ptrstruct + + mov dx, word ptr[esi+4] ; TimeValue + + or dx, dx ; TimeValue Reach = 0 + jz elapsed + + mov ecx, [esi+6] ; memoticks + + mov eax, [TimerRef] + + sub eax, ecx + cmp ax, dx ; if step >= nbstep + jae sao2 ; poke EndValue + + movzx ebx, dx ; nb step = time to come here + mov ebp, eax ; step en cours + + movsx eax, word ptr[esi+2] ; End Value + movsx ecx, word ptr[esi+0] ; start value + sub eax, ecx + imul ebp ; resul DX:AX + idiv ebx ; /NbStep + add eax, ecx ; cx = Valeur1 + + ret + +sao2: mov word ptr[esi+4], 0 ; TimeValue reset + +elapsed: movsx eax, word ptr[esi+2] ; EndValue + ret + +GetRealValue endp + + @ + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +GetRealAngle proc uses ebx,\ + ptrstruct:DWORD + + mov ebx, ptrstruct + + xor eax, eax + mov ax, word ptr[ebx+2] ; EndValue + + mov cx, word ptr[ebx+4] ; TimeAngle + or cx, cx ; TimeAngle Reach = 0 + jz elapsed + + mov edx, [TimerRef] + + sub edx, [ebx+6] ; memoticks + cmp dx, cx ; if step >= nbstep + jae sao2 ; poke EndValue + + ; nb step = time to come here + + sub ax, word ptr[ebx+0] ; start value + cmp ax, -512 + jl short art1 + cmp ax, 512 + jle short ok + +art0: sub ax, 2048 +art1: add ax, 1024 +ok: + imul dx ; resul DX:AX + idiv cx ; / NbStep + add ax, word ptr[ebx+0] ; start value + ret + +sao2: mov word ptr[ebx+4], 0 ; TimeValue reset +elapsed: ; return EndValue + ret + +GetRealAngle endp + +comment @ + +GetRealAngle proc uses esi ebx ebp,\ + ptrstruct:DWORD + + mov esi, ptrstruct + + mov dx, word ptr[esi+4] ; TimeAngle + + or dx, dx ; TimeAngle Reach = 0 + jz elapsed + + mov ecx, [esi+6] ; memoticks + + mov eax, [TimerRef] + + sub eax, ecx + cmp ax, dx ; if step >= nbstep + jae sao2 ; poke EndValue + + mov bx, dx ; nb step = time to come here + mov bp, ax ; step en cours + + mov ax, word ptr[esi+2] ; EndValue + and ax, 1023 + mov cx, word ptr[esi+0] ; start value + and cx, 1023 + mov dx, ax + + sub ax, cx + + cmp ax, 512 + jg art0 + cmp ax,-512 + jl art1 + + imul bp ; resul DX:AX + idiv bx ; bx ; /NbStep + add ax, cx ; cx = Valeur1 + movzx eax, ax + ret + +art0: add cx, 1024 + sub dx, cx + mov ax, dx + + imul bp ; resul DX:AX + idiv bx ; bx ; /NbStep + add ax, cx ; cx = Valeur1 + movzx eax, ax + ret + +art1: add dx, 1024 + sub dx, cx + mov ax, dx + + imul bp ; resul DX:AX + idiv bx ; bx ; /NbStep + add ax, cx ; cx = Valeur1 + movzx eax, ax + ret + +sao2: mov word ptr[esi+4], 0 ; TimeValue reset + +elapsed: movsx eax, word ptr[esi+2] ; EndValue + ret + +GetRealAngle endp + + @ + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +comment # + +StopRealValue proc uses ds si,\ + value:WORD, ptrstruct:PTR + + lds si,ptrstruct + + mov bx,ss:word ptr[FlagFlip] ; Cmpt 60 hz + + mov ax,value + cmp word ptr[si+0],ax ; start value + jz srv0 + + mov word ptr[si+0],ax ; start value + + mov cx,word ptr[si+6] ; memoticks + mov ax,word ptr[si+4] ; time value + sub bx,cx + sub ax,bx + mov word ptr[si+4],ax ; new time value + +srv0: mov word ptr[si+6],bx ; new memoticks + ret + +StopRealValue endp + + # + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ Ûßßßß Ûßßßß Û Ûßßßß ßßßÛÛ +; ÛÛßÛß ÛÛßß ÛÛ ßÛ ÛÛ ÛÛßß ßßßÛÛ +; ßß ß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +BoundRegleTrois proc \ + Valeur1:DWORD, Valeur2:DWORD, \ + NbStep:DWORD, Step:DWORD + + mov eax, Valeur2 + mov ecx, Valeur1 + mov edx, Step + + or edx, edx + jle troppetit + cmp edx, NbStep + jge tropgrand + + sub eax, ecx ; delta valeurs + imul edx ; * Step + idiv NbStep ; /NbStep + add eax, ecx ; + Valeur1 + +tropgrand: ret + +troppetit: mov eax, ecx + ret + +BoundRegleTrois endp + +comment @ + +BoundRegleTrois proc uses ebx ,\ + Valeur1:DWORD, Valeur2:DWORD ,\ + NbStep:DWORD, Step:DWORD + + mov eax, Valeur2 + mov ecx, Valeur1 + mov ebx, NbStep + mov edx, Step + + or edx, edx + jle troppetit + cmp edx, ebx + jge tropgrand + + sub eax, ecx ; delta valeurs + imul edx ; * Step + idiv ebx ; /NbStep + add eax, ecx ; + Valeur1 + +tropgrand: ret + +troppetit: mov eax, ecx + ret + +BoundRegleTrois endp + + @ + +RegleTrois32 proc \ + Valeur1:DWORD, Valeur2:DWORD, \ + NbStep:DWORD, Step:DWORD + + mov eax, Valeur2 + + mov ecx, NbStep + or ecx, ecx ; essai global 8-o + jle short erreur + + sub eax, Valeur1 + imul Step ; resul DX:AX + idiv ecx ; /NbStep + add eax, Valeur1 ; cx = Valeur1 + +erreur: ret + +RegleTrois32 endp + +comment @ + +RegleTrois32 proc uses ebx ,\ + Valeur1:DWORD, Valeur2:DWORD ,\ + NbStep:DWORD, Step:DWORD + + mov eax, Valeur2 + mov ecx, Valeur1 + sub eax, ecx + imul Step ; resul DX:AX + + mov ebx, NbStep +; dec ebx + or ebx, ebx ; essai global 8-o + jle erreur + + idiv ebx ; /NbStep + + add eax, ecx ; cx = Valeur1 + ret + +erreur: mov eax, ecx + ret + +RegleTrois32 endp + + @ + +comment # + +RegleTrois proc \ + Valeur1:WORD, Valeur2:WORD ,\ + NbStep:WORD, Step:WORD + + mov ax, Valeur2 + mov cx, Valeur1 + sub ax, cx + imul Step ; resul DX:AX + + mov bx, NbStep + dec bx + jbe erreur + + idiv bx ; /NbStep + + add ax, cx ; cx = Valeur1 + ret + +erreur: xor ax, ax + ret + +RegleTrois endp + + # +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÛßßß ÛßßßÛ ÛßßßÛ +; ßßßßÛ ÛÛ ÜÛ ÛÛßÛß +; ßßßßß ßßßß ßß ß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; EAX = Sqr(EAX) + +Sqr PROC NEAR USES EBX + + cmp eax, 3 + jbe short asqr_0_1 + + xor edx, edx + mov ebx, eax + + bsr eax, ebx ; cherche dernier bit … 1 + mov cl, 33 + sub cl, al + and cl, -2 ; calcul de combien decaler + ; … gauche pour avoir le + ; premier doublet non nul + ; dans edx + shld edx, ebx, cl + shl ebx, cl + + mov ecx, eax ; doublets restants + shr ecx, 1 + + mov eax, 1 + dec edx + +asqr_loop: shld edx, ebx, 2 + shl ebx, 2 + shl eax, 2 + cmp edx, eax + jc short asqr_neg + + inc eax + sub edx, eax + jnc short asqr_1 + add edx, eax +asqr_neg: shr eax, 1 + dec ecx + jnz short asqr_loop + ret + +asqr_1: inc eax + shr eax, 1 + dec ecx + jnz short asqr_loop + ret + +asqr_0_1: or eax, eax + jz short asqr_00 + mov eax, 1 +asqr_00: ret + +Sqr ENDP + +comment @ + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; EAX = Sqr(EAX) + +Sqr proc near + + cmp eax, 3 + jbe short asqr_0_1 + + mov esi, eax + mov eax, 1 + xor edx, edx + + bsr ebx, esi ; cherche dernier bit … 1 + + mov cx, 33 + sub cx, bx + and cx, -2 ; calcul de combien decaler + ; … gauche pour avoir le + ; premier doublet non nul + ; dans edx + shld edx, esi, cl + shl esi, cl + + mov ecx, ebx ; doublets restants + shr ecx, 1 + inc cx + + dec edx + dec ecx + jnz short asqr_loop + ret + +asqr_loop: shld edx, esi, 2 + shl esi, 2 + shl eax, 1 + mov ebx, edx + shr ebx, 1 + sub ebx, eax + jc short asqr_neg + + mov ebx, eax + stc + rcl ebx, 1 + sub edx, ebx + jc short asqr_0 + inc eax + dec ecx + jnz short asqr_loop + ret + +asqr_0: add edx, ebx +asqr_neg: dec ecx + jnz short asqr_loop + ret + +asqr_0_1: or eax, eax + jnz asqr_1 + ret +asqr_1: mov eax, 1 + ret + +Sqr endp + + @ + +comment @ + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; AX = Sqr(DX:AX) + +Sqr proc near + + xor cx,cx + test dx,dx + jne sq1 + test ax,ax + je is0 + xchg ax,dx + mov cx,8 +sq1: + test dh,dh + jne sq2 + xchg dh,dl + xchg dl,ah + xchg ah,al + add cx,4 +sq2: + test dh,0f0h + jne sq3 + +; shld dx, ax, 4 +; shl ax, 4 + + shl ax, 1 + rcl dx, 1 + shl ax, 1 + rcl dx, 1 + shl ax, 1 + rcl dx, 1 + shl ax, 1 + rcl dx, 1 + + add cx,2 +sq3: + test dh,0c0h + jne sq4 + +; shld dx, ax, 2 +; shl ax, 2 + + shl ax, 1 + rcl dx, 1 + shl ax, 1 + rcl dx, 1 + + inc cx +sq4: + mov bl,dh + xor bh,bh + shl bx,1 + mov bx,[ SqrTab + bx-64*2 ] + cmp dx,bx + jae sq5 + div bx + add ax,bx + rcr ax,1 + shr ax,cl +is0: + ret +sq5: + mov ax,dx + stc + rcr ax,1 + shr ax,cl + + ret + +Sqr endp + + @ + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÜ Û ÛÛßßß ßßÛßß ÛßßßÛ ÛÛÜ Û Ûßßßß Ûßßßß +; ÛÛ Û ÛÛ ßßßßÛ ÛÛ ÛÛßßÛ ÛÛßÛÛ ÛÛ ÛÛßß +; ßßßß ßß ßßßßß ßß ßß ß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +Distance2D proc \ + px0:DWORD,py0:DWORD, px1:DWORD,py1:DWORD + + mov eax, px1 + sub eax, px0 ; Dx = x1-x0 + imul eax, eax ; Dxý + + mov ecx, py1 + sub ecx, py0 ; Dy = y1-y0 + imul ecx, ecx ; Dyý + add eax, ecx ; Dxý + Dyý + + call Sqr ; eax = û (Dxý+Dyý) + + ret + +Distance2D endp + +comment @ + +Distance2D proc uses ebx,\ + px0:DWORD,py0:DWORD, px1:DWORD,py1:DWORD + + mov eax, px1 + sub eax, px0 ; Dx = x1-x0 + imul eax, eax ; Dxý + + mov ebx, py1 + sub ebx, py0 ; Dy = y1-y0 + imul ebx, ebx ; Dyý + add eax, ebx ; Dxý + Dyý + + call Sqr ; eax = û (Dxý+Dyý) + + ret + +Distance2D endp + + @ + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +Distance3D proc \ + px0:DWORD,py0:DWORD,pz0:DWORD, px1:DWORD,py1:DWORD,pz1:DWORD + + + mov eax, px1 + sub eax, px0 + imul eax, eax ; Dxý + + mov ecx, py1 + sub ecx, py0 + imul ecx, ecx ; Dyý + add eax, ecx + + mov ecx, pz1 + sub ecx, pz0 + imul ecx, ecx ; Dzý + add eax, ecx + + call Sqr ; eax = û (Dxý+Dyý+Dzý) + + ret + +Distance3D endp + +comment @ + +Distance3D proc uses ebx,\ + px0:DWORD,py0:DWORD,pz0:DWORD, px1:DWORD,py1:DWORD,pz1:DWORD + + + mov eax, px1 + sub eax, px0 + imul eax, eax ; Dxý + + mov ebx, py1 + sub ebx, py0 + imul ebx, ebx ; Dyý + add eax, ebx + + mov ebx, pz1 + sub ebx, pz0 + imul ebx, ebx ; Dzý + add eax, ebx + + call Sqr ; eax = û (Dxý+Dyý+Dzý) + + ret + +Distance3D endp + + @ + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ßßÛßß ÛßßßÛ Û Ûßßßß ÛßßßÛ +; ÛÛ ÛÛßÛß ÛÛ ÛÛ ßÛ ÛÛ Û +; ßß ßß ß ßß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +GetAngle proc uses esi edi ebx ebp,\ + x0:DWORD, z0:DWORD, x1:DWORD, z1:DWORD + + + mov edx, z1 + sub edx, z0 ; z = z1 - z0 + mov edi, edx ; save z + + mov eax, x1 + sub eax, x0 ; x = x1 - x0 + mov ebp, eax ; save x + + imul eax, eax ; xý + imul edx, edx ; zý + cmp eax, edx + jae noswap + xchg ebp, edi ; permute x z + or ebp, 1 + jmp short carre +noswap: + and ebp, -2 +carre: + add eax, edx ; eax = xý + zý + call Sqr ; eax = sqr(xý + zý) + + mov [Distance], eax + + or eax, eax ; si longueur 0 alors angle 0 + jz fgetangle + + xchg eax, edi + sal eax, 14 + cdq + idiv edi + + mov esi, offset P_SinTab + 384 * 2 + lea edi, [esi+256*2] + +ga2: mov ebx, esi + add ebx, edi + shr ebx, 1 + + cmp ax, [ebx] + jle ga0 + mov edi, ebx + jmp short ga1 +ga0: mov esi, ebx + je short fgaloop + + mov ebx, edi +ga1: sub ebx, esi + dec ebx + jnz short ga2 + + movsx ebx, word ptr [esi] + movsx edx, word ptr [edi] + add ebx, edx + sar ebx, 1 + cmp bx, ax + jg short fgaloop + mov esi, edi + +fgaloop: sub esi, offset P_SinTab + 256 * 2 + mov eax, esi + shr eax, 1 + + or ebp, ebp + jns short fga + neg eax +fga: + test ebp, 1 + jz short norestore + neg eax + add eax, 256 +norestore: + and eax, 1023 +fgetangle: + ret + +GetAngle endp + + +comment @ + + +GetAngle proc uses esi edi ebx ebp,\ + x0:DWORD, z0:DWORD, x1:DWORD, z1:DWORD + + + mov edx, z1 + sub edx, z0 ; z = z1 - z0 + mov edi, edx ; save z + jns nonegedx ; abs(z) + neg edx +nonegedx: + mov eax, x1 + sub eax, x0 ; x = x1 - x0 + mov ebp, eax ; save x + jns nonegeax ; abs(x) + neg eax +nonegeax: + cmp eax, edx + jae noswap + xchg eax, edx ; permute x z + xchg ebp, edi + or ebp, 1 + jmp short carre +noswap: + and ebp, -2 +carre: + imul eax, eax + imul edx, edx + add eax, edx ; eax = xý + zý + + call Sqr + + mov [Distance], eax + + or eax, eax ; si longueur 0 alors angle 0 + jz fgetangle + + + xchg eax, edi + sal eax, 14 + cdq + idiv edi + + mov esi, offset P_SinTab + 384 * 2 + mov edi, esi + add edi, 256 * 2 + +ga2: mov ebx, esi + add ebx, edi + shr ebx, 1 + + cmp ax, [ebx] + jle ga0 + mov edi, ebx + jmp short ga1 +ga0: mov esi, ebx + je fgaloop + + mov ebx, edi +ga1: sub ebx, esi + dec ebx + jnz ga2 + + movsx ebx, word ptr [esi] + movsx edx, word ptr [edi] + add ebx, edx + sar ebx, 1 + cmp bx, ax + jg fgaloop + mov esi, edi + + +fgaloop: sub esi, offset P_SinTab + 256 * 2 + mov eax, esi + shr eax, 1 + + or ebp, ebp + jns fga + neg eax + +fga: + test ebp, 1 + jz norestore + mov ebx, eax + mov eax, 256 + sub eax, ebx +norestore: + and eax, 1023 +fgetangle: + ret + +GetAngle endp + + @ + +comment @ + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Rotation 2D autour d'un axe +; entr‚e: eax=X ecx=Y edx=T +; +; sortie: eax = X'=X*cos(T)-Y*sin(T) +; ecx = Y'=X*sin(T)+Y*cos(T) +; +; ( ebx, ebp, edi d‚truits ) +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +RotEXY proc + + or edx, edx + jz short norot + + and edx, 03FFh + movsx ebx, word ptr[P_SinTab + edx*2] ; ebx = Sin( T ) + add dx, 256 + and dx, 03FFh + movsx edx, word ptr[P_SinTab + edx*2] ; edx = Cos( T ) + + mov ebp, eax ; ebp = X + mov edi, ecx ; edi = Y + + imul eax, edx ; X*cos(T) + imul edi, ebx ; Y*sin(T) + sub eax, edi + sar eax, 15 ; eax = X' = X*cos(T)-Y*sin(T) + + imul ecx, edx ; Y*cos(T) + imul ebp, ebx ; X*sin(T) + add ecx, ebp + sar ecx, 15 ; ecx = Y' = X*sin(T) + Y*cos(T) +norot: ret + +RotEXY endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Rotation 2D autour d'un axe +; entr‚e: ebx=X ecx=Y ebp=T +; +; sortie: eax = X'=X*cos(T)-Y*sin(T) +; edx = Y'=X*sin(T)+Y*cos(T) +; +; ( ebx, ebp, edi d‚truits ) +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +RotEXY proc + + or ebp, ebp + jz norot + + mov eax, ebp ; T + and eax, 03FFh + mov edi, offset P_SinTab + movsx ebp, word ptr[ edi+eax*2 ] ; ebp = Sin( T ) + add eax, 256 + and eax, 03FFh + movsx edx, word ptr[ edi+eax*2 ] ; edx = Cos( T ) +; X*cos(T) + mov eax, ebx + imul eax, edx + mov edi, eax +; Y*sin(T) + mov eax, ecx + imul eax, ebp + sub edi, eax + sar edi, 15 ; di= X'= X*cos(T)-Y*sin(T) +; Y*cos(T) + imul edx, ecx +; X*sin(T) + imul ebx, ebp + add edx, ebx ; Y' = X*sin(T) + Y*cos(T) + sar edx, 15 ; edx = Y' + + mov eax, edi ; eax = X' + xor ecx, ecx + + ret + +norot: mov eax, ebx ; ax = X' = X + mov edx, ecx ; dx = Y' = Y + ret + +RotEXY endp + + @ + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +Rot2D proc uses ebx,\ + coorx:DWORD,coory:DWORD,angle:DWORD + + mov edx, angle + mov eax, coorx + mov ecx, coory + + or edx, edx + jz short norot + + and edx, 03FFh + movsx ebx, word ptr[P_SinTab + edx*2] ; ebx = Sin( T ) + add dx, 256 + and dx, 03FFh + movsx edx, word ptr[P_SinTab + edx*2] ; edx = Cos( T ) + + imul eax, edx ; X*cos(T) + imul ecx, ebx ; Y*sin(T) + sub eax, ecx + sar eax, 15 ; eax = X' = X*cos(T)-Y*sin(T) + mov [EX0], eax + + imul edx, coory ; Y*cos(T) + imul ebx, coorx ; X*sin(T) + add edx, ebx + sar edx, 15 ; edx = Y' = X*sin(T) + Y*cos(T) + mov [EY0], edx + + ret + +norot: mov [EX0], eax + mov [EY0], ecx + ret + +Rot2D endp + +comment @ + +Rot2D proc uses ebx ebp edi,\ + coorx:DWORD,coory:DWORD,angle:DWORD + + mov eax, coorx + mov ecx, coory + mov edx, angle + call RotEXY + mov [EX0], eax + mov [EY0], ecx + ret + +Rot2D endp + + @ + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + + END diff --git a/LIB386/LIB_3D/P_OBJET.ASM b/LIB386/LIB_3D/P_OBJET.ASM new file mode 100644 index 0000000..9c4a840 --- /dev/null +++ b/LIB386/LIB_3D/P_OBJET.ASM @@ -0,0 +1,1749 @@ + .386p + jumps + + .model SMALL, C + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÜ ÜÛ ÛßßßÛ ÛßßÛ Û Ûßßßß ßßÛßß +; ÛÛß Û ÛÛ Û ÛÛßßÛ ÜÜ Û ÛÛßß ÛÛ +; ßß ß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + + include p_define.ash + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + .data +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + + ; extern M_TRIGO + + extrn NoLanguage CameraXr:WORD + extrn NoLanguage CameraYr:WORD + extrn NoLanguage CameraZr:WORD + extrn NoLanguage X0:WORD + extrn NoLanguage Y0:WORD + extrn NoLanguage Z0:WORD + extrn NoLanguage XCentre:WORD + extrn NoLanguage YCentre:WORD + + extrn NoLanguage lAlpha:WORD + extrn NoLanguage lBeta:WORD + extrn NoLanguage lGamma:WORD + + extrn NoLanguage NormalXLight:WORD + extrn NoLanguage NormalYLight:WORD + extrn NoLanguage NormalZLight:WORD + + extrn NoLanguage MatriceTempo:WORD + extrn NoLanguage MatriceWorld:WORD + extrn NoLanguage MatriceRot:WORD + + extrn NoLanguage IsoScale:WORD + extrn NoLanguage TypeProj:WORD + + + extrn NoLanguage Mat00:WORD + extrn NoLanguage Mat01:WORD + extrn NoLanguage Mat02:WORD + extrn NoLanguage Mat10:WORD + extrn NoLanguage Mat11:WORD + extrn NoLanguage Mat12:WORD + extrn NoLanguage Mat20:WORD + extrn NoLanguage Mat21:WORD + extrn NoLanguage Mat22:WORD + + extrn NoLanguage compteur:WORD + + ; extern LIB_GRAF + + extrn NoLanguage NbPolyPoints:WORD + extrn NoLanguage TabPoly:WORD + extrn NoLanguage TypePoly:WORD + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + public NoLanguage FlagLight + + public NoLanguage List_Point + public NoLanguage NbPoints + + public NoLanguage List_Anim_Point + public NoLanguage List_Entity + public NoLanguage List_Tri + + public NoLanguage ScreenXmin + public NoLanguage ScreenYmin + public NoLanguage ScreenXmax + public NoLanguage ScreenYmax + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +List_Point dw (500*3) dup(00) ; Xp Yp Zrot + +List_Normal dw 500 dup(00) ; surement plus + +List_Anim_Point dw (500*3) dup(00) ; Xr Yr Zr + +List_Entity dw 5000 dup(00) ; TAILLE … determin‚e + +List_Tri dw (500*8) dup(00) ; entites + +PosXWr dw 00 ; pos World rot‚e de l'objet … afficher +PosYWr dw 00 +PosZWr dw 00 + +ScreenXmin dw 00 +ScreenYmin dw 00 +ScreenXmax dw 00 +ScreenYmax dw 00 + +NbPoints dw 00 +TotalEntite dw 00 + +PointeurListTri dd 00 +StartDI dd 00 +NextDI dd 00 + +ZMax dw 00 + +NbGroupes dw 00 +ListGroupe dd 00 + +Infos dw 00 +StartInfos dd 00 +OffsetDefPoint dd 00 +OffsetListNormal dd 00 + +FlagLight dw 01 + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +TabJump_2 dd aff_E_LIGNE + dd aff_E_POLY + dd aff_E_SPHERE + +; dd aff_E_POINT + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + .code +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + + + public NoLanguage AffObjet + + + extrn NoLanguage ComputePoly:PROC + extrn NoLanguage ComputeSphere_A:PROC + extrn NoLanguage FillVertic_A:PROC + extrn NoLanguage Line_A:PROC + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + + extrn NoLanguage RotMatW:near + extrn NoLanguage RotMat:near + extrn NoLanguage WorldRot:near + extrn NoLanguage Rot:near + extrn NoLanguage Proj:near + extrn NoLanguage RotList:near + extrn NoLanguage TransRotList:near + extrn NoLanguage RotListNormal:near + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ Ûßßßß Ûßßßß ÛßßßÛ ÛßßÛ Û Ûßßßß ßßÛßß +; ÛÛßßÛ ÛÛßß ÛÛßß ÛÛ Û ÛÛßßÛ ÜÜ Û ÛÛßß ÛÛ +; ßß ß ßß ßß ßßßßß ßßßßß ßßßßß ßßßßß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + + +AffObjet proc uses esi edi ebx ebp,\ + xwr:DWORD, ywr:DWORD, zwr:DWORD,\ + palpha:DWORD, pbeta:DWORD, pgamma:DWORD,\ + ptrobj:DWORD + + mov eax, palpha + mov [lAlpha], ax + mov eax, pbeta + mov [lBeta], ax + mov eax, pgamma + mov [lGamma], ax + + mov ax, 32767 + mov [ScreenXmin], ax + mov [ScreenYmin], ax + neg ax + mov [ScreenXmax], ax + mov [ScreenYmax], ax + +;*-------------------------------------------------------------------------- +;* rotation world org obj + + mov eax, xwr ; X World rot + mov ebx, ywr ; Y World + mov ecx, zwr ; Z World + + push ebp + call WorldRot + pop ebp + + mov ax, [CameraXr] + sub ax, [X0] + mov [PosXWr], ax + + mov ax, [CameraYr] + sub ax, [Y0] + mov [PosYWr], ax + + mov ax, [CameraZr] + sub ax, [Z0] +; iso or ax, ax +; jle finafobjshort ; objet Z <= 0 + mov [PosZWr], ax + +;*-------------------------------------------------------------------------- +;* recup infos + + mov [TotalEntite], 0 + mov [PointeurListTri], offset List_Tri + + mov esi, ptrobj + + lodsw ; infos + mov bx, ax + mov [Infos], ax + + add esi, 12 ; saute ZV + + lodsw ; nb bytes to skip + movzx eax, ax + add esi, eax ; saute zone info + +;*--------------------------------------------------------------------------* +;* rotation nuage/normal face/normal point + + test bx, INFO_ANIM + jz normalrotate + + call AnimNuage ; Objet Anim‚ + call ComputeAnimNormal + jmp short finnuage + +normalrotate: call RotateNuage ; Objet Normal + call ComputeStaticNormal + jmp short finnuage + +finafobjshort: jmp badfinafobj_2 + +finnuage: + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛßßßÛ Û Û Üß Ûßßßß ÛßßßÛ ÛÛÜ Û Ûßßßß ÛÛßßß +; ÛÛßßß ÛÛ Û ÛÛ ÛÛß ÛÛ ßÛ ÛÛ Û ÛÛßÛÛ ÛÛßß ßßßßÛ +; ßß ßßßßß ßßßßß ßß ßßßßß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + + mov edi, offset List_Entity + + lodsw ; nb polys + movzx ecx, ax + jecxz short_lignes + +b_poly: push ecx + + mov [StartDI], edi ; memo pointeur List_Coor + + lodsb ; matiere poly + + cmp al, 9 ; >= MAT_GOURAUD + jae polygouraud + + cmp al, 7 ; >= MAT_FLAT + jae polyflat + +;----------------------------------------------------------------------------- +; MAT_TRISTE->MAT_TRAME + + mov byte ptr[edi], al ; stock type + + lodsb ; nb point poly + mov byte ptr[edi+1], al ; stock nbp + add edi, 2 + xor ah, ah + mov cx, ax + + movsw ; stock coul1/coul2 + + mov bp, 32000 ; ZMax + + push edi ; memo start poly somm + + EVEN +p0: lodsw ; index point sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + xchg ebx, esi + lodsw + mov word ptr[edi+2], ax ; Xscr + + lodsw + mov word ptr[edi+4], ax ; Yscr dans List_Coor + add edi, 6 + + lodsw ; Zrot +; iso or ax, ax +; js skippoly ; <0 ? + + cmp ax, bp ; ZMin + jge nozmax + mov bp, ax +nozmax: + mov esi, ebx + dec ecx + jnz p0 + + jmp testpoly + +short_lignes: jmp lignes + +;----------------------------------------------------------------------------- +; MAT_GOURAUD + + +polygouraud: ;cmp [FlagLight], 0 + ;jz nolight2 + + dec al + dec al ; attention voir reanim + mov byte ptr[edi], al ; stock type translated + + lodsb ; nb point poly + mov byte ptr[edi+1], al ; stock nbp + xor ah, ah + movzx ecx, ax + + lodsw + mov word ptr[edi+2], ax ; stock coul1/coul2 + add edi, 4 + mov dx, ax + + mov bp, -32000 ; ZMax + + push edi ; memo start poly somm + + EVEN +p0g: + lodsw ; normal point + movzx eax, ax + mov ax, word ptr[List_Normal + eax * 2] + add al, dl + mov word ptr[edi+0], ax ; stock intensity point + + lodsw ; index point sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + xchg ebx, esi + lodsw + mov word ptr[edi+2], ax ; Xscr + lodsw + mov word ptr[edi+4], ax ; Yscr dans List_Coor + add edi, 6 + + lodsw ; Zrot + + ; voir pour "depthcueing" vers sombre + +; iso or ax, ax +; js skippolyg + + cmp ax, bp ; ZMin + jle nozmaxg + mov bp, ax +nozmaxg: + mov esi, ebx + dec ecx + jnz p0g + + jmp testpoly + +;----------------------------------------------------------------------------- +; gouraud --> MAT_TRISTE->MAT_TRAME + + +nolight2: xor al,al + mov byte ptr[edi], al ; stock type + + lodsb ; nb point poly + mov byte ptr[edi+1], al ; stock nbp + add edi, 2 + xor ah, ah + mov cx, ax + + movsw ; stock coul1/coul2 + + mov bp, 32000 ; ZMax + + push edi ; memo start poly somm + + EVEN +p0l: lodsw ; oublie normal + + lodsw ; index point sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + xchg ebx, esi + lodsw + mov word ptr[edi+2], ax ; Xscr + + lodsw + mov word ptr[edi+4], ax ; Yscr dans List_Coor + add edi, 6 + + lodsw ; Zrot +; iso or ax, ax +; js skippoly ; <0 ? + + cmp ax, bp ; ZMin + jge nozmaxl + mov bp, ax +nozmaxl: + mov esi, ebx + dec ecx + jnz p0l + + jmp testpoly + +;----------------------------------------------------------------------------- +; MAT_FLAT +polyflat: sub al, 7 + mov byte ptr[edi], al ; stock mat translat‚ + + lodsb ; nb point poly + mov byte ptr[edi+1], al ; stock nbp + xor ah, ah + movzx ecx, ax + + lodsw + mov bp, ax ; coul1/coul2 + + ; 1st coul = normal face + lodsw + movzx eax, ax + add bp, word ptr[ List_Normal + eax*2 ] + mov ax, bp + mov word ptr[edi+2], ax ; stock coul + intensity + add edi, 4 + + push edi ; memo start poly somm + + mov bp, -32000 ; ZMax + + EVEN +p0f: lodsw ; index point sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + xchg ebx, esi + lodsw + mov word ptr[edi+2], ax ; Xscr + + lodsw + mov word ptr[edi+4], ax ; Yscr dans List_Coor + add edi, 6 + + lodsw ; Zrot +; iso or ax, ax +; js skippoly + + cmp ax, bp ; ZMin + jle nozmaxf + mov bp, ax +nozmaxf: + mov esi, ebx + dec ecx + jnz p0f + + jmp testpoly + +skippoly: mov esi, ebx + dec ecx + shl ecx, 1 + add esi, ecx ; skip points restant + pop edi + jmp badpoly + +skippolyg: mov esi, ebx + dec ecx + shl ecx, 2 + add esi, ecx ; skip points restant + pop edi + jmp short badpoly + +;----------------------------------------------------------------------------- +testpoly: mov [NextDI], edi ; memo pointeur List_Coor + + pop edi ; pointeur list sommets + + mov [ZMax], bp + + mov bx, [edi+8] + sub bx, [edi+2] + mov ax, [edi+4] + sub ax, [edi+16] + imul bx + mov bp,ax + mov bx,dx + mov cx, [edi+10] + sub cx, [edi+4] + mov ax, [edi+2] + sub ax, [edi+14] + imul cx + + sub ax, bp ; oublie face si bx:bp < dx:ax + sbb dx, bx + jnl badpoly + +okpoly: + inc [TotalEntite] + mov edi, [PointeurListTri] + mov ax, [ZMax] + mov word ptr[edi], ax + mov ax, E_POLY + mov word ptr[edi+2], ax + mov eax, [StartDI] + mov dword ptr[edi+4], eax + add edi, 8 + mov [PointeurListTri], edi + +;----------------------------------------------------------------------------- + + mov edi, [NextDI] +nextpoly: pop ecx + dec ecx + jz lignes + jmp b_poly + +badpoly: mov edi, [StartDI] + jmp nextpoly + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Û Û Ûßßßß ÛÛÜ Û Ûßßßß ÛÛßßß +; ÛÛ ÛÛ ÛÛ ßÛ ÛÛßÛÛ ÛÛßß ßßßßÛ +; ßßßßß ßß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +lignes: lodsw ; nb lignes + movzx ecx, ax + jecxz spheres + +b_line: mov [StartDI], edi ; memo pointeur List_Coor + + movsd ; stock matiere/coul + ; coul2 / even + + lodsw ; index point 1 sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + mov eax, [ebx+00] + mov dword ptr[edi], eax ; X1scr vers List_Coor + ; Y1scr + mov dx, [ebx+04] ; Zrot ZMin/Max + + lodsw ; index point 2 sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + mov eax, [ebx+00] + mov dword ptr[edi+4], eax ; X2scr vers List_Coor + add edi, 8 + ; Y2scr + mov bp, [ebx+04] ; Zrot ZMin/Max + + mov [NextDI], edi + + cmp dx, bp ; ZMin ZMax + jl zok0 + xchg dx, bp ; DX < BP +zok0: +; iso or dx, dx ; ZMin +; jle badline + +okline: inc [TotalEntite] + mov edi, [PointeurListTri] + mov ax, bp + mov word ptr[edi], ax + mov ax, E_LIGNE + mov word ptr[edi+2], ax + mov eax, [StartDI] + mov dword ptr[edi+4], eax + add edi, 8 + mov [PointeurListTri], edi + + mov edi, [NextDI] + dec ecx + jnz b_line + jmp short spheres + +badline: mov edi, [StartDI] + loope b_line + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÛßßß ÛßßßÛ Û Û Ûßßßß ÛßßßÛ Ûßßßß ÛÛßßß +; ßßßßÛ ÛÛßßß ÛÛßßÛ ÛÛßß ÛÛßÛß ÛÛßß ßßßßÛ +; ßßßßß ßß ßß ß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +spheres: lodsw ; nb spheres + movzx ecx, ax + jecxz tri + +b_sphere: mov [StartDI], edi ; memo pointeur List_Coor + movsd ; stock matiere/coul + ; coul2 / even + movsw ; rayon + lodsw ; index point 1 sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + mov eax, [ebx+00] ; X1scr vers List_Coor + mov dword ptr[edi], eax ; Y1scr + mov ax, [ebx+04] ; Zrot ZMin/Max + mov word ptr[edi+4], ax + add edi, 6 + + mov [NextDI], edi + +; iso or ax, ax ; ZMin +; jle badsphere + +oksphere: inc [TotalEntite] + mov edi, [PointeurListTri] + mov word ptr[edi], ax + mov ax, E_SPHERE + mov word ptr[edi+2], ax + mov eax, [StartDI] + mov dword ptr[edi+4], eax + add edi, 8 + mov [PointeurListTri], edi + + mov edi, [NextDI] + dec ecx + jnz b_sphere + jmp short tri + +badsphere: mov edi, [StartDI] + dec ecx + jnz b_sphere + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ßßÛßß ÛßßßÛ Û Ûßßßß ÛÛÜ Û ßßÛßß Û ßßÛßß Û Üß +; ÛÛ ÛÛßÛß ÛÛ ÛÛßß ÛÛßÛÛ ÛÛ ÛÛ ÛÛ ÛÛß +; ßß ßß ß ßß ßßßßß ßßßßß ßß ß ßß ßß ßß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; tri les faces dans la table Listtri (ordre Z et offset sur list coors +; premachees. + +tri: movzx ecx, word ptr[TotalEntite] + dec ecx + jz fintri + + mov esi, offset List_Tri + lea ebp, List_Tri + ecx*8 + +SergeSort:: ; esi bas + ; ebp haut + ; ecx nbr d'elements + + ; ax pivot + ; edi pospivot + ; ebx h + + push 0 ; flag de fin de pile ! + + jmp nocalccx + +plusgrand: mov ebx, edi + mov eax, [edi] + jmp short cont + +permut: ; ecx nb entite - 1 + ; esi start list sizeof 8 byte + +tt0: mov ebp, ecx + mov eax, [esi] ; lit Z + + mov edi, esi + add edi, 8 + xor ebx, ebx + +tt1: cmp [edi], ax + jg plusgrand +cont: add edi, 8 + dec ecx + jnz tt1 + + or ebx, ebx + jz short noexchg + + xchg [esi], eax ; permutte + mov [ebx], eax + mov eax, [esi+04] + xchg [ebx+04], eax + mov [esi+04], eax + +noexchg: add esi, 8 + mov ecx, ebp + dec ecx + jnz tt0 + + pop ebp + or ebp, ebp + jnz short dopop + jmp fintri + +permut2: mov eax, [esi] + mov ebx, [ebp] + + cmp ax, bx + jge short skipswap + + mov [esi], ebx + mov [ebp], eax + mov eax, [esi+04] + xchg [ebp+04], eax + mov [esi+04], eax +skipswap: + pop ebp + or ebp, ebp + jz short fintri + +dopop: pop esi +nopop: + mov ecx, ebp + sub ecx, esi + shr ecx, 3 +nocalccx: + cmp ecx, 1 ; select permut2 ? + je short permut2 + + cmp ecx, 7 ; select permut ou qsort + jbe short permut + + mov edi, esi ; pospivot = bas + + mov eax, [edi] ; pivot = [pospivot] = [bas] + + add esi, 8 ; bas++ + + mov ebx, ebp ; h = haut + +w1: cmp word ptr[esi], ax + jl short w2 + add esi, 8 ; si [bas] >= pivot + dec ecx + jnz w1 + + jmp short w4 + +w2: cmp word ptr[ebx], ax + jg short w3 + sub ebx, 8 ; si [h] <= pivot + dec ecx + jnz w2 + + jmp short w4 + +w3: mov edx, [esi] ; xchg [bas],[h] + xchg edx, [ebx] + mov [esi], edx + mov edx, [esi+4] + xchg edx, [ebx+4] + mov [esi+4], edx + + jmp short w1 +w4: + xchg esi, ebx ; idem que esi-=8 et ebx+=8 + + xchg [esi], eax ; xchg [pospivot],[bas] + mov [edi], eax + mov edx, [edi+4] + xchg edx, [esi+4] + mov [edi+4], edx + + cmp ebx, ebp + jae short nopush + + push ebx ; h + push ebp ; haut +nopush: + sub esi, 8 + cmp edi, esi + jae short norecur + + mov ebp, esi + mov esi, edi + jmp nopop +norecur: + pop ebp + or ebp, ebp + jnz dopop +fintri: + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÜ Û ÛÛßßß ÛßßßÛ Û ÛßßßÛ Û Üß +; ÛÛ Û ÛÛ ßßßßÛ ÛÛßßß ÛÛ ÛÛßßÛ ÛÛß +; ßßßß ßß ßßßßß ßß ßßßßß ßß ß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; affichage des entit‚s + + mov esi,offset List_Tri + + movzx ecx, [TotalEntite] + jcxz badfinafobj_1 + +ade0: push ecx + inc esi + inc esi ; saute Z max + + lodsw ; type entit‚ + movzx ebx, ax + lodsd ; offset List_Coor + push esi + mov esi, eax + + jmp [ TabJump_2 + ebx*4 ] ; jmp … aff de l'entit‚ + +nextaff: pop esi + pop ecx + dec ecx + jnz ade0 + +goodfinobj: xor eax, eax ; OK affich‚ au moins 1 entit‚ + ret + +;*--------------------------------------------------------------------------*/ + +badfinafobj_1: ; 1 si pas d'entite to aff + mov ax,-1 + mov [ScreenXmax], ax + mov [ScreenYmax], ax + mov [ScreenXmin], ax + mov [ScreenYmin], ax + mov eax, 1 + ret + +badfinafobj_2: mov ax, -1 + mov [ScreenXmax], ax + mov [ScreenYmax], ax + mov [ScreenXmin], ax + mov [ScreenYmin], ax + + mov eax, 2 ; 2 si objet clipp‚ en Z <= 0 + ret + +AffObjet endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Ûßßßß ÛÛÜ Û ßßÛßß Û ßßÛßß Û Üß +; ÛÛßß ÛÛßÛÛ ÛÛ ÛÛ ÛÛ ÛÛß +; ßßßßß ßß ß ßß ßß ßß ßß +; +; ÛßßßÜ Û ÛÛßßß ÛßßßÛ Û ÛßßßÛ Û Üß +; ÛÛ Û ÛÛ ßßßßÛ ÛÛßßß ÛÛ ÛÛßßÛ ÛÛß +; ßßßß ßß ßßßßß ßß ßßßßß ßß ß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +aff_E_POLY:: + lodsb ; type (ATTENTION GOURAUD) + xor ah, ah + mov bx, ax + mov [TypePoly], ax + + lodsb ; nb points + movzx ecx, ax + mov [NbPolyPoints], ax + + lodsw ; coul1/coul2 + mov dx, ax + + mov edi, ecx + shl ecx, 1 + add ecx, edi ; *3 word + mov edi, offset TabPoly + rep movsw ; … changer + + mov si, bx ; type + mov di, dx ; coul + + call ComputePoly + or ax, ax + jz no_poly + + mov cx, si ; type + call FillVertic_A + +no_poly: jmp nextaff + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +aff_E_LIGNE:: + lodsw + xchg al, ah + mov bp, ax + inc esi + inc esi + + lodsw ; x0 + movsx edx, ax + lodsw ; y0 + movsx ebx, ax + lodsw ; x1 + movsx ecx, ax + lodsw ; y1 + movsx eax, ax + xchg eax, edx + + call Line_A + + jmp nextaff + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +aff_E_SPHERE:: + xor eax, eax + lodsb ; type + push eax ; mov [TypePoly], ax + + lodsw ; coul1/coul2 + push eax + + inc esi ; even + + lodsw ; rayon + movzx ebp, ax + lodsw ; x + movzx ecx, ax + lodsw ; y + movzx edi, ax + lodsw ; Zr + +; iso xchg eax, ebp +; imul word ptr[LFactorX] +; add bp, [KFactor] +; idiv bp +; movzx ebp, ax pfeu + + mov ax, 34 ; racine sxý+syý + imul bp + idiv word ptr[IsoScale] + movzx ebp, ax + + ; ecx x + ; edi y -> esi pour computesphere + ; ebp rayon sur ecran + + ; reajuste coordonn‚e box + + mov ax, cx ; x + rayon + add ax, bp + cmp ax, [ScreenXmax] + jle nosxa + mov [ScreenXmax], ax +nosxa: mov ax, cx ; x - rayon + sub ax, bp + cmp ax, [ScreenXmin] + jge nosxi + mov [ScreenXmin], ax +nosxi: mov ax, di + add ax, bp ; y + rayon + cmp ax, [ScreenYmax] + jle nosya + mov [ScreenYmax], ax +nosya: mov ax, di ; y - rayon + sub ax, bp + cmp ax, [ScreenYmin] + jge nosyi + mov [ScreenYmin], ax +nosyi: + + mov esi, edi + call ComputeSphere_A + + pop edi ; coul + pop ecx ; type + + or eax, eax + jz no_sphere + + call FillVertic_A + +no_sphere: jmp nextaff + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; sous programmes +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛÛÜ Û Û ÛÜ ÜÛ ÛßßßÛ ÛßßßÛ ßßÛßß +; ÛÛßßÛ ÛÛßÛÛ ÛÛ ÛÛß Û ÛÛßÛß ÛÛ Û ÛÛ +; ßß ß ßß ß ßß ßß ß ßßßßß ßß ß ßßßßß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +RotateGroupe proc near + + mov [lAlpha], bx + mov [lBeta], cx + mov [lGamma], dx + + push esi ; save group en cours + + + movzx ebx, word ptr[esi+6] ; orggroupe deja * 38 + cmp bx, -1 + jnz pasgroupe0 + + mov esi, offset MatriceWorld + mov edi, offset MatriceTempo + mov ecx, 4 + rep movsd + movsw + + mov dword ptr[X0], ecx ; XYZ0 ChgRepere + mov [Z0], cx + + jmp short groupe0 + +pasgroupe0: + + + movzx eax, word ptr[esi+04] ; Org Point index deja *6 + lea edi, List_Anim_Point + eax ; di sur List_Anim_Point + Org + mov eax, dword ptr[edi] ; X0 et Y0 + mov dword ptr[X0], eax + mov ax, [edi+4] ; Z0 + mov [Z0], ax ; XYZ0 ChgRepere + + add ebx, 20 + mov esi, [ListGroupe] + add esi, ebx ; Matrice du groupe org + mov edi, offset MatriceTempo + mov ecx, 4 + rep movsd + movsw ; copy Mgroup org vers Mtempo + +groupe0: call RotMat ; rot de Mtempo vers Mrot + + pop edi ; + add edi, 20 ; Mgroup en cours + mov esi, offset MatriceRot + mov ecx, 4 + rep movsd ; copy de Mrot vers Mgroup + movsw + mov esi, edi + sub esi, 38 ; group en cours + + movzx eax, word ptr[esi+0] ; Start point deja *6 + movzx ecx, word ptr[esi+2] ; nb points + + mov esi, [OffsetDefPoint] + add esi, eax ; si sur Def_Point + Start + + lea edi, List_Anim_Point + eax ; di sur List_Point + Start + + call RotList + + ret + +RotateGroupe endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +TranslateGroupe proc near + + mov [lAlpha], bx ; attention ! + mov [lBeta], cx ; ici step de translation + mov [lGamma], dx + + mov edi, esi ; save group en cours + + movzx ebx, word ptr[esi+6] ; orggroupe deja * 38 + cmp bx, -1 + jnz pasgroupe0 + + add edi, 20 ; Mgroup en cours + mov esi, offset MatriceWorld + mov ecx, 4 + rep movsd + movsw + + mov dword ptr[X0], ecx + mov [Z0], cx ; ChgRepere + + jmp short groupe0 + +pasgroupe0: + + movzx ecx, word ptr[esi+4] ; Org Point index deja *6 + mov eax, dword ptr[List_Anim_Point + ecx ] ; X0 et Y0 + mov dword ptr[X0], eax + mov ax, word ptr[List_Anim_Point + ecx + 4 ]; Z0 + mov [Z0], ax ; ChgRepere + + mov esi, [ListGroupe] + add ebx, 20 + add esi, ebx ; Mgroup org + add edi, 20 ; Mgroup en cours + mov ecx, 4 + rep movsd ; copy de Mgroup org vers Mgroup + movsw + +groupe0: mov esi, edi + sub esi, 38 ; group en cours + + movzx eax, word ptr[esi+0] ; Start point deja *6 + mov dx, [esi+2] ; nb points + + mov edi, offset MatriceRot + add esi, 20 + mov ecx, 4 + rep movsd ; Mgroup vers Mrot + movsw + + mov esi, [OffsetDefPoint] + add esi, eax ; si sur List_Point + Start + + lea edi, List_Anim_Point + eax + + movzx ecx, dx + call TransRotList + + ret + +TranslateGroupe endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +ifdef Poubelle +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +ZoomGroupe proc near + +; bx zoomX cx zoomY dx zoomZ + + inc bh ; ZoomX + 256 + inc ch ; ZoomY + 256 + inc dh ; ZoomZ + 256 + mov bp, dx ; bp zoomZ + + mov di, [si+0] ; Start point deja *6 + mov dx, [si+2] ; nb points + + mov si, offset List_Anim_Point + add si, di ; si sur List_Point + Start + + push ds + + mov di, es + mov ds, di ; ds sur dgroup + EVEN +rg0: push dx ; beurk + + mov ax, [si] ; Delta X + imul bx + mov al, ah ; /256 + mov ah, dl + mov [si], ax + inc si + inc si + + mov ax, [si] ; Delta Y + imul cx + mov al, ah ; /256 + mov ah, dl + mov [si], ax + inc si + inc si + + mov ax, [si] ; Delta Z + imul bp + mov al, ah ; /256 + mov ah, dl + mov [si], ax + inc si + inc si + + pop dx + dec dx + jnz rg0 + + pop ds + ret + +ZoomGroupe endp + +endif + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛÛÜ Û Û ÛÜ ÜÛ ÛÛÜ Û Û Û ÛßßßÛ Ûßßßß Ûßßßß +; ÛÛßßÛ ÛÛßÛÛ ÛÛ ÛÛß Û ÛÛßÛÛ ÛÛ Û ÛÛßßÛ ÛÛ ßÛ ÛÛßß +; ßß ß ßß ß ßß ßß ß ßßßßß ßß ß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +AnimNuage proc near + + lodsw ; nb points + movsx eax, ax + mov [NbPoints], ax + + mov [OffsetDefPoint], esi + mov ecx, eax + shl ecx, 1 ; *2 + add ecx, eax ; *3 + shl ecx, 1 ; *6 + add esi, ecx ; esi saute defpoint + + lodsw ; Nb groupes anims + mov [NbGroupes], ax + movzx ecx, ax + + mov [ListGroupe], esi ; memo start list groupe + +;*--------------------------------------------------------------------------*/ +; rotations du groupe 0 + + mov bx, [lAlpha] ; SI sur groupe 0 + mov cx, [lBeta] ; init aux valeurs de rot locale + mov dx, [lGamma] + + push esi + call RotateGroupe + pop esi + add esi, 38 ; size d'un groupe + +;*--------------------------------------------------------------------------*/ +; rotations/translations/zooms des groupes + + movzx ecx, [NbGroupes] + dec ecx ; - groupe 0 + jcxz ag0f + +ag0: push ecx + push esi + + mov bx, [esi+10] ; Alpha ou stepX + mov cx, [esi+12] ; Beta ou stepY + mov dx, [esi+14] ; Gamma ou stepZ + + mov ax, [esi+8] ; type anim groupe + + cmp ax, TYPE_ROTATE + jz rotateg + cmp ax, TYPE_TRANSLATE + jz translateg + cmp ax, TYPE_ZOOM + jnz nolocalrot + +zoomg: ;call ZoomGroupe + jmp short nolocalrot + +translateg: call TranslateGroupe + jmp short nolocalrot + +rotateg: call RotateGroupe + +nolocalrot: pop esi + add esi, 38 ; size d'un groupe + pop ecx + dec ecx + jnz ag0 + +ag0f: +;*--------------------------------------------------------------------------*/ +; projette liste + + push esi + +project: movzx ecx, [NbPoints] + + mov esi, offset List_Anim_Point + mov edi, offset List_Point + +boucleproj: push ecx + + lodsw ; eax X rot + sub ax, [PosXWr] + movsx ecx, ax + + lodsw ; ebx Y rot + sub ax, [PosYWr] + movsx ebx, ax + + lodsw ; ecx Z rot + movsx eax, ax ; ou cwde ? + xchg eax, ecx + movsx ebp, [PosZWr] + sub ebp, ecx ; bp = Zrot tri + +;-------------------------------------------- +; cmp word ptr[TypeProj], PROJ_ISO +; jz projiso + +; iso js nopoint ; si Z0 < 0 clip +; cmp ax, cx ; si X0 > Z0 clip +; jg nopoint +; cmp bx, cx ; si Y0 > Z0 clip +; jg nopoint + +; neg cx +; cmp ax, cx +; jl nopoint +; cmp bx, cx +; jl nopoint +; neg cx + + +projiso: mov ecx, eax ; save x + + add eax, ebp ; x + zrot + + sal eax, 3 ; *8 + mov edx, eax + sal eax, 1 ; *16 + add eax, edx ; *24 + + mov edx, eax + sar edx, 16 ; + idiv word ptr[IsoScale] ; (x+zrot)/IsoScale + + add ax, [XCentre] + mov word ptr[edi], ax + add edi, 2 ; stock Xp + + cmp ax, [ScreenXmin] + jl sxmin +nosxmin: cmp ax, [ScreenXmax] + jg sxmax +nosxmax: + mov eax, ecx ; restore x + sub eax, ebp ; x - zrot + sub ebp, ecx ; Zrot - X pour bon tri + + sal eax, 2 ; *4 + mov edx, eax + sal eax, 1 ; *8 + add eax, edx ; *12 + + mov ecx, eax ; ecx = (x-zrot) * 12 + + sal ebx, 1 ; *2 + mov eax, ebx ; = 2 + sal eax, 4 ; *32 + sub eax, ebx + + sub eax, ecx ; - (x-zrot) * 12 + + mov edx, eax + sar edx, 16 + idiv word ptr[IsoScale] + + neg ax + add ax, [YCentre] + mov word ptr[edi], ax + add edi, 2 ; stock Yp + + cmp ax, [ScreenYmin] + jl symin +nosymin: cmp ax, [ScreenYmax] + jg symax +nosymax: + + mov ax, bp + mov word ptr[edi], ax + add edi, 2 ; stock Zrot pour tri + +;-------------------------------------------- + +pl0: pop ecx + dec ecx + jnz boucleproj + + pop esi + +;*--------------------------------------------------------------------------* + +finanim: mov eax, -1 + ret + +sxmin: mov [ScreenXmin], ax + jmp nosxmin +sxmax: mov [ScreenXmax],ax + jmp nosxmax +symin: mov [ScreenYmin], ax + jmp nosymin +symax: mov [ScreenYmax],ax + jmp nosymax + +nopoint: xor eax, eax + mov word ptr[edi], ax + mov word ptr[edi+2], ax + mov ax, -1 + mov word ptr[edi+6], ax + add edi, 8 + jmp pl0 + +AnimNuage endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛßßßÛ ßßÛßß ÛßßßÛ ßßÛßß Ûßßßß ÛÛÜ Û Û Û ÛßßßÛ Ûßßßß Ûßßßß +; ÛÛßÛß ÛÛ Û ÛÛ ÛÛßßÛ ÛÛ ÛÛßß ÛÛßÛÛ ÛÛ Û ÛÛßßÛ ÛÛ ßÛ ÛÛßß +; ßß ß ßßßßß ßß ßß ß ßß ßßßßß ßßßßß ßß ß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +RotateNuage proc near + + push esi + + call RotMatW ; Rotate MWorld vers Mrot + + pop esi + + ; rotationS nuage de points + + lodsw ; nbobj points + mov [NbPoints], ax + movzx ecx, ax + + mov edi,offset List_Point + +bouclerot: push ecx + push edi + + ; rotation totale de l'objet + + lodsw + mov cx, ax ; AX X reel + lodsw + mov bx, ax ; BX Y reel + lodsw + xchg ax, cx ; CX Z reel + + call Rot ; voir pour Coor rot‚es + ; en LONG * 2^15 + pop edi + + ; change repere (pos camera reelle & pos objet reelle) + + mov ax, [X0] + sub ax, [PosXWr] + + mov bx, [Y0] + sub bx, [PosYWr] + + mov cx, [PosZWr] + sub cx, [Z0] + mov bp, cx + + js nopoint ; si Z0 < 0 clip + cmp ax, cx ; si X0 > Z0 clip + jg nopoint + cmp bx, cx ; si Y0 > Z0 clip + jg nopoint + neg cx + cmp ax, cx + jl nopoint + cmp bx, cx + jl nopoint + neg cx + + ; projection point + + call Proj + + mov word ptr[edi], ax ; stock Xp + + cmp ax,[ScreenXmin] + jge nosxmin + mov [ScreenXmin],ax +nosxmin: cmp ax,[ScreenXmax] + jle nosxmax + mov [ScreenXmax],ax +nosxmax: + mov ax,bx + mov word ptr[edi+2], ax ; stock Yp + + cmp ax,[ScreenYmin] + jge nosymin + mov [ScreenYmin],ax +nosymin: cmp ax,[ScreenYmax] + jle nosymax + mov [ScreenYmax],ax +nosymax: + mov ax,cx + mov word ptr[edi+4], ax ; stock Zrot + add edi, 6 + +rn0: pop ecx + dec ecx + jnz bouclerot + + ret + +nopoint: xor ax, ax + mov word ptr[edi], ax + mov word ptr[edi+2], ax + mov ax, -1 + mov word ptr[edi+4], ax + add edi, 6 + jmp rn0 + +RotateNuage endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÛÜ Û ÛßßßÛ ÛßßßÛ ÛÜ ÜÛ ÛßßßÛ Û ÛÛßßß +; ÛÛßÛÛ ÛÛ Û ÛÛßÛß ÛÛß Û ÛÛßßÛ ÛÛ ßßßßÛ +; ßß ß ßßßßß ßß ß ßß ß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +ComputeStaticNormal proc near + + lodsw ; nbobj normal faces/points + mov cx, ax + jcxz nonp + + mov edi, offset List_Normal + +bouclerot: push ecx + push edi + + lodsw + mov dx, ax ; AX X + lodsw + mov bx, ax ; BX Y + lodsw + mov cx, ax ; CX Z + lodsw + xchg dx, ax ; DX prenormalized range + + call Rot ; DX inchang‚ + + pop edi + + mov bp, dx + + mov ax, [X0] + + imul word ptr[NormalXLight] + mov cx, ax + mov bx, dx + + mov ax, [Y0] + imul word ptr[NormalYLight] + add cx, ax + adc bx, dx + + mov ax, [Z0] + imul word ptr[NormalZLight] + add cx, ax + adc bx, dx + + mov ax, cx + mov dx, bx ; intensity + + or dx,dx + js nointensity ; saut si negatif + + idiv bp + mov word ptr[edi], ax + add edi, 2 ; stock intensity + + pop ecx + dec ecx + jnz bouclerot + +nonp: ret + +nointensity: xor ax, ax + mov word ptr[edi], ax + add edi, 2 + pop ecx + dec ecx + jnz bouclerot + + ret + +ComputeStaticNormal endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +nextgroup2: pop ebx + add ebx, 38 + pop ecx + dec ecx + jnz bouclegroup + jmp nonp + +ComputeAnimNormal proc near + + lodsw ; nbobj normal faces/points + or ax, ax + jz nonp + + mov edi,offset List_Normal + + movzx ecx, [NbGroupes] + + mov ebx, [ListGroupe] + add ebx, 18 ; sur NbNormal + +bouclegroup: push ecx + push ebx + + mov cx, [ebx] + jcxz nextgroup2 + + ; copy Mgroup vers Mrot + + mov edx, esi + mov ebp, edi + mov esi, ebx + inc esi + inc esi ; sur Mgroup + + mov edi, offset MatriceRot + mov ecx, 4 + rep movsd + movsw + mov edi, ebp + mov esi, edx + + movzx ecx, word ptr[ebx] + +; cmp [FlagLight], 0 +; jz nolight1 + +; call RotListNormal + +;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + mov [compteur], cx + +bouclerot: ;push ecx + push edi + + movsx ebp, word ptr[esi+0] + movsx ebx, word ptr[esi+2] + movsx ecx, word ptr[esi+4] + add esi, 6 + + movsx eax, word ptr[ Mat00 ] + imul eax, ebp + mov edx, eax + movsx eax, word ptr[ Mat01 ] + imul eax, ebx + add edx, eax + movsx eax, word ptr[ Mat02 ] + imul eax, ecx + add eax, edx + sar eax, 15 + + movsx edx, word ptr[NormalXLight] + imul eax, edx + mov edi, eax + + movsx eax, word ptr[ Mat10 ] + imul eax, ebp + mov edx, eax + movsx eax, word ptr[ Mat11 ] + imul eax, ebx + add edx, eax + movsx eax, word ptr[ Mat12 ] + imul eax, ecx + add eax, edx + sar eax, 15 + + movsx edx, word ptr[NormalYLight] + imul eax, edx + add edi, eax + + movsx eax, word ptr[ Mat20 ] + imul eax, ebp + mov edx, eax + movsx eax, word ptr[ Mat21 ] + imul eax, ebx + add edx, eax + movsx eax, word ptr[ Mat22 ] + imul eax, ecx + add eax, edx + sar eax, 15 + + movsx edx, word ptr[NormalZLight] + imul eax, edx + add edi, eax + + or edi, edi + js nointensity ; saut si negatif + + lodsw ; prenormalized range + xchg di, ax + cwd + idiv di + + pop edi + mov word ptr[edi], ax + add edi, 2 ; stock intensity + +; pop ecx +; dec ecx + dec word ptr[compteur] + jnz bouclerot + + jmp nextgroup + +nointensity: lodsw + xor ax, ax + pop edi + mov word ptr[edi], ax + add edi, 2 + +; pop ecx +; dec ecx + dec word ptr[compteur] + jnz bouclerot + +;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +nextgroup: pop ebx + add ebx, 38 + + pop ecx + dec ecx + jnz bouclegroup +; dec ecx + jnz bouclegroup + +nonp: ret + +nolight1: mov ebx, ecx + xor ax, ax + rep stosw + shl ebx, 3 + add esi, ebx + jmp short nextgroup + +ComputeAnimNormal endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + + END diff --git a/LIB386/LIB_3D/P_OBJ_3D.ASM b/LIB386/LIB_3D/P_OBJ_3D.ASM new file mode 100644 index 0000000..c5418e5 --- /dev/null +++ b/LIB386/LIB_3D/P_OBJ_3D.ASM @@ -0,0 +1,1712 @@ + .386p + + .model SMALL, C + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÜ ÜÛ ÛßßßÛ ÛßßÛ Û Ûßßßß ßßÛßß +; ÛÛß Û ÛÛ Û ÛÛßßÛ ÜÜ Û ÛÛßß ÛÛ +; ßß ß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + + include p_define.ash + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + .data +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + + ; extern M_TRIGO + + extrn NoLanguage CameraXr:WORD + extrn NoLanguage CameraYr:WORD + extrn NoLanguage CameraZr:WORD + extrn NoLanguage X0:WORD + extrn NoLanguage Y0:WORD + extrn NoLanguage Z0:WORD + extrn NoLanguage XCentre:WORD + extrn NoLanguage YCentre:WORD + + extrn NoLanguage lAlpha:WORD + extrn NoLanguage lBeta:WORD + extrn NoLanguage lGamma:WORD + + extrn NoLanguage NormalXLight:WORD + extrn NoLanguage NormalYLight:WORD + extrn NoLanguage NormalZLight:WORD + + extrn NoLanguage MatriceTempo:WORD + extrn NoLanguage MatriceWorld:WORD + extrn NoLanguage MatriceRot:WORD + + extrn NoLanguage IsoScale:WORD + extrn NoLanguage TypeProj:WORD + + + extrn NoLanguage Mat00:WORD + extrn NoLanguage Mat01:WORD + extrn NoLanguage Mat02:WORD + extrn NoLanguage Mat10:WORD + extrn NoLanguage Mat11:WORD + extrn NoLanguage Mat12:WORD + extrn NoLanguage Mat20:WORD + extrn NoLanguage Mat21:WORD + extrn NoLanguage Mat22:WORD + + extrn NoLanguage compteur:WORD + + ; extern LIB_GRAF + + extrn NoLanguage NbPolyPoints:WORD + extrn NoLanguage TabPoly:WORD + extrn NoLanguage TypePoly:WORD + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + extrn NoLanguage FlagLight:WORD + + extrn NoLanguage List_Point:WORD + extrn NoLanguage NbPoints:WORD + + extrn NoLanguage List_Anim_Point:WORd + extrn NoLanguage List_Entity:WORD + extrn NoLanguage List_Tri:WORD + + extrn NoLanguage ScreenXmin:WORD + extrn NoLanguage ScreenYmin:WORD + extrn NoLanguage ScreenXmax:WORD + extrn NoLanguage ScreenYmax:WORD + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +List_Point dw (500*3) dup(00) ; Xp Yp Zrot + +List_Normal dw 500 dup(00) ; surement plus + +List_Anim_Point dw (500*3) dup(00) ; Xr Yr Zr + +List_Entity dw 5000 dup(00) ; TAILLE … determin‚e + +List_Tri dw (500*8) dup(00) ; entites + +PosXWr dw 00 ; pos World rot‚e de l'objet … afficher +PosYWr dw 00 +PosZWr dw 00 + +ScreenXmin dw 00 +ScreenYmin dw 00 +ScreenXmax dw 00 +ScreenYmax dw 00 + +NbPoints dw 00 +TotalEntite dw 00 + +PointeurListTri dd 00 +StartDI dd 00 +NextDI dd 00 + +ZMax dw 00 + +NbGroupes dw 00 +ListGroupe dd 00 + +Infos dw 00 +StartInfos dd 00 +OffsetDefPoint dd 00 +OffsetListNormal dd 00 + +FlagLight dw 01 + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +TabJump_2 dd aff_E_LIGNE + dd aff_E_POLY + dd aff_E_SPHERE + +; dd aff_E_POINT + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + .code +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + + + public NoLanguage AffObjet + + + extrn NoLanguage ComputePoly:PROC + extrn NoLanguage ComputeSphere_A:PROC + extrn NoLanguage FillVertic_A:PROC + extrn NoLanguage Line_A:PROC + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + + extrn NoLanguage RotMatW:near + extrn NoLanguage RotMat:near + extrn NoLanguage WorldRot:near + extrn NoLanguage Rot:near + extrn NoLanguage Proj:near + extrn NoLanguage RotList:near + extrn NoLanguage TransRotList:near + extrn NoLanguage RotListNormal:near + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ Ûßßßß Ûßßßß ÛßßßÛ ÛßßÛ Û Ûßßßß ßßÛßß +; ÛÛßßÛ ÛÛßß ÛÛßß ÛÛ Û ÛÛßßÛ ÜÜ Û ÛÛßß ÛÛ +; ßß ß ßß ßß ßßßßß ßßßßß ßßßßß ßßßßß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + + +AffObjet proc uses esi edi ebx ebp,\ + xwr:DWORD, ywr:DWORD, zwr:DWORD,\ + palpha:DWORD, pbeta:DWORD, pgamma:DWORD,\ + ptrobj:DWORD + + mov eax, palpha + mov [lAlpha], ax + mov eax, pbeta + mov [lBeta], ax + mov eax, pgamma + mov [lGamma], ax + + mov ax, 32767 + mov [ScreenXmin], ax + mov [ScreenYmin], ax + neg ax + mov [ScreenXmax], ax + mov [ScreenYmax], ax + +;*-------------------------------------------------------------------------- +;* rotation world org obj + + mov eax, xwr ; X World rot + mov ebx, ywr ; Y World + mov ecx, zwr ; Z World + + push ebp + call WorldRot + pop ebp + + mov ax, [CameraXr] + sub ax, [X0] + mov [PosXWr], ax + + mov ax, [CameraYr] + sub ax, [Y0] + mov [PosYWr], ax + + mov ax, [CameraZr] + sub ax, [Z0] +; iso or ax, ax +; jle finafobjshort ; objet Z <= 0 + mov [PosZWr], ax + +;*-------------------------------------------------------------------------- +;* recup infos + + mov [TotalEntite], 0 + mov [PointeurListTri], offset List_Tri + + mov esi, ptrobj + + lodsw ; infos + mov bx, ax + mov [Infos], ax + + add esi, 12 ; saute ZV + + lodsw ; nb bytes to skip + movzx eax, ax + add esi, eax ; saute zone info + +;*--------------------------------------------------------------------------* +;* rotation nuage/normal face/normal point + + test bx, INFO_ANIM + jz normalrotate + + call AnimNuage ; Objet Anim‚ + call ComputeAnimNormal + jmp short finnuage + +normalrotate: call RotateNuage ; Objet Normal + call ComputeStaticNormal + jmp short finnuage + +finafobjshort: jmp badfinafobj_2 + +finnuage: + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛßßßÛ Û Û Üß Ûßßßß ÛßßßÛ ÛÛÜ Û Ûßßßß ÛÛßßß +; ÛÛßßß ÛÛ Û ÛÛ ÛÛß ÛÛ ßÛ ÛÛ Û ÛÛßÛÛ ÛÛßß ßßßßÛ +; ßß ßßßßß ßßßßß ßß ßßßßß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + + mov edi, offset List_Entity + + lodsw ; nb polys + movzx ecx, ax + jecxz short_lignes + +b_poly: push ecx + + mov [StartDI], edi ; memo pointeur List_Coor + + lodsb ; matiere poly + + cmp al, 9 ; >= MAT_GOURAUD + jae polygouraud + + cmp al, 7 ; >= MAT_FLAT + jae polyflat + +;----------------------------------------------------------------------------- +; MAT_TRISTE->MAT_TRAME + + stosb ; stock type + + lodsb ; nb point poly + stosb ; stock nbp + xor ah, ah + mov cx, ax + + movsw ; stock coul1/coul2 + + mov bp, 32000 ; ZMax + + push edi ; memo start poly somm + + EVEN +p0: lodsw ; index point sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + xchg ebx, esi + lodsw + mov word ptr[edi+2], ax ; Xscr + + lodsw + mov word ptr[edi+4], ax ; Yscr dans List_Coor + add edi, 6 + + lodsw ; Zrot +; iso or ax, ax +; js skippoly ; <0 ? + + cmp ax, bp ; ZMin + jge nozmax + mov bp, ax +nozmax: + mov esi, ebx + loop p0 + + jmp testpoly + +short_lignes: jmp lignes + +;----------------------------------------------------------------------------- +; MAT_GOURAUD + + +polygouraud: ;cmp [FlagLight], 0 + ;jz nolight2 + + dec al + dec al ; attention voir reanim + stosb ; stock type translated + + lodsb ; nb point poly + stosb ; stock nbp + xor ah, ah + movzx ecx, ax + + lodsw + stosw ; stock coul1/coul2 + mov dx, ax + + mov bp, -32000 ; ZMax + + push edi ; memo start poly somm + + EVEN +p0g: + lodsw ; normal point + movzx eax, ax + mov ax, word ptr[List_Normal + eax * 2] + add al, dl + mov word ptr[edi+0], ax ; stock intensity point + + lodsw ; index point sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + xchg ebx, esi + lodsw + mov word ptr[edi+2], ax ; Xscr + lodsw + mov word ptr[edi+4], ax ; Yscr dans List_Coor + add edi, 6 + + lodsw ; Zrot + + ; voir pour "depthcueing" vers sombre + +; iso or ax, ax +; js skippolyg + + cmp ax, bp ; ZMin + jle nozmaxg + mov bp, ax +nozmaxg: + mov esi, ebx + loop p0g + + jmp testpoly + +;----------------------------------------------------------------------------- +; gouraud --> MAT_TRISTE->MAT_TRAME + + +nolight2: xor al,al + stosb ; stock type + + lodsb ; nb point poly + stosb ; stock nbp + xor ah, ah + mov cx, ax + + movsw ; stock coul1/coul2 + + mov bp, 32000 ; ZMax + + push edi ; memo start poly somm + + EVEN +p0l: lodsw ; oublie normal + + lodsw ; index point sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + xchg ebx, esi + lodsw + mov word ptr[edi+2], ax ; Xscr + + lodsw + mov word ptr[edi+4], ax ; Yscr dans List_Coor + add edi, 6 + + lodsw ; Zrot +; iso or ax, ax +; js skippoly ; <0 ? + + cmp ax, bp ; ZMin + jge nozmaxl + mov bp, ax +nozmaxl: + mov esi, ebx + loop p0l + + jmp testpoly + +;----------------------------------------------------------------------------- +; MAT_FLAT +polyflat: sub al, 7 + stosb ; stock mat translat‚ + + lodsb ; nb point poly + stosb ; stock nbp + xor ah, ah + movzx ecx, ax + + lodsw + mov bp, ax ; coul1/coul2 + + ; 1st coul = normal face + lodsw + movzx eax, ax + add bp, word ptr[ List_Normal + eax*2 ] + mov ax, bp + stosw ; stock coul + intensity + + push edi ; memo start poly somm + + mov bp, -32000 ; ZMax + + EVEN +p0f: lodsw ; index point sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + xchg ebx, esi + lodsw + mov word ptr[edi+2], ax ; Xscr + + lodsw + mov word ptr[edi+4], ax ; Yscr dans List_Coor + add edi, 6 + + lodsw ; Zrot +; iso or ax, ax +; js skippoly + + cmp ax, bp ; ZMin + jle nozmaxf + mov bp, ax +nozmaxf: + mov esi, ebx + loop p0f + + jmp testpoly + +skippoly: mov esi, ebx + dec ecx + shl ecx, 1 + add esi, ecx ; skip points restant + pop edi + jmp badpoly + +skippolyg: mov esi, ebx + dec ecx + shl ecx, 2 + add esi, ecx ; skip points restant + pop edi + jmp short badpoly + +;----------------------------------------------------------------------------- +testpoly: mov [NextDI], edi ; memo pointeur List_Coor + + pop edi ; pointeur list sommets + + mov [ZMax], bp + + mov bx, [edi+8] + sub bx, [edi+2] + mov ax, [edi+4] + sub ax, [edi+16] + imul bx + mov bp,ax + mov bx,dx + mov cx, [edi+10] + sub cx, [edi+4] + mov ax, [edi+2] + sub ax, [edi+14] + imul cx + + sub ax, bp ; oublie face si bx:bp < dx:ax + sbb dx, bx + jnl badpoly + +okpoly: + inc [TotalEntite] + mov edi, [PointeurListTri] + mov ax, [ZMax] + stosw + mov ax, E_POLY + stosw + mov eax, [StartDI] + stosd + mov [PointeurListTri], edi + +;----------------------------------------------------------------------------- + + mov edi, [NextDI] +nextpoly: pop ecx + dec ecx + jz lignes + jmp b_poly + +badpoly: mov edi, [StartDI] + jmp nextpoly + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Û Û Ûßßßß ÛÛÜ Û Ûßßßß ÛÛßßß +; ÛÛ ÛÛ ÛÛ ßÛ ÛÛßÛÛ ÛÛßß ßßßßÛ +; ßßßßß ßß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +lignes: lodsw ; nb lignes + movzx ecx, ax + jecxz spheres + +b_line: mov [StartDI], edi ; memo pointeur List_Coor + + movsd ; stock matiere/coul + ; coul2 / even + + lodsw ; index point 1 sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + mov eax, [ebx+00] + stosd ; X1scr vers List_Coor + ; Y1scr + mov dx, [ebx+04] ; Zrot ZMin/Max + + lodsw ; index point 2 sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + mov eax, [ebx+00] + stosd ; X2scr vers List_Coor + ; Y2scr + mov bp, [ebx+04] ; Zrot ZMin/Max + + mov [NextDI], edi + + cmp dx, bp ; ZMin ZMax + jl zok0 + xchg dx, bp ; DX < BP +zok0: +; iso or dx, dx ; ZMin +; jle badline + +okline: inc [TotalEntite] + mov edi, [PointeurListTri] + mov ax, bp + stosw + mov ax, E_LIGNE + stosw + mov eax, [StartDI] + stosd + mov [PointeurListTri], edi + + mov edi, [NextDI] + loop b_line + jmp short spheres + +badline: mov edi, [StartDI] + loope b_line + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÛßßß ÛßßßÛ Û Û Ûßßßß ÛßßßÛ Ûßßßß ÛÛßßß +; ßßßßÛ ÛÛßßß ÛÛßßÛ ÛÛßß ÛÛßÛß ÛÛßß ßßßßÛ +; ßßßßß ßß ßß ß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +spheres: lodsw ; nb spheres + movzx ecx, ax + jecxz tri + +b_sphere: mov [StartDI], edi ; memo pointeur List_Coor + movsd ; stock matiere/coul + ; coul2 / even + movsw ; rayon + lodsw ; index point 1 sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + mov eax, [ebx+00] ; X1scr vers List_Coor + stosd ; Y1scr + mov ax, [ebx+04] ; Zrot ZMin/Max + stosw + + mov [NextDI], edi + +; iso or ax, ax ; ZMin +; jle badsphere + +oksphere: inc [TotalEntite] + mov edi, [PointeurListTri] + stosw + mov ax, E_SPHERE + stosw + mov eax, [StartDI] + stosd + mov [PointeurListTri], edi + + mov edi, [NextDI] + loop b_sphere + jmp short tri + +badsphere: mov edi, [StartDI] + loop b_sphere + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ßßÛßß ÛßßßÛ Û Ûßßßß ÛÛÜ Û ßßÛßß Û ßßÛßß Û Üß +; ÛÛ ÛÛßÛß ÛÛ ÛÛßß ÛÛßÛÛ ÛÛ ÛÛ ÛÛ ÛÛß +; ßß ßß ß ßß ßßßßß ßßßßß ßß ß ßß ßß ßß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; tri les faces dans la table Listtri (ordre Z et offset sur list coors +; premachees. + +tri: movzx ecx, word ptr[TotalEntite] + dec ecx + jz fintri + + mov esi, offset List_Tri + lea ebp, List_Tri + ecx*8 + +SergeSort:: ; esi bas + ; ebp haut + ; ecx nbr d'elements + + ; ax pivot + ; edi pospivot + ; ebx h + + push 0 ; flag de fin de pile ! + + jmp nocalccx + +plusgrand: mov ebx, edi + mov eax, [edi] + jmp short cont + +permut: ; ecx nb entite - 1 + ; esi start list sizeof 8 byte + +tt0: mov ebp, ecx + mov eax, [esi] ; lit Z + + mov edi, esi + add edi, 8 + xor ebx, ebx + +tt1: cmp [edi], ax + jg plusgrand +cont: add edi, 8 + loop tt1 + + or ebx, ebx + jz short noexchg + + xchg [esi], eax ; permutte + mov [ebx], eax + mov eax, [esi+04] + xchg [ebx+04], eax + mov [esi+04], eax + +noexchg: add esi, 8 + mov ecx, ebp + loop tt0 + + pop ebp + or ebp, ebp + jnz short dopop + jmp fintri + +permut2: mov eax, [esi] + mov ebx, [ebp] + + cmp ax, bx + jge short skipswap + + mov [esi], ebx + mov [ebp], eax + mov eax, [esi+04] + xchg [ebp+04], eax + mov [esi+04], eax +skipswap: + pop ebp + or ebp, ebp + jz short fintri + +dopop: pop esi +nopop: + mov ecx, ebp + sub ecx, esi + shr ecx, 3 +nocalccx: + cmp ecx, 1 ; select permut2 ? + je short permut2 + + cmp ecx, 7 ; select permut ou qsort + jbe short permut + + mov edi, esi ; pospivot = bas + + mov eax, [edi] ; pivot = [pospivot] = [bas] + + add esi, 8 ; bas++ + + mov ebx, ebp ; h = haut + +w1: cmp word ptr[esi], ax + jl short w2 + add esi, 8 ; si [bas] >= pivot + loop w1 + + jmp short w4 + +w2: cmp word ptr[ebx], ax + jg short w3 + sub ebx, 8 ; si [h] <= pivot + loop w2 + + jmp short w4 + +w3: mov edx, [esi] ; xchg [bas],[h] + xchg edx, [ebx] + mov [esi], edx + mov edx, [esi+4] + xchg edx, [ebx+4] + mov [esi+4], edx + + jmp short w1 +w4: + xchg esi, ebx ; idem que esi-=8 et ebx+=8 + + xchg [esi], eax ; xchg [pospivot],[bas] + mov [edi], eax + mov edx, [edi+4] + xchg edx, [esi+4] + mov [edi+4], edx + + cmp ebx, ebp + jae short nopush + + push ebx ; h + push ebp ; haut +nopush: + sub esi, 8 + cmp edi, esi + jae short norecur + + mov ebp, esi + mov esi, edi + jmp nopop +norecur: + pop ebp + or ebp, ebp + jnz dopop +fintri: + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÜ Û ÛÛßßß ÛßßßÛ Û ÛßßßÛ Û Üß +; ÛÛ Û ÛÛ ßßßßÛ ÛÛßßß ÛÛ ÛÛßßÛ ÛÛß +; ßßßß ßß ßßßßß ßß ßßßßß ßß ß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; affichage des entit‚s + + mov esi,offset List_Tri + + movzx ecx, [TotalEntite] + jcxz badfinafobj_1 + +ade0: push ecx + inc esi + inc esi ; saute Z max + + lodsw ; type entit‚ + movzx ebx, ax + lodsd ; offset List_Coor + push esi + mov esi, eax + + jmp [ TabJump_2 + ebx*4 ] ; jmp … aff de l'entit‚ + +nextaff: pop esi + pop ecx + loop ade0 + +goodfinobj: xor eax, eax ; OK affich‚ au moins 1 entit‚ + ret + +;*--------------------------------------------------------------------------*/ + +badfinafobj_1: ; 1 si pas d'entite to aff + mov ax,-1 + mov [ScreenXmax], ax + mov [ScreenYmax], ax + mov [ScreenXmin], ax + mov [ScreenYmin], ax + mov eax, 1 + ret + +badfinafobj_2: mov ax, -1 + mov [ScreenXmax], ax + mov [ScreenYmax], ax + mov [ScreenXmin], ax + mov [ScreenYmin], ax + + mov eax, 2 ; 2 si objet clipp‚ en Z <= 0 + ret + +AffObjet endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Ûßßßß ÛÛÜ Û ßßÛßß Û ßßÛßß Û Üß +; ÛÛßß ÛÛßÛÛ ÛÛ ÛÛ ÛÛ ÛÛß +; ßßßßß ßß ß ßß ßß ßß ßß +; +; ÛßßßÜ Û ÛÛßßß ÛßßßÛ Û ÛßßßÛ Û Üß +; ÛÛ Û ÛÛ ßßßßÛ ÛÛßßß ÛÛ ÛÛßßÛ ÛÛß +; ßßßß ßß ßßßßß ßß ßßßßß ßß ß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +aff_E_POLY:: + lodsb ; type (ATTENTION GOURAUD) + xor ah, ah + mov bx, ax + mov [TypePoly], ax + + lodsb ; nb points + movzx ecx, ax + mov [NbPolyPoints], ax + + lodsw ; coul1/coul2 + mov dx, ax + + mov edi, ecx + shl ecx, 1 + add ecx, edi ; *3 word + mov edi, offset TabPoly + rep movsw ; … changer + + mov si, bx ; type + mov di, dx ; coul + + call ComputePoly + or ax, ax + jz no_poly + + mov cx, si ; type + call FillVertic_A + +no_poly: jmp nextaff + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +aff_E_LIGNE:: + lodsw + xchg al, ah + mov bp, ax + inc esi + inc esi + + lodsw ; x0 + movsx edx, ax + lodsw ; y0 + movsx ebx, ax + lodsw ; x1 + movsx ecx, ax + lodsw ; y1 + movsx eax, ax + xchg eax, edx + + call Line_A + + jmp nextaff + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +aff_E_SPHERE:: + xor eax, eax + lodsb ; type + push eax ; mov [TypePoly], ax + + lodsw ; coul1/coul2 + push eax + + inc esi ; even + + lodsw ; rayon + movzx ebp, ax + lodsw ; x + movzx ecx, ax + lodsw ; y + movzx edi, ax + lodsw ; Zr + +; iso xchg eax, ebp +; imul word ptr[LFactorX] +; add bp, [KFactor] +; idiv bp +; movzx ebp, ax pfeu + + mov ax, 34 ; racine sxý+syý + imul bp + idiv word ptr[IsoScale] + movzx ebp, ax + + ; ecx x + ; edi y -> esi pour computesphere + ; ebp rayon sur ecran + + ; reajuste coordonn‚e box + + mov ax, cx ; x + rayon + add ax, bp + cmp ax, [ScreenXmax] + jle nosxa + mov [ScreenXmax], ax +nosxa: mov ax, cx ; x - rayon + sub ax, bp + cmp ax, [ScreenXmin] + jge nosxi + mov [ScreenXmin], ax +nosxi: mov ax, di + add ax, bp ; y + rayon + cmp ax, [ScreenYmax] + jle nosya + mov [ScreenYmax], ax +nosya: mov ax, di ; y - rayon + sub ax, bp + cmp ax, [ScreenYmin] + jge nosyi + mov [ScreenYmin], ax +nosyi: + + mov esi, edi + call ComputeSphere_A + + pop edi ; coul + pop ecx ; type + + or eax, eax + jz no_sphere + + call FillVertic_A + +no_sphere: jmp nextaff + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; sous programmes +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛÛÜ Û Û ÛÜ ÜÛ ÛßßßÛ ÛßßßÛ ßßÛßß +; ÛÛßßÛ ÛÛßÛÛ ÛÛ ÛÛß Û ÛÛßÛß ÛÛ Û ÛÛ +; ßß ß ßß ß ßß ßß ß ßßßßß ßß ß ßßßßß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +RotateGroupe proc near + + mov [lAlpha], bx + mov [lBeta], cx + mov [lGamma], dx + + push esi ; save group en cours + + + movzx ebx, word ptr[esi+6] ; orggroupe deja * 38 + cmp bx, -1 + jnz pasgroupe0 + + mov esi, offset MatriceWorld + mov edi, offset MatriceTempo + mov ecx, 4 + rep movsd + movsw + + mov dword ptr[X0], ecx ; XYZ0 ChgRepere + mov [Z0], cx + + jmp short groupe0 + +pasgroupe0: + + + movzx eax, word ptr[esi+04] ; Org Point index deja *6 + lea edi, List_Anim_Point + eax ; di sur List_Anim_Point + Org + mov eax, dword ptr[edi] ; X0 et Y0 + mov dword ptr[X0], eax + mov ax, [edi+4] ; Z0 + mov [Z0], ax ; XYZ0 ChgRepere + + add ebx, 20 + mov esi, [ListGroupe] + add esi, ebx ; Matrice du groupe org + mov edi, offset MatriceTempo + mov ecx, 4 + rep movsd + movsw ; copy Mgroup org vers Mtempo + +groupe0: call RotMat ; rot de Mtempo vers Mrot + + pop edi ; + add edi, 20 ; Mgroup en cours + mov esi, offset MatriceRot + mov ecx, 4 + rep movsd ; copy de Mrot vers Mgroup + movsw + mov esi, edi + sub esi, 38 ; group en cours + + movzx eax, word ptr[esi+0] ; Start point deja *6 + movzx ecx, word ptr[esi+2] ; nb points + + mov esi, [OffsetDefPoint] + add esi, eax ; si sur Def_Point + Start + + lea edi, List_Anim_Point + eax ; di sur List_Point + Start + + call RotList + + ret + +RotateGroupe endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +TranslateGroupe proc near + + mov [lAlpha], bx ; attention ! + mov [lBeta], cx ; ici step de translation + mov [lGamma], dx + + mov edi, esi ; save group en cours + + movzx ebx, word ptr[esi+6] ; orggroupe deja * 38 + cmp bx, -1 + jnz pasgroupe0 + + add edi, 20 ; Mgroup en cours + mov esi, offset MatriceWorld + mov ecx, 4 + rep movsd + movsw + + mov dword ptr[X0], ecx + mov [Z0], cx ; ChgRepere + + jmp short groupe0 + +pasgroupe0: + + movzx ecx, word ptr[esi+4] ; Org Point index deja *6 + mov eax, dword ptr[List_Anim_Point + ecx ] ; X0 et Y0 + mov dword ptr[X0], eax + mov ax, word ptr[List_Anim_Point + ecx + 4 ]; Z0 + mov [Z0], ax ; ChgRepere + + mov esi, [ListGroupe] + add ebx, 20 + add esi, ebx ; Mgroup org + add edi, 20 ; Mgroup en cours + mov ecx, 4 + rep movsd ; copy de Mgroup org vers Mgroup + movsw + +groupe0: mov esi, edi + sub esi, 38 ; group en cours + + movzx eax, word ptr[esi+0] ; Start point deja *6 + mov dx, [esi+2] ; nb points + + mov edi, offset MatriceRot + add esi, 20 + mov ecx, 4 + rep movsd ; Mgroup vers Mrot + movsw + + mov esi, [OffsetDefPoint] + add esi, eax ; si sur List_Point + Start + + lea edi, List_Anim_Point + eax + + movzx ecx, dx + call TransRotList + + ret + +TranslateGroupe endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +ifdef Poubelle +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +ZoomGroupe proc near + +; bx zoomX cx zoomY dx zoomZ + + inc bh ; ZoomX + 256 + inc ch ; ZoomY + 256 + inc dh ; ZoomZ + 256 + mov bp, dx ; bp zoomZ + + mov di, [si+0] ; Start point deja *6 + mov dx, [si+2] ; nb points + + mov si, offset List_Anim_Point + add si, di ; si sur List_Point + Start + + push ds + + mov di, es + mov ds, di ; ds sur dgroup + EVEN +rg0: push dx ; beurk + + mov ax, [si] ; Delta X + imul bx + mov al, ah ; /256 + mov ah, dl + mov [si], ax + inc si + inc si + + mov ax, [si] ; Delta Y + imul cx + mov al, ah ; /256 + mov ah, dl + mov [si], ax + inc si + inc si + + mov ax, [si] ; Delta Z + imul bp + mov al, ah ; /256 + mov ah, dl + mov [si], ax + inc si + inc si + + pop dx + dec dx + jnz rg0 + + pop ds + ret + +ZoomGroupe endp + +endif + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛÛÜ Û Û ÛÜ ÜÛ ÛÛÜ Û Û Û ÛßßßÛ Ûßßßß Ûßßßß +; ÛÛßßÛ ÛÛßÛÛ ÛÛ ÛÛß Û ÛÛßÛÛ ÛÛ Û ÛÛßßÛ ÛÛ ßÛ ÛÛßß +; ßß ß ßß ß ßß ßß ß ßßßßß ßß ß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +AnimNuage proc near + + lodsw ; nb points + movsx eax, ax + mov [NbPoints], ax + + mov [OffsetDefPoint], esi + mov ecx, eax + shl ecx, 1 ; *2 + add ecx, eax ; *3 + shl ecx, 1 ; *6 + add esi, ecx ; esi saute defpoint + + lodsw ; Nb groupes anims + mov [NbGroupes], ax + movzx ecx, ax + + mov [ListGroupe], esi ; memo start list groupe + +;*--------------------------------------------------------------------------*/ +; rotations du groupe 0 + + mov bx, [lAlpha] ; SI sur groupe 0 + mov cx, [lBeta] ; init aux valeurs de rot locale + mov dx, [lGamma] + + push esi + call RotateGroupe + pop esi + add esi, 38 ; size d'un groupe + +;*--------------------------------------------------------------------------*/ +; rotations/translations/zooms des groupes + + movzx ecx, [NbGroupes] + dec ecx ; - groupe 0 + jcxz ag0f + +ag0: push ecx + push esi + + mov bx, [esi+10] ; Alpha ou stepX + mov cx, [esi+12] ; Beta ou stepY + mov dx, [esi+14] ; Gamma ou stepZ + + mov ax, [esi+8] ; type anim groupe + + cmp ax, TYPE_ROTATE + jz rotateg + cmp ax, TYPE_TRANSLATE + jz translateg + cmp ax, TYPE_ZOOM + jnz nolocalrot + +zoomg: ;call ZoomGroupe + jmp short nolocalrot + +translateg: call TranslateGroupe + jmp short nolocalrot + +rotateg: call RotateGroupe + +nolocalrot: pop esi + add esi, 38 ; size d'un groupe + pop ecx + loop ag0 + +ag0f: +;*--------------------------------------------------------------------------*/ +; projette liste + + push esi + +project: movzx ecx, [NbPoints] + + mov esi, offset List_Anim_Point + mov edi, offset List_Point + +boucleproj: push ecx + + lodsw ; eax X rot + sub ax, [PosXWr] + movsx ecx, ax + + lodsw ; ebx Y rot + sub ax, [PosYWr] + movsx ebx, ax + + lodsw ; ecx Z rot + movsx eax, ax ; ou cwde ? + xchg eax, ecx + movsx ebp, [PosZWr] + sub ebp, ecx ; bp = Zrot tri + +;-------------------------------------------- +; cmp word ptr[TypeProj], PROJ_ISO +; jz projiso + +; iso js nopoint ; si Z0 < 0 clip +; cmp ax, cx ; si X0 > Z0 clip +; jg nopoint +; cmp bx, cx ; si Y0 > Z0 clip +; jg nopoint + +; neg cx +; cmp ax, cx +; jl nopoint +; cmp bx, cx +; jl nopoint +; neg cx + + +projiso: mov ecx, eax ; save x + + add eax, ebp ; x + zrot + + sal eax, 3 ; *8 + mov edx, eax + sal eax, 1 ; *16 + add eax, edx ; *24 + + mov edx, eax + sar edx, 16 ; + idiv word ptr[IsoScale] ; (x+zrot)/IsoScale + + add ax, [XCentre] + stosw ; stock Xp + + cmp ax, [ScreenXmin] + jl sxmin +nosxmin: cmp ax, [ScreenXmax] + jg sxmax +nosxmax: + mov eax, ecx ; restore x + sub eax, ebp ; x - zrot + sub ebp, ecx ; Zrot - X pour bon tri + + sal eax, 2 ; *4 + mov edx, eax + sal eax, 1 ; *8 + add eax, edx ; *12 + + mov ecx, eax ; ecx = (x-zrot) * 12 + + sal ebx, 1 ; *2 + mov eax, ebx ; = 2 + sal eax, 4 ; *32 + sub eax, ebx + + sub eax, ecx ; - (x-zrot) * 12 + + mov edx, eax + sar edx, 16 + idiv word ptr[IsoScale] + + neg ax + add ax, [YCentre] + stosw ; stock Yp + + cmp ax, [ScreenYmin] + jl symin +nosymin: cmp ax, [ScreenYmax] + jg symax +nosymax: + + mov ax, bp + stosw ; stock Zrot pour tri + +;-------------------------------------------- + +pl0: pop ecx + dec ecx + jnz boucleproj + + pop esi + +;*--------------------------------------------------------------------------* + +finanim: mov eax, -1 + ret + +sxmin: mov [ScreenXmin], ax + jmp nosxmin +sxmax: mov [ScreenXmax],ax + jmp nosxmax +symin: mov [ScreenYmin], ax + jmp nosymin +symax: mov [ScreenYmax],ax + jmp nosymax + +nopoint: xor eax, eax + stosw + stosw + mov ax, -1 + stosw + jmp pl0 + +AnimNuage endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛßßßÛ ßßÛßß ÛßßßÛ ßßÛßß Ûßßßß ÛÛÜ Û Û Û ÛßßßÛ Ûßßßß Ûßßßß +; ÛÛßÛß ÛÛ Û ÛÛ ÛÛßßÛ ÛÛ ÛÛßß ÛÛßÛÛ ÛÛ Û ÛÛßßÛ ÛÛ ßÛ ÛÛßß +; ßß ß ßßßßß ßß ßß ß ßß ßßßßß ßßßßß ßß ß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +RotateNuage proc near + + push esi + + call RotMatW ; Rotate MWorld vers Mrot + + pop esi + + ; rotationS nuage de points + + lodsw ; nbobj points + mov [NbPoints], ax + movzx ecx, ax + + mov edi,offset List_Point + +bouclerot: push ecx + push edi + + ; rotation totale de l'objet + + lodsw + mov cx, ax ; AX X reel + lodsw + mov bx, ax ; BX Y reel + lodsw + xchg ax, cx ; CX Z reel + + call Rot ; voir pour Coor rot‚es + ; en LONG * 2^15 + pop edi + + ; change repere (pos camera reelle & pos objet reelle) + + mov ax, [X0] + sub ax, [PosXWr] + + mov bx, [Y0] + sub bx, [PosYWr] + + mov cx, [PosZWr] + sub cx, [Z0] + mov bp, cx + + js nopoint ; si Z0 < 0 clip + cmp ax, cx ; si X0 > Z0 clip + jg nopoint + cmp bx, cx ; si Y0 > Z0 clip + jg nopoint + neg cx + cmp ax, cx + jl nopoint + cmp bx, cx + jl nopoint + neg cx + + ; projection point + + call Proj + + stosw ; stock Xp + + cmp ax,[ScreenXmin] + jge nosxmin + mov [ScreenXmin],ax +nosxmin: cmp ax,[ScreenXmax] + jle nosxmax + mov [ScreenXmax],ax +nosxmax: + mov ax,bx + stosw ; stock Yp + + cmp ax,[ScreenYmin] + jge nosymin + mov [ScreenYmin],ax +nosymin: cmp ax,[ScreenYmax] + jle nosymax + mov [ScreenYmax],ax +nosymax: + mov ax,cx + stosw ; stock Zrot + +rn0: pop ecx + dec ecx + jnz bouclerot + + ret + +nopoint: xor ax, ax + stosw + stosw + mov ax, -1 + stosw + jmp rn0 + +RotateNuage endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÛÜ Û ÛßßßÛ ÛßßßÛ ÛÜ ÜÛ ÛßßßÛ Û ÛÛßßß +; ÛÛßÛÛ ÛÛ Û ÛÛßÛß ÛÛß Û ÛÛßßÛ ÛÛ ßßßßÛ +; ßß ß ßßßßß ßß ß ßß ß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +ComputeStaticNormal proc near + + lodsw ; nbobj normal faces/points + mov cx, ax + jcxz nonp + + mov edi, offset List_Normal + +bouclerot: push ecx + push edi + + lodsw + mov dx, ax ; AX X + lodsw + mov bx, ax ; BX Y + lodsw + mov cx, ax ; CX Z + lodsw + xchg dx, ax ; DX prenormalized range + + call Rot ; DX inchang‚ + + pop edi + + mov bp, dx + + mov ax, [X0] + + imul word ptr[NormalXLight] + mov cx, ax + mov bx, dx + + mov ax, [Y0] + imul word ptr[NormalYLight] + add cx, ax + adc bx, dx + + mov ax, [Z0] + imul word ptr[NormalZLight] + add cx, ax + adc bx, dx + + mov ax, cx + mov dx, bx ; intensity + + or dx,dx + js nointensity ; saut si negatif + + idiv bp + stosw ; stock intensity + + pop ecx + loop bouclerot + +nonp: ret + +nointensity: xor ax, ax + stosw + pop ecx + loop bouclerot + + ret + +ComputeStaticNormal endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +nextgroup2: pop ebx + add ebx, 38 + pop ecx + loop bouclegroup + jmp nonp + +ComputeAnimNormal proc near + + lodsw ; nbobj normal faces/points + or ax, ax + jz nonp + + mov edi,offset List_Normal + + movzx ecx, [NbGroupes] + + mov ebx, [ListGroupe] + add ebx, 18 ; sur NbNormal + +bouclegroup: push ecx + push ebx + + mov cx, [ebx] + jcxz nextgroup2 + + ; copy Mgroup vers Mrot + + mov edx, esi + mov ebp, edi + mov esi, ebx + inc esi + inc esi ; sur Mgroup + + mov edi, offset MatriceRot + mov ecx, 4 + rep movsd + movsw + mov edi, ebp + mov esi, edx + + movzx ecx, word ptr[ebx] + +; cmp [FlagLight], 0 +; jz nolight1 + +; call RotListNormal + +;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + mov [compteur], cx + +bouclerot: ;push ecx + push edi + + movsx ebp, word ptr[esi+0] + movsx ebx, word ptr[esi+2] + movsx ecx, word ptr[esi+4] + add esi, 6 + + movsx eax, word ptr[ Mat00 ] + imul eax, ebp + mov edx, eax + movsx eax, word ptr[ Mat01 ] + imul eax, ebx + add edx, eax + movsx eax, word ptr[ Mat02 ] + imul eax, ecx + add eax, edx + sar eax, 14 + + movsx edx, word ptr[NormalXLight] + imul eax, edx + mov edi, eax + + movsx eax, word ptr[ Mat10 ] + imul eax, ebp + mov edx, eax + movsx eax, word ptr[ Mat11 ] + imul eax, ebx + add edx, eax + movsx eax, word ptr[ Mat12 ] + imul eax, ecx + add eax, edx + sar eax, 14 + + movsx edx, word ptr[NormalYLight] + imul eax, edx + add edi, eax + + movsx eax, word ptr[ Mat20 ] + imul eax, ebp + mov edx, eax + movsx eax, word ptr[ Mat21 ] + imul eax, ebx + add edx, eax + movsx eax, word ptr[ Mat22 ] + imul eax, ecx + add eax, edx + sar eax, 14 + + movsx edx, word ptr[NormalZLight] + imul eax, edx + add edi, eax + + or edi, edi + js nointensity ; saut si negatif + + lodsw ; prenormalized range + xchg di, ax + cwd + idiv di + + pop edi + stosw ; stock intensity + +; pop ecx +; dec ecx + dec word ptr[compteur] + jnz bouclerot + + jmp nextgroup + +nointensity: lodsw + xor ax, ax + pop edi + stosw + +; pop ecx +; dec ecx + dec word ptr[compteur] + jnz bouclerot + +;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +nextgroup: pop ebx + add ebx, 38 + + pop ecx + dec ecx + jnz bouclegroup +; loop bouclegroup + +nonp: ret + +nolight1: mov ebx, ecx + xor ax, ax + rep stosw + shl ebx, 3 + add esi, ebx + jmp short nextgroup + +ComputeAnimNormal endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + + END diff --git a/LIB386/LIB_3D/P_OB_ISO.ASM b/LIB386/LIB_3D/P_OB_ISO.ASM new file mode 100644 index 0000000..b933f1e --- /dev/null +++ b/LIB386/LIB_3D/P_OB_ISO.ASM @@ -0,0 +1,1736 @@ + .386p + jumps + + .model SMALL, SYSCALL + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÜ ÜÛ ÛßßßÛ ÛßßÛ Û Ûßßßß ßßÛßß +; ÛÛß Û ÛÛ Û ÛÛßßÛ ÜÜ Û ÛÛßß ÛÛ +; ßß ß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + + include p_define.ash + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + .data +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + + ; extern M_TRIGO + + extrn NoLanguage CameraXr:DWORD + extrn NoLanguage CameraYr:DWORD + extrn NoLanguage CameraZr:DWORD + extrn NoLanguage X0:DWORD + extrn NoLanguage Y0:DWORD + extrn NoLanguage Z0:DWORD + extrn NoLanguage XCentre:DWORD + extrn NoLanguage YCentre:DWORD + + extrn NoLanguage lAlpha:DWORD + extrn NoLanguage lBeta:DWORD + extrn NoLanguage lGamma:DWORD + + extrn NoLanguage NormalXLight:DWORD + extrn NoLanguage NormalYLight:DWORD + extrn NoLanguage NormalZLight:DWORD + + extrn NoLanguage LMatriceWorld:DWORD + +; extrn NoLanguage IsoScale:WORD + extrn NoLanguage TypeProj:WORD + + extrn NoLanguage KFactor:DWORD + extrn NoLanguage LFactorX:DWORD + extrn NoLanguage LFactorY:DWORD + + extrn NoLanguage LMat00:DWORD + extrn NoLanguage LMat01:DWORD + extrn NoLanguage LMat02:DWORD + extrn NoLanguage LMat10:DWORD + extrn NoLanguage LMat11:DWORD + extrn NoLanguage LMat12:DWORD + extrn NoLanguage LMat20:DWORD + extrn NoLanguage LMat21:DWORD + extrn NoLanguage LMat22:DWORD + + extrn NoLanguage TabMat:DWORD + + extrn NoLanguage compteur:WORD + + ; extern LIB_GRAF + + extrn NoLanguage NbPolyPoints:WORD + extrn NoLanguage TabPoly:WORD + extrn NoLanguage TypePoly:WORD + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + public NoLanguage FlagLight + + public NoLanguage List_Point + public NoLanguage NbPoints + + public NoLanguage List_Anim_Point + public NoLanguage List_Entity + public NoLanguage List_Tri + + public NoLanguage ScreenXmin + public NoLanguage ScreenYmin + public NoLanguage ScreenXmax + public NoLanguage ScreenYmax + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +List_Point dw (500*3) dup(00) ; Xp Yp Zrot + +List_Normal dw 500 dup(00) ; surement plus + +List_Anim_Point dw (500*3) dup(00) ; Xr Yr Zr + +List_Entity dw 5000 dup(00) ; TAILLE … determin‚e + +List_Tri dw (500*8) dup(00) ; entites + +ScreenXmin dw 00 +ScreenYmin dw 00 +ScreenXmax dw 00 +ScreenYmax dw 00 + +NbPoints dw 00 +TotalEntite dw 00 + +ZMax dw 00 + +NbGroupes dw 00 + +Infos dw 00 + +Count1 dw 00 + +FlagLight dw 01 + +ALIGN 4 + +PointeurListTri dd 00 +StartDI dd 00 +NextDI dd 00 + +ListGroupe dd 00 + +StartInfos dd 00 +OffsetDefPoint dd 00 +OffsetListNormal dd 00 + +Save1 dd 00 +Save2 dd 00 +Save3 dd 00 +Ptr1 dd 00 +Ptr2 dd 00 + +PosXWr dd 00 ; pos World rot‚e de l'objet … afficher +PosYWr dd 00 +PosZWr dd 00 + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +TabJump_2 dd aff_E_LIGNE + dd aff_E_POLY + dd aff_E_SPHERE + +; dd aff_E_POINT + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + .code +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + + + public NoLanguage PatchObjet + public NoLanguage AffObjetIso + + + extrn NoLanguage ComputePoly_A:PROC +; extrn NoLanguage ComputePoly:PROC + extrn NoLanguage ComputeSphere_A:PROC + extrn NoLanguage FillVertic_A:PROC + extrn NoLanguage Line_A:PROC + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + + extrn NoLanguage RotMatW:near + extrn NoLanguage RotMatIndex2:near + extrn NoLanguage WorldRot:near + extrn NoLanguage LongWorldRot:near + extrn NoLanguage Rot:near +; extrn NoLanguage Proj:near + extrn NoLanguage Proj_3D:near + extrn NoLanguage Proj_ISO:near + extrn NoLanguage RotList:near +; extrn NoLanguage RotList16:near + extrn NoLanguage TransRotList:near +; extrn NoLanguage RotListNormal:near + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ Ûßßßß Ûßßßß ÛßßßÛ ÛßßÛ Û Ûßßßß ßßÛßß +; ÛÛßßÛ ÛÛßß ÛÛßß ÛÛ Û ÛÛßßÛ ÜÜ Û ÛÛßß ÛÛ +; ßß ß ßß ßß ßßßßß ßßßßß ßßßßß ßßßßß ßß ISO +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + + +PatchObjet proc uses esi ebx ebp,\ + ptrobj:DWORD + + mov esi, ptrobj + + test word ptr[esi], INFO_ANIM + jz exit + + movzx eax, word ptr[esi+14] ; nb bytes to skip + lea esi, [esi+eax+16] ; saute zone info + + movzx eax, word ptr[esi] ; nb points + add esi, 2 + + lea eax, [eax+eax*2] ; *3 + lea esi, [esi+eax*2] ; *6, esi saute defpoint + + mov cx, [esi] + add esi, 2 + + dec cx ; - groupe 0 + jz exit + + mov bp, 36 + mov bx, 38 + +ag0: add esi, 38 ; size d'un groupe + mov ax, [esi+6] ; orggroupe * 38 + mul bp + div bx ; orggroupe * 36 + mov [esi+6], ax + dec cx + jnz ag0 +exit: + ret + +PatchObjet endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +AffObjetIso proc uses esi edi ebx ebp,\ + xwr:DWORD, ywr:DWORD, zwr:DWORD,\ + palpha:DWORD, pbeta:DWORD, pgamma:DWORD,\ + ptrobj:DWORD + + mov eax, palpha + mov [lAlpha], eax + mov eax, pbeta + mov [lBeta], eax + mov eax, pgamma + mov [lGamma], eax + + mov ax, 32767 + mov [ScreenXmin], ax + mov [ScreenYmin], ax + neg ax + mov [ScreenXmax], ax + mov [ScreenYmax], ax + +;*-------------------------------------------------------------------------- +;* rotation world org obj + + cmp word ptr[TypeProj], TYPE_3D + jnz iso0 + + mov eax, xwr ; X World rot + mov ebx, ywr ; Y World + mov ecx, zwr ; Z World + + mov [Save1], ebp + call LongWorldRot + mov ebp, [Save1] + + mov eax, [X0] + sub eax, [CameraXr] + mov [PosXWr], eax + + mov eax, [Y0] + sub eax, [CameraYr] + mov [PosYWr], eax + + mov eax, [Z0] + sub eax, [CameraZr] + mov [PosZWr], eax + + jmp iso1 + +iso0: + mov eax, xwr ; X World rot + mov [PosXWr], eax + mov eax, ywr ; Y World rot + mov [PosYWr], eax + mov eax, zwr ; Z World rot + mov [PosZWr], eax + +iso1: +;*-------------------------------------------------------------------------- +;* recup infos + + mov [TotalEntite], 0 + mov [PointeurListTri], offset List_Tri + + mov esi, ptrobj + + mov bx, [esi] ; infos + mov [Infos], bx + + movzx eax, word ptr[esi+14] ; nb bytes to skip + lea esi, [esi+eax+16] ; saute zone info + +;*--------------------------------------------------------------------------* +;* rotation nuage/normal face/normal point + + + test bx, INFO_ANIM + jnz AnimNuage + jmp RotateNuage + +; test bx, INFO_ANIM +; jz normalrotate + +; call AnimNuage ; Objet Anim‚ +; call ComputeAnimNormal +; jmp short finnuage +;normalrotate: +; call RotateNuage ; Objet Normal +; call ComputeStaticNormal + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛßßßÛ Û Û Üß Ûßßßß ÛßßßÛ ÛÛÜ Û Ûßßßß ÛÛßßß +; ÛÛßßß ÛÛ Û ÛÛ ÛÛß ÛÛ ßÛ ÛÛ Û ÛÛßÛÛ ÛÛßß ßßßßÛ +; ßß ßßßßß ßßßßß ßß ßßßßß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +finnuage:: + mov edi, offset List_Entity + + mov cx, word ptr[esi] ; nb polys + add esi, 2 + or cx, cx + jz lignes + + mov [Count1], cx +b_poly: + mov [StartDI], edi ; memo pointeur List_Coor + + mov ecx, [esi] ; matiere poly + nb point poly + ; (+ coul1/coul2) + add esi, 2 + + cmp cl, 9 ; >= MAT_GOURAUD + jae polygouraud + + cmp cl, 7 ; >= MAT_FLAT + jae polyflat + +;----------------------------------------------------------------------------- +; MAT_TRISTE->MAT_TRAME + + mov [edi], ecx ; stock type + nbp + ; stock coul1/coul2 + add esi, 2 + add edi, 4 + + mov bp, -32000 ; ZMax + + mov [Ptr1], edi ; memo start poly somm + + xor eax, eax + EVEN +p0: lodsw ; index point sur List_Point + mov edx, [eax+offset List_Point]; index d‚j… *SIZE_LIST_POINT + mov dword ptr[edi+2], edx ; Xscr & Yscr dans List_Coor + add edi, 6 + + mov dx, word ptr[eax+offset List_Point+4]; Zrot + cmp dx, bp ; ZMin + jle nozmax + mov bp, dx +nozmax: + dec ch + jnz p0 + + jmp testpoly + +;----------------------------------------------------------------------------- +; MAT_FLAT +polyflat: sub cl, 7 + mov [edi], cx ; stock mat translat‚ + nbp + + mov bp, [esi] ; coul1/coul2 + + xor eax, eax + + ; 1st coul = normal face + mov ax, [esi+2] + add esi, 4 + add bp, word ptr[ List_Normal + eax*2 ] + mov word ptr[edi+2], bp ; stock coul + intensity + add edi, 4 + + mov [ptr1], edi ; memo start poly somm + + mov bp, -32000 ; ZMax + + EVEN +p0f: lodsw ; index point sur List_Point + mov edx, [eax+offset List_Point]; index d‚j… *SIZE_LIST_POINT + mov dword ptr[edi+2], edx ; Xscr & Yscr dans List_Coor + add edi, 6 + + mov dx, word ptr[eax+offset List_Point+4]; Zrot + cmp dx, bp ; ZMin + jle nozmaxf + mov bp, dx +nozmaxf: + dec ch + jnz p0f + + jmp testpoly + +comment @ + +skippoly: mov esi, ebx + dec ecx + shl ecx, 1 + add esi, ecx ; skip points restant + mov edi, [Ptr1] + jmp badpoly + +skippolyg: mov esi, ebx + dec ecx + shl ecx, 2 + add esi, ecx ; skip points restant + mov edi, [Ptr1] + jmp badpoly + + @ + +comment @ + +;----------------------------------------------------------------------------- +; gouraud --> MAT_TRISTE->MAT_TRAME + + +nolight2: xor cl, cl + mov [edi], cx ; stock type + nbp + add edi, 2 ; stock nbp + + movsw ; stock coul1/coul2 + + mov bp, 32000 ; ZMax + + mov [ptr1], edi ; memo start poly somm + + EVEN +p0l: add esi, 2 ; oublie normal + + lodsw ; index point sur List_Point + movzx ebx, ax ; index d‚j… *SIZE_LIST_POINT + add ebx, offset List_Point + + xchg ebx, esi + lodsd + mov dword ptr[edi+2], eax ; Xscr & Yscr dans List_Coor + add edi, 6 + + lodsw ; Zrot +; iso or ax, ax +; js skippoly ; <0 ? + + cmp ax, bp ; ZMin + jge nozmaxl + mov bp, ax +nozmaxl: + mov esi, ebx + dec ch + jnz p0l + + jmp testpoly + + @ + +;----------------------------------------------------------------------------- +; MAT_GOURAUD + + +polygouraud: ;cmp [FlagLight], 0 + ;jz nolight2 + + sub cl, 2 ; attention voir reanim + mov [edi], ecx ; stock type translated + nbp + ; + stock coul1/coul2 + add esi, 2 + add edi, 4 + + shr ecx, 8 ; cl = nbp, ch = coul1 + + mov bp, -32000 ; ZMax + + mov [Ptr1], edi ; memo start poly somm + + xor eax, eax + EVEN +p0g: + mov ax, [esi] ; normal point + mov dx, word ptr[List_Normal+eax*2] + add dl, ch + mov word ptr[edi], dx ; stock intensity point + + mov ax, [esi+2] ; index point sur List_Point + add esi, 4 + mov edx, [eax+offset List_Point]; index d‚j… *SIZE_LIST_POINT + mov dword ptr[edi+2], edx ; Xscr & Yscr dans List_Coor + add edi, 6 + + mov dx, word ptr[eax+offset List_Point+4]; Zrot + + ; voir pour "depthcueing" vers sombre + + cmp dx, bp ; ZMin + jle nozmaxg + mov bp, dx +nozmaxg: + dec cl + jnz p0g + +;----------------------------------------------------------------------------- +testpoly: mov [NextDI], edi ; memo pointeur List_Coor + + mov edi, [Ptr1] ; pointeur list sommets + + mov [ZMax], bp + + mov ax, [edi+4] + mov bx, [edi+8] + sub ax, [edi+16] + sub bx, [edi+2] + imul bx + mov bp,ax + mov bx,dx + mov ax, [edi+2] + mov cx, [edi+10] + sub ax, [edi+14] + sub cx, [edi+4] + imul cx + + sub ax, bp ; oublie face si bx:bp < dx:ax + sbb dx, bx + jnl badpoly + +okpoly: + inc [TotalEntite] + mov edi, [PointeurListTri] + mov ax, [ZMax] + mov word ptr[edi], ax + mov word ptr[edi+2], E_POLY + mov eax, [StartDI] + mov dword ptr[edi+4], eax + add edi, 8 + mov [PointeurListTri], edi + +;----------------------------------------------------------------------------- + + mov edi, [NextDI] +nextpoly: dec word ptr[Count1] + jnz b_poly + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Û Û Ûßßßß ÛÛÜ Û Ûßßßß ÛÛßßß +; ÛÛ ÛÛ ÛÛ ßÛ ÛÛßÛÛ ÛÛßß ßßßßÛ +; ßßßßß ßß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +lignes: mov cx, [esi] ; nb lignes + add esi, 2 + or cx, cx + jz spheres + + add [TotalEntite], cx + + mov edx, [PointeurListTri] + + xor ebx, ebx + +b_line: mov eax, [esi] ; stock matiere/coul + mov [edi], eax ; coul2 / even + + + mov bx, [esi+4] ; index point 1 sur List_Point + + mov eax, [ebx+offset List_Point+00] + mov dword ptr[edi+4], eax ; X1scr vers List_Coor + ; Y1scr + mov bp, word ptr[ebx+offset List_Point+04]; Zrot ZMin/Max + + + mov bx, [esi+6] ; index point 2 sur List_Point + add esi, 8 + + mov eax, [ebx+offset List_Point+00] + mov dword ptr[edi+8], eax ; X2scr vers List_Coor + ; Y2scr + + cmp word ptr[ebx+offset List_Point+04], bp; ZMin ZMax + jl zok0 + mov bp, word ptr[ebx+offset List_Point+04] +zok0: + mov word ptr[edx], bp + mov word ptr[edx+2], E_LIGNE + mov dword ptr[edx+4], edi + add edx, 8 + add edi, 12 + + dec cx + jnz b_line + + mov [PointeurListTri], edx + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÛßßß ÛßßßÛ Û Û Ûßßßß ÛßßßÛ Ûßßßß ÛÛßßß +; ßßßßÛ ÛÛßßß ÛÛßßÛ ÛÛßß ÛÛßÛß ÛÛßß ßßßßÛ +; ßßßßß ßß ßß ß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +spheres: mov cx, [esi] ; nb spheres + add esi, 2 + or cx, cx + jz tri + + add [TotalEntite], cx + + mov edx, [PointeurListTri] + +b_sphere: mov eax, [esi] ; stock matiere/coul + mov ebx, [esi+4] ; rayon & index point 1 sur List_Point + mov [edi], eax ; coul2 / even + mov [edi+4], bx ; rayon + add esi, 8 + + shr ebx, 16 ; index point 1 sur List_Point + mov eax, [ebx+offset List_Point+00] ; X1scr vers List_Coor + mov dword ptr[edi+6], eax ; Y1scr + mov ax, word ptr[ebx+offset List_Point+04] ; Zrot ZMin/Max + mov word ptr[edi+10], ax + + mov word ptr[edx], ax + mov word ptr[edx+2], E_SPHERE + mov dword ptr[edx+4], edi + add edi, 12 + add edx, 8 + + dec cx + jnz b_sphere + + mov [PointeurListTri], edx + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ßßÛßß ÛßßßÛ Û Ûßßßß ÛÛÜ Û ßßÛßß Û ßßÛßß Û Üß +; ÛÛ ÛÛßÛß ÛÛ ÛÛßß ÛÛßÛÛ ÛÛ ÛÛ ÛÛ ÛÛß +; ßß ßß ß ßß ßßßßß ßßßßß ßß ß ßß ßß ßß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; tri les faces dans la table Listtri (ordre Z et offset sur list coors +; premachees. + +tri: movzx ecx, word ptr[TotalEntite] + dec ecx + jle fintri + + mov esi, offset List_Tri + lea ebp, [esi+ecx*8] + +SergeSort:: ; esi bas + ; ebp haut + ; cx nbr d'elements + + ; ax pivot + ; edi pospivot + ; ebx h + + push 0 ; flag de fin de pile ! + + jmp nocalccx + +plusgrand: mov ebx, edi + mov eax, [edi] + jmp short cont + +permut: ; cx nb entite - 1 + ; esi start list sizeof 8 byte + + mov bp, cx + +tt0: mov eax, [esi] ; lit Z + + lea edi, [esi+8] + xor ebx, ebx + +tt1: cmp [edi], ax + jg plusgrand +cont: add edi, 8 + dec cx + jnz tt1 + + or ebx, ebx + jz short noexchg + + xchg [esi], eax ; permutte + mov [ebx], eax + mov eax, [esi+04] + xchg [ebx+04], eax + mov [esi+04], eax + +noexchg: add esi, 8 + dec bp + mov cx, bp + jnz tt0 + + pop ebp + or ebp, ebp + jnz short dopop + jmp fintri + +permut2: mov eax, [esi] + mov ebx, [ebp] + + cmp ax, bx + jge short skipswap + + mov [esi], ebx + mov [ebp], eax + mov eax, [esi+04] + xchg [ebp+04], eax + mov [esi+04], eax +skipswap: + pop ebp + or ebp, ebp + jz short fintri + +dopop: pop esi +nopop: + mov ecx, ebp + sub ecx, esi + shr ecx, 3 +nocalccx: + cmp cx, 1 ; select permut2 ? + je short permut2 + + cmp cx, 7 ; select permut ou qsort + jbe short permut + + mov edi, esi ; pospivot = bas + + mov eax, [esi] ; pivot = [pospivot] = [bas] + + add esi, 8 ; bas++ + + mov ebx, ebp ; h = haut + +w1: cmp word ptr[esi], ax + jl short w2 + add esi, 8 ; si [bas] >= pivot + dec cx + jnz w1 + + jmp short w4 + +w2: cmp word ptr[ebx], ax + jg short w3 + sub ebx, 8 ; si [h] <= pivot + dec cx + jnz w2 + + jmp short w4 + +w3: mov edx, [esi] ; xchg [bas],[h] + xchg edx, [ebx] + mov [esi], edx + mov edx, [esi+4] + xchg edx, [ebx+4] + mov [esi+4], edx + + jmp short w1 +w4: + xchg esi, ebx ; idem que esi-=8 et ebx+=8 + + xchg [esi], eax ; xchg [pospivot],[bas] + mov [edi], eax + mov edx, [edi+4] + xchg edx, [esi+4] + mov [edi+4], edx + + cmp ebx, ebp + jae short nopush + + push ebx ; h + push ebp ; haut +nopush: + sub esi, 8 + cmp edi, esi + jae short norecur + + mov ebp, esi + mov esi, edi + jmp nopop +norecur: + pop ebp + or ebp, ebp + jnz dopop +fintri: + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÜ Û ÛÛßßß ÛßßßÛ Û ÛßßßÛ Û Üß +; ÛÛ Û ÛÛ ßßßßÛ ÛÛßßß ÛÛ ÛÛßßÛ ÛÛß +; ßßßß ßß ßßßßß ßß ßßßßß ßß ß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; affichage des entit‚s + + mov esi,offset List_Tri + + mov cx, [TotalEntite] + or cx, cx + jz badfinafobj_1 + + mov [Count1], cx + mov [Ptr1], esi + +ade0: movzx ebx, word ptr[esi+2] ; type entit‚ + mov esi, [esi+4] ; offset List_Coor + add [Ptr1], 8 + + jmp [ TabJump_2 + ebx*4 ] ; jmp … aff de l'entit‚ + +nextaff:: mov esi, [Ptr1] + dec word ptr[Count1] + jnz ade0 + +goodfinobj: xor eax, eax ; OK affich‚ au moins 1 entit‚ + ret + +;*--------------------------------------------------------------------------*/ + +badfinafobj_1: ; 1 si pas d'entite to aff + mov ax,-1 + mov [ScreenXmax], ax + mov [ScreenYmax], ax + mov [ScreenXmin], ax + mov [ScreenYmin], ax + mov eax, 1 + ret + +;*--------------------------------------------------------------------------*/ + +badpoly: mov edi, [StartDI] + jmp nextpoly + +AffObjetIso endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Ûßßßß ÛÛÜ Û ßßÛßß Û ßßÛßß Û Üß +; ÛÛßß ÛÛßÛÛ ÛÛ ÛÛ ÛÛ ÛÛß +; ßßßßß ßß ß ßß ßß ßß ßß +; +; ÛßßßÜ Û ÛÛßßß ÛßßßÛ Û ÛßßßÛ Û Üß +; ÛÛ Û ÛÛ ßßßßÛ ÛÛßßß ÛÛ ÛÛßßÛ ÛÛß +; ßßßß ßß ßßßßß ßß ßßßßß ßß ß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +aff_E_POLY:: + xor ecx, ecx + mov ebx, ecx + + lodsd + mov bl, al ; type + mov cl, ah ; nb points + shr eax, 16 ; coul1/coul2 + + mov [TypePoly], bx + mov [NbPolyPoints], cx + + lea ecx, [ecx+ecx*2] ; *3 word + mov edi, offset TabPoly + shr ecx, 1 + jnc dod + movsw +dod: rep movsd + + + mov di, ax ; coul pour fillv + + call ComputePoly_A + or ax, ax + jz nextaff + + mov cx, bx ; type + call FillVertic_A + + jmp nextaff + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +aff_E_LIGNE:: + mov ax, [esi] + xchg al, ah + mov bp, ax + + mov ebx, [esi+4] + movsx eax, bx ; x0 + sar ebx, 16 ; y0 + mov edx, [esi+8] + movsx ecx, dx ; x1 + sar edx, 16 ; y1 + + call Line_A + + jmp nextaff + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +aff_E_SPHERE:: + movzx eax, byte ptr[esi] ; type + mov [save1], eax ; mov [TypePoly], ax + + mov ax, [esi+1] ; coul1/coul2 + mov [save2], eax + + mov ecx, [esi+4] + movzx ebp, cx ; rayon + shr ecx, 16 ; x + movzx edi, word ptr[esi+8] ; y + + cmp word ptr[TypeProj], TYPE_3D + jnz isosph + + mov ax, bp ; rayon + imul word ptr[LFactorX] + mov bp, word ptr[esi+10] ; Z + add bp, word ptr[KFactor] + idiv bp + movzx ebp, ax + jmp short affsph + + ; mov ax, 34 ; racine sxý+syý + ; imul bp + ; idiv word ptr[IsoScale] + ; movzx ebp, ax +isosph: imul ebp, 34 ; racine sxý+syý + sar ebp, 9 ; /512 IsoScale + + ; ecx x + ; edi y -> esi pour computesphere + ; ebp rayon sur ecran + + ; reajuste coordonn‚e box + +affsph: mov ax, cx ; x + rayon + add ax, bp + cmp ax, [ScreenXmax] + jle nosxa + mov [ScreenXmax], ax +nosxa: mov ax, cx ; x - rayon + sub ax, bp + cmp ax, [ScreenXmin] + jge nosxi + mov [ScreenXmin], ax +nosxi: mov ax, di + add ax, bp ; y + rayon + cmp ax, [ScreenYmax] + jle nosya + mov [ScreenYmax], ax +nosya: mov ax, di ; y - rayon + sub ax, bp + cmp ax, [ScreenYmin] + jge nosyi + mov [ScreenYmin], ax +nosyi: + + mov esi, edi + call ComputeSphere_A + + or eax, eax + jz nextaff + + mov edi, [save2] ; coul + mov ecx, [save1] ; type + + call FillVertic_A + +no_sphere: jmp nextaff + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; sous programmes +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛÛÜ Û Û ÛÜ ÜÛ ÛßßßÛ ÛßßßÛ ßßÛßß +; ÛÛßßÛ ÛÛßÛÛ ÛÛ ÛÛß Û ÛÛßÛß ÛÛ Û ÛÛ +; ßß ß ßß ß ßß ßß ß ßßßßß ßß ß ßßßßß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +RotateGroupe proc near + + mov [lAlpha], ebx + mov [lBeta], ecx + mov [lGamma], edx + + movzx eax, word ptr[esi] ; Start point deja *6 + mov [Save2], eax + movzx eax, word ptr[esi+2] ; nb points + mov [Save3], eax + + movzx ebp, word ptr[esi+6] ; orggroupe deja * 36 + cmp bp, -1 + jne pasgroupe0 + + mov ebp, offset LMatriceWorld + + mov [X0], 0 ; XYZ0 ChgRepere + mov [Y0], 0 + mov [Z0], 0 + + jmp short groupe0 + +pasgroupe0: add ebp, offset TabMat ; EBP Matrice du groupe org + + movzx edx, word ptr[esi+04] ; Org Point index deja *6 + mov eax, dword ptr[List_Anim_Point+edx] ; X0 & Y0 + movsx edi, ax + sar eax, 16 + mov [X0], edi + mov [Y0], eax + movsx eax, word ptr[List_Anim_Point+edx+4] ; Z0 + mov [Z0], eax ; XYZ0 ChgRepere +groupe0: + mov eax, [Ptr1] ; Mgroup + + call RotMatIndex2 ; rot de Mtempo vers Mrot & Mgroup + + mov ecx, [Save2] + + mov esi, [OffsetDefPoint] + add esi, ecx ; si sur Def_Point + Start + + lea edi, [List_Anim_Point + ecx]; di sur List_Point + Start + + mov ecx, [Save3] + + jmp RotList + +RotateGroupe endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +TranslateGroupe proc near + + mov [lAlpha], ebx ; attention ! + mov [lBeta], ecx ; ici step de translation + mov [lGamma], edx + + mov edx, esi ; save group en cours + + movzx esi, word ptr[esi+6] ; orggroupe deja * 38 + cmp si, -1 + jne pasgroupe0 + + mov [X0], 0 + mov [Y0], 0 + mov [Z0], 0 ; ChgRepere + + mov esi, offset LMatriceWorld + + jmp short groupe0 + +pasgroupe0: add esi, offset TabMat ; Mgroup org + + movzx ecx, word ptr[edx+4] ; Org Point index deja *6 + mov eax, dword ptr[List_Anim_Point+ecx] ; X0 & Y0 + movsx edi, ax + sar eax, 16 + mov [X0], edi + mov [Y0], eax + movsx eax, word ptr[List_Anim_Point + ecx + 4]; Z0 + mov [Z0], eax ; XYZ0 ChgRepere + +groupe0: mov eax, [Ptr1] + + mov edi, eax + mov ecx, 9 + rep movsd + + mov ecx, [edx] + movzx edx, cx ; Start point deja *6 + + mov esi, [OffsetDefPoint] + add esi, edx ; si sur List_Point + Start + + lea edi, [List_Anim_Point + edx] + + shr ecx, 16 ; nb points + + jmp TransRotList + +TranslateGroupe endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +ifdef Poubelle +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +ZoomGroupe proc near + +; bx zoomX cx zoomY dx zoomZ + + inc bh ; ZoomX + 256 + inc ch ; ZoomY + 256 + inc dh ; ZoomZ + 256 + mov bp, dx ; bp zoomZ + + mov di, [si+0] ; Start point deja *6 + mov dx, [si+2] ; nb points + + mov si, offset List_Anim_Point + add si, di ; si sur List_Point + Start + + push ds + + mov di, es + mov ds, di ; ds sur dgroup + EVEN +rg0: push dx ; beurk + + mov ax, [si] ; Delta X + imul bx + mov al, ah ; /256 + mov ah, dl + mov [si], ax + inc si + inc si + + mov ax, [si] ; Delta Y + imul cx + mov al, ah ; /256 + mov ah, dl + mov [si], ax + inc si + inc si + + mov ax, [si] ; Delta Z + imul bp + mov al, ah ; /256 + mov ah, dl + mov [si], ax + inc si + inc si + + pop dx + dec dx + jnz rg0 + + pop ds + ret + +ZoomGroupe endp + +endif + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛÛÜ Û Û ÛÜ ÜÛ ÛÛÜ Û Û Û ÛßßßÛ Ûßßßß Ûßßßß +; ÛÛßßÛ ÛÛßÛÛ ÛÛ ÛÛß Û ÛÛßÛÛ ÛÛ Û ÛÛßßÛ ÛÛ ßÛ ÛÛßß +; ßß ß ßß ß ßß ßß ß ßßßßß ßß ß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +AnimNuage proc near + + movzx eax, word ptr[esi] ; nb points + add esi, 2 + mov [NbPoints], ax + + mov [OffsetDefPoint], esi + lea eax, [eax+eax*2] ; *3 + lea esi, [esi+eax*2] ; *6, esi saute defpoint + + lodsw + mov [NbGroupes], ax + + mov [ListGroupe], esi ; memo start list groupe + +;*--------------------------------------------------------------------------*/ +; rotations du groupe 0 + + mov ebx, [lAlpha] ; SI sur groupe 0 + mov ecx, [lBeta] ; init aux valeurs de rot locale + mov edx, [lGamma] + + mov [Ptr1], offset TabMat + + mov [Save1], esi + + call RotateGroupe + + mov esi, [Save1] + add esi, 38 ; size d'un groupe + mov [Save1], esi + +;*--------------------------------------------------------------------------*/ +; rotations/translations/zooms des groupes + + mov cx, [NbGroupes] + dec cx ; - groupe 0 + jz ag0f + + mov [Count1], cx + + mov [Ptr1], offset TabMat + 36 + +ag0: mov ebx, [esi+8] + mov ax, bx ; type anim groupe + sar ebx, 16 ; Alpha ou stepX + mov edx, [esi+12] + movsx ecx, dx ; Beta ou stepY + sar edx, 16 ; Gamma ou stepZ + + cmp ax, TYPE_ROTATE + jz rotateg + cmp ax, TYPE_TRANSLATE + jnz nolocalrot + +; jz translateg +; cmp ax, TYPE_ZOOM +; jnz nolocalrot + +;zoomg: call ZoomGroupe +; jmp short nolocalrot + +translateg: call TranslateGroupe + jmp short nolocalrot + +rotateg: call RotateGroupe + +nolocalrot: add [Ptr1], 36 ; next matrix + + mov esi, [Save1] + add esi, 38 ; size d'un groupe + mov [Save1], esi + + dec word ptr[Count1] + jnz ag0 + +ag0f: + +;*--------------------------------------------------------------------------*/ +; projette liste + +project: mov cx, [NbPoints] + mov [Count1], cx + + mov esi, offset List_Anim_Point + mov edi, offset List_Point + + cmp word ptr[TypeProj], TYPE_3D + jz boucleproj3d + + + +boucleproj: movsx eax, word ptr[esi] ; eax X rot + add eax, [PosXWr] + + movsx ebx, word ptr[esi+2] ; ebx Y rot + add ebx, [PosYWr] + + movsx ebp, word ptr[esi+4] + add ebp, [PosZWr] + neg ebp ; Z rot, bp = Zrot tri + + add esi, 6 + +projiso: lea ecx, [ebp+eax] ; x + zrot + lea ecx, [ecx*8] ; *8 + lea ecx, [ecx+ecx*2] ; *24 + + sar ecx, 9 ; /512 IsoScale + + add cx, word ptr[XCentre] + mov word ptr[edi], cx ; stock Xp + + cmp cx, [ScreenXmin] + jl sxmin +nosxmin: cmp cx, [ScreenXmax] + jg sxmax +nosxmax: + mov ecx, eax + sub eax, ebp ; x - zrot + sub ebp, ecx ; Zrot - X pour bon tri + + lea eax, [eax*4] ; *4 + lea eax, [eax+eax*2] ; *12 + ; eax = (x-zrot) * 12 + +; essai de correction tri par influence du y + sub bp, bx + + lea ecx, [ebx+ebx] ; *2 + shl ebx, 5 ; 32 + sub ecx, ebx ; - y*30 + + add eax, ecx ; + (x-zrot) * 12 + + ; mov edx, eax + ; sar edx, 16 + ; idiv word ptr[IsoScale] + + sar eax, 9 ; /512 IsoScale + + add ax, word ptr[YCentre] + mov word ptr[edi+2], ax ; stock Yp + + cmp ax, [ScreenYmin] + jl symin +nosymin: cmp ax, [ScreenYmax] + jg symax +nosymax: + + mov word ptr[edi+4], bp ; stock Zrot pour tri + add edi, 6 + +;-------------------------------------------- + +pl0: dec word ptr[Count1] + jnz boucleproj + + + mov esi, [Save1] + mov eax, -1 + jmp ComputeAnimNormal +; ret + +;*--------------------------------------------------------------------------* +;*--------------------------------------------------------------------------* +;*--------------------------------------------------------------------------* + + +sxmin: mov [ScreenXmin], cx + jmp nosxmin +sxmax: mov [ScreenXmax], cx + jmp nosxmax +symin: mov [ScreenYmin], ax + jmp nosymin +symax: mov [ScreenYmax], ax + jmp nosymax + +sxmin3d: mov [ScreenXmin], ax + jmp nosxmin3d +sxmax3d: mov [ScreenXmax], ax + jmp nosxmax3d +symin3d: mov [ScreenYmin], ax + jmp nosymin3d +symax3d: mov [ScreenYmax], ax + jmp nosymax3d + +overflow: mov ebp, 7FFFFFFFh ; max value + jmp fixed + +overX: shr eax, 16 + or ax, 7FFFh + jmp fixedX + +overY: shr eax, 16 + or ax, 7FFFh + jmp fixedY + +overZ: shr ebp, 16 + or bp, 7FFFh + jmp fixedZ + + +boucleproj3D: movsx eax, word ptr[esi] ; eax X rot + add eax, [PosXWr] + + movsx ebx, word ptr[esi+2] ; ebx Y rot + add ebx, [PosYWr] + + movsx ebp, word ptr[esi+4] ; Z rot, bp = Zrot tri + add ebp, [PosZWr] + neg ebp + + add esi, 6 + + add ebp, [KFactor] + jle overflow + +fixed: imul [LFactorX] ; X + idiv ebp + add eax, [XCentre] + + cmp eax, 0FFFFh + ja overX +fixedX: + mov word ptr[edi], ax ; stock Xp + + cmp ax, [ScreenXmin] + jl sxmin3d +nosxmin3d: cmp ax, [ScreenXmax] + jg sxmax3d +nosxmax3d: + + mov eax, ebx + neg eax + imul [LFactorY] ; -Y + idiv ebp + add eax, [YCentre] + + cmp eax, 0FFFFh + ja overY +fixedY: + mov word ptr[edi+2], ax ; stock Yp + + cmp ax, [ScreenYmin] + jl symin3d +nosymin3d: cmp ax, [ScreenYmax] + jg symax3d +nosymax3d: + cmp ebp, 0FFFFh + ja overZ +fixedZ: + mov word ptr[edi+4], bp ; stock Zrot pour tri + add edi, 6 + +;-------------------------------------------- + +pl03d: dec word ptr[Count1] + jnz boucleproj3d + +;*--------------------------------------------------------------------------* + + mov esi, [Save1] + +finanim: +; mov eax, -1 +; ret + +;AnimNuage endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÛÜ Û ÛßßßÛ ÛßßßÛ ÛÜ ÜÛ ÛßßßÛ Û ÛÛßßß +; ÛÛßÛÛ ÛÛ Û ÛÛßÛß ÛÛß Û ÛÛßßÛ ÛÛ ßßßßÛ +; ßß ß ßßßßß ßß ß ßß ß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +;ComputeAnimNormal proc near + +ComputeAnimNormal: + + lodsw ; nbobj normal faces/points + or ax, ax + jz nonp + + mov edi, offset List_Normal + mov [Ptr1], edi + + mov eax, offset TabMat + mov [Ptr2], eax + + mov cx, [NbGroupes] + mov word ptr[Count1], cx + + mov ebx, [ListGroupe] + add ebx, 18 ; sur NbNormal + mov [Save1], ebx + +bouclegroup: mov cx, [ebx] + or cx, cx + jz nextgroup + + mov [compteur], cx + + ; copy Mgroup vers Mrot & Premultiply par Normallight + + mov ecx, [NormalXlight] + mov edx, [eax+LT00] + mov ebx, [eax+LT01] + mov ebp, [eax+LT02] + imul edx, ecx + imul ebx, ecx + imul ebp, ecx + mov [LMat00], edx + mov [LMat01], ebx + mov [LMat02], ebp + + mov ecx, [NormalYlight] + mov edx, [eax+LT10] + mov ebx, [eax+LT11] + mov ebp, [eax+LT12] + imul edx, ecx + imul ebx, ecx + imul ebp, ecx + mov [LMat10], edx + mov [LMat11], ebx + mov [LMat12], ebp + + mov ecx, [NormalZlight] + mov edx, [eax+LT20] + mov ebx, [eax+LT21] + mov ebp, [eax+LT22] + imul edx, ecx + imul ebx, ecx + imul ebp, ecx + mov [LMat20], edx + mov [LMat21], ebx + mov [LMat22], ebp + +;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +bouclerot: + mov ebx, [esi] + movsx ebp, bx + sar ebx, 16 + movsx ecx, word ptr[esi+4] + + mov eax, [ LMat00 ] + mov edx, [ LMat01 ] + imul eax, ebp + imul edx, ebx + add eax, edx + mov edx, [ LMat02 ] + imul edx, ecx + add eax, edx + + mov edi, [ LMat10 ] + mov edx, [ LMat11 ] + imul edi, ebp + imul edx, ebx + add eax, edi + mov edi, [ LMat12 ] + imul edi, ecx + add eax, edx + add eax, edi + + xor di, di ; 0 intensity for now + + imul ebp, [ LMat20 ] + imul ebx, [ LMat21 ] + add eax, ebp + imul ecx, [ LMat22 ] + add eax, ebx + add eax, ecx + + js nointensity ; saut si negatif + + sar eax, 14 + cwd + idiv word ptr[esi+6] ; prenormalized range + mov di, ax + +nointensity: mov eax, [Ptr1] + mov word ptr[eax], di ; stock intensity + add eax, 2 + mov [Ptr1], eax + + add esi, 8 + + dec word ptr[compteur] + jnz bouclerot + +;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +nextgroup: + mov ebx, [Save1] + mov eax, [Ptr2] + add ebx, 38 + add eax, 36 + mov [Save1], ebx + mov [Ptr2], eax + + dec word ptr[Count1] + jnz bouclegroup +nonp: + jmp FinNuage +; ret + +;ComputeAnimNormal endp + +AnimNuage endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛßßßÛ ßßÛßß ÛßßßÛ ßßÛßß Ûßßßß ÛÛÜ Û Û Û ÛßßßÛ Ûßßßß Ûßßßß +; ÛÛßÛß ÛÛ Û ÛÛ ÛÛßßÛ ÛÛ ÛÛßß ÛÛßÛÛ ÛÛ Û ÛÛßßÛ ÛÛ ßÛ ÛÛßß +; ßß ß ßßßßß ßß ßß ß ßß ßßßßß ßßßßß ßß ß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +RotateNuage proc near + + mov [Save1], esi + call RotMatW ; Rotate MWorld vers Mrot + mov esi, [Save1] + + ; rotationS nuage de points + + mov cx, word ptr[esi] ; nbobj points + add esi, 2 + mov [NbPoints], cx + + mov edi,offset List_Point + + mov [Count1], cx + mov [Ptr1], edi + +bouclerot2: + + ; rotation totale de l'objet + + mov ax, [esi] ; AX X reel + mov bx, [esi+2] ; BX Y reel + mov cx, [esi+4] ; CX Z reel + add esi, 6 + + call Rot ; voir pour Coor rot‚es + ; en LONG * 2^15 + + ; change repere (pos camera reelle & pos objet reelle) + + mov ax, word ptr[X0] + sub ax, word ptr[PosXWr] + + mov bx, word ptr[Y0] + sub bx, word ptr[PosYWr] + + mov bp, word ptr[Z0] + add bp, word ptr[PosZWr] + neg bp + + ; projection point + +; passer les param en long !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + mov word ptr[Save2], bp + call Proj_ISO + mov bp, word ptr[Save2] + + mov edi, [Ptr1] + + mov word ptr[edi], ax ; stock Xp + + cmp ax,[ScreenXmin] + jge nosxmin + mov [ScreenXmin],ax +nosxmin: cmp ax,[ScreenXmax] + jle nosxmax + mov [ScreenXmax],ax +nosxmax: + mov word ptr[edi+2], bx ; stock Yp + + cmp bx,[ScreenYmin] + jge nosymin + mov [ScreenYmin],bx +nosymin: cmp bx,[ScreenYmax] + jle nosymax + mov [ScreenYmax],bx +nosymax: + mov word ptr[edi+4], bp ; stock Zrot + + add dword ptr[Ptr1], 6 + +rn0: dec word ptr[Count1] + jnz bouclerot2 + +; jmp ComputeStaticNormal +; ret + +;RotateNuage endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÛÜ Û ÛßßßÛ ÛßßßÛ ÛÜ ÜÛ ÛßßßÛ Û ÛÛßßß +; ÛÛßÛÛ ÛÛ Û ÛÛßÛß ÛÛß Û ÛÛßßÛ ÛÛ ßßßßÛ +; ßß ß ßßßßß ßß ß ßß ß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +;ComputeStaticNormal proc near + + mov cx, [esi] ; nbobj normal faces/points + add esi, 2 + or cx, cx + jz nonp + + mov edi, offset List_Normal + + mov [Count1], cx + mov [Ptr1], edi + +bouclerot: mov ax, [esi] ; AX X + mov bx, [esi+2] ; BX Y + mov cx, [esi+4] ; CX Z + mov dx, [esi+6] ; DX prenormalized range + add esi, 8 + + call Rot ; DX inchang‚ + + mov bp, dx + + mov ax, word ptr[X0] + + imul word ptr[NormalXLight] + mov cx, ax + mov bx, dx + + mov ax, word ptr[Y0] + imul word ptr[NormalYLight] + add cx, ax + adc bx, dx + + mov ax, word ptr[Z0] + imul word ptr[NormalZLight] + add ax, cx + adc dx, bx ; intensity + + mov edi, [Ptr1] + + or dx,dx + js nointensity ; saut si negatif + + idiv bp + + mov word ptr[edi], ax + add edi, 2 + mov [Ptr1], edi ; stock intensity + + dec word ptr[Count1] + jnz bouclerot +nonp: + jmp FinNuage +; ret + +nointensity: mov word ptr[edi], 0 + add edi, 2 + mov [Ptr1], edi ; stock intensity + + dec word ptr[Count1] + jnz bouclerot + + jmp FinNuage +; ret + +;ComputeStaticNormal endp + +RotateNuage endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + + END diff --git a/LIB386/LIB_3D/P_SINTAB.ASM b/LIB386/LIB_3D/P_SINTAB.ASM new file mode 100644 index 0000000..5d9001c --- /dev/null +++ b/LIB386/LIB_3D/P_SINTAB.ASM @@ -0,0 +1,276 @@ + .386p + .model SMALL, SYSCALL + + .data + +EVEN + + public NoLanguage P_SinTab + +comment # + +P_SinTab dw 0, 201, 402, 603, 804, 1005, 1206, 1407 + dw 1608, 1809, 2009, 2210, 2411, 2611, 2811, 3012 + dw 3212, 3412, 3612, 3812, 4011, 4211, 4410, 4609 + dw 4808, 5007, 5205, 5404, 5602, 5800, 5998, 6195 + dw 6393, 6590, 6787, 6983, 7180, 7376, 7571, 7767 + dw 7962, 8157, 8351, 8546, 8740, 8933, 9127, 9319 + dw 9512, 9704, 9896, 10088, 10279, 10469, 10660, 10850 + dw 11039, 11228, 11417, 11605, 11793, 11980, 12167, 12354 + dw 12540, 12725, 12910, 13095, 13279, 13463, 13646, 13828 + dw 14010, 14192, 14373, 14553, 14733, 14912, 15091, 15269 + dw 15447, 15624, 15800, 15976, 16151, 16326, 16500, 16673 + dw 16846, 17018, 17190, 17361, 17531, 17700, 17869, 18037 + dw 18205, 18372, 18538, 18703, 18868, 19032, 19195, 19358 + dw 19520, 19681, 19841, 20001, 20160, 20318, 20475, 20632 + dw 20788, 20943, 21097, 21251, 21403, 21555, 21706, 21856 + dw 22006, 22154, 22302, 22449, 22595, 22740, 22884, 23028 + dw 23170, 23312, 23453, 23593, 23732, 23870, 24008, 24144 + dw 24279, 24414, 24548, 24680, 24812, 24943, 25073, 25202 + dw 25330, 25457, 25583, 25708, 25833, 25956, 26078, 26199 + dw 26320, 26439, 26557, 26674, 26791, 26906, 27020, 27133 + dw 27246, 27357, 27467, 27576, 27684, 27791, 27897, 28002 + dw 28106, 28209, 28311, 28411, 28511, 28610, 28707, 28803 + dw 28899, 28993, 29086, 29178, 29269, 29359, 29448, 29535 + dw 29622, 29707, 29792, 29875, 29957, 30038, 30118, 30196 + dw 30274, 30350, 30425, 30499, 30572, 30644, 30715, 30784 + dw 30853, 30920, 30986, 31050, 31114, 31177, 31238, 31298 + dw 31357, 31415, 31471, 31527, 31581, 31634, 31686, 31737 + dw 31786, 31834, 31881, 31927, 31972, 32015, 32058, 32099 + dw 32138, 32177, 32214, 32251, 32286, 32319, 32352, 32383 + dw 32413, 32442, 32470, 32496, 32522, 32546, 32568, 32590 + dw 32610, 32629, 32647, 32664, 32679, 32693, 32706, 32718 + dw 32729, 32738, 32746, 32753, 32758, 32762, 32766, 32767 + dw 32767, 32767, 32766, 32762, 32758, 32753, 32746, 32738 + dw 32729, 32718, 32706, 32693, 32679, 32664, 32647, 32629 + dw 32610, 32590, 32568, 32546, 32522, 32496, 32470, 32442 + dw 32413, 32383, 32352, 32319, 32286, 32251, 32214, 32177 + dw 32138, 32099, 32058, 32015, 31972, 31927, 31881, 31834 + dw 31786, 31737, 31686, 31634, 31581, 31527, 31471, 31415 + dw 31357, 31298, 31238, 31177, 31114, 31050, 30986, 30920 + dw 30853, 30784, 30715, 30644, 30572, 30499, 30425, 30350 + dw 30274, 30196, 30118, 30038, 29957, 29875, 29792, 29707 + dw 29622, 29535, 29448, 29359, 29269, 29178, 29086, 28993 + dw 28899, 28803, 28707, 28610, 28511, 28411, 28311, 28209 + dw 28106, 28002, 27897, 27791, 27684, 27576, 27467, 27357 + dw 27246, 27133, 27020, 26906, 26791, 26674, 26557, 26439 + dw 26320, 26199, 26078, 25956, 25833, 25708, 25583, 25457 + dw 25330, 25202, 25073, 24943, 24812, 24680, 24548, 24414 + dw 24279, 24144, 24008, 23870, 23732, 23593, 23453, 23312 + dw 23170, 23028, 22884, 22740, 22595, 22449, 22302, 22154 + dw 22006, 21856, 21706, 21555, 21403, 21251, 21097, 20943 + dw 20788, 20632, 20475, 20318, 20160, 20001, 19841, 19681 + dw 19520, 19358, 19195, 19032, 18868, 18703, 18538, 18372 + dw 18205, 18037, 17869, 17700, 17531, 17361, 17190, 17018 + dw 16846, 16673, 16500, 16326, 16151, 15976, 15800, 15624 + dw 15447, 15269, 15091, 14912, 14733, 14553, 14373, 14192 + dw 14010, 13828, 13646, 13463, 13279, 13095, 12910, 12725 + dw 12540, 12354, 12167, 11980, 11793, 11605, 11417, 11228 + dw 11039, 10850, 10660, 10469, 10279, 10088, 9896, 9704 + dw 9512, 9319, 9127, 8933, 8740, 8546, 8351, 8157 + dw 7962, 7767, 7571, 7376, 7180, 6983, 6787, 6590 + dw 6393, 6195, 5998, 5800, 5602, 5404, 5205, 5007 + dw 4808, 4609, 4410, 4211, 4011, 3812, 3612, 3412 + dw 3212, 3012, 2811, 2611, 2411, 2210, 2009, 1809 + dw 1608, 1407, 1206, 1005, 804, 603, 402, 201 + dw 0, -201, -402, -603, -804, -1005, -1206, -1407 + dw -1608, -1809, -2009, -2210, -2411, -2611, -2811, -3012 + dw -3212, -3412, -3612, -3812, -4011, -4211, -4410, -4609 + dw -4808, -5007, -5205, -5404, -5602, -5800, -5998, -6195 + dw -6393, -6590, -6787, -6983, -7180, -7376, -7571, -7767 + dw -7962, -8157, -8351, -8546, -8740, -8933, -9127, -9319 + dw -9512, -9704, -9896, -10088, -10279, -10469, -10660, -10850 + dw -11039, -11228, -11417, -11605, -11793, -11980, -12167, -12354 + dw -12540, -12725, -12910, -13095, -13279, -13463, -13646, -13828 + dw -14010, -14192, -14373, -14553, -14733, -14912, -15091, -15269 + dw -15447, -15624, -15800, -15976, -16151, -16326, -16500, -16673 + dw -16846, -17018, -17190, -17361, -17531, -17700, -17869, -18037 + dw -18205, -18372, -18538, -18703, -18868, -19032, -19195, -19358 + dw -19520, -19681, -19841, -20001, -20160, -20318, -20475, -20632 + dw -20788, -20943, -21097, -21251, -21403, -21555, -21706, -21856 + dw -22006, -22154, -22302, -22449, -22595, -22740, -22884, -23028 + dw -23170, -23312, -23453, -23593, -23732, -23870, -24008, -24144 + dw -24279, -24414, -24548, -24680, -24812, -24943, -25073, -25202 + dw -25330, -25457, -25583, -25708, -25833, -25956, -26078, -26199 + dw -26320, -26439, -26557, -26674, -26791, -26906, -27020, -27133 + dw -27246, -27357, -27467, -27576, -27684, -27791, -27897, -28002 + dw -28106, -28209, -28311, -28411, -28511, -28610, -28707, -28803 + dw -28899, -28993, -29086, -29178, -29269, -29359, -29448, -29535 + dw -29622, -29707, -29792, -29875, -29957, -30038, -30118, -30196 + dw -30274, -30350, -30425, -30499, -30572, -30644, -30715, -30784 + dw -30853, -30920, -30986, -31050, -31114, -31177, -31238, -31298 + dw -31357, -31415, -31471, -31527, -31581, -31634, -31686, -31737 + dw -31786, -31834, -31881, -31927, -31972, -32015, -32058, -32099 + dw -32138, -32177, -32214, -32251, -32286, -32319, -32352, -32383 + dw -32413, -32442, -32470, -32496, -32522, -32546, -32568, -32590 + dw -32610, -32629, -32647, -32664, -32679, -32693, -32706, -32718 + dw -32729, -32738, -32746, -32753, -32758, -32762, -32766, -32767 + dw -32768, -32767, -32766, -32762, -32758, -32753, -32746, -32738 + dw -32729, -32718, -32706, -32693, -32679, -32664, -32647, -32629 + dw -32610, -32590, -32568, -32546, -32522, -32496, -32470, -32442 + dw -32413, -32383, -32352, -32319, -32286, -32251, -32214, -32177 + dw -32138, -32099, -32058, -32015, -31972, -31927, -31881, -31834 + dw -31786, -31737, -31686, -31634, -31581, -31527, -31471, -31415 + dw -31357, -31298, -31238, -31177, -31114, -31050, -30986, -30920 + dw -30853, -30784, -30715, -30644, -30572, -30499, -30425, -30350 + dw -30274, -30196, -30118, -30038, -29957, -29875, -29792, -29707 + dw -29622, -29535, -29448, -29359, -29269, -29178, -29086, -28993 + dw -28899, -28803, -28707, -28610, -28511, -28411, -28311, -28209 + dw -28106, -28002, -27897, -27791, -27684, -27576, -27467, -27357 + dw -27246, -27133, -27020, -26906, -26791, -26674, -26557, -26439 + dw -26320, -26199, -26078, -25956, -25833, -25708, -25583, -25457 + dw -25330, -25202, -25073, -24943, -24812, -24680, -24548, -24414 + dw -24279, -24144, -24008, -23870, -23732, -23593, -23453, -23312 + dw -23170, -23028, -22884, -22740, -22595, -22449, -22302, -22154 + dw -22006, -21856, -21706, -21555, -21403, -21251, -21097, -20943 + dw -20788, -20632, -20475, -20318, -20160, -20001, -19841, -19681 + dw -19520, -19358, -19195, -19032, -18868, -18703, -18538, -18372 + dw -18205, -18037, -17869, -17700, -17531, -17361, -17190, -17018 + dw -16846, -16673, -16500, -16326, -16151, -15976, -15800, -15624 + dw -15447, -15269, -15091, -14912, -14733, -14553, -14373, -14192 + dw -14010, -13828, -13646, -13463, -13279, -13095, -12910, -12725 + dw -12540, -12354, -12167, -11980, -11793, -11605, -11417, -11228 + dw -11039, -10850, -10660, -10469, -10279, -10088, -9896, -9704 + dw -9512, -9319, -9127, -8933, -8740, -8546, -8351, -8157 + dw -7962, -7767, -7571, -7376, -7180, -6983, -6787, -6590 + dw -6393, -6195, -5998, -5800, -5602, -5404, -5205, -5007 + dw -4808, -4609, -4410, -4211, -4011, -3812, -3612, -3412 + dw -3212, -3012, -2811, -2611, -2411, -2210, -2009, -1809 + dw -1608, -1407, -1206, -1005, -804, -603, -402, -201 + + # + +;comment # + +P_SinTab dw 0, 101, 201, 302, 402, 503, 603, 704 + dw 804, 904, 1005, 1105, 1205, 1306, 1406, 1506 + dw 1606, 1706, 1806, 1906, 2006, 2105, 2205, 2305 + dw 2404, 2503, 2603, 2702, 2801, 2900, 2999, 3098 + dw 3196, 3295, 3393, 3492, 3590, 3688, 3786, 3883 + dw 3981, 4078, 4176, 4273, 4370, 4467, 4563, 4660 + dw 4756, 4852, 4948, 5044, 5139, 5235, 5330, 5425 + dw 5520, 5614, 5708, 5803, 5897, 5990, 6084, 6177 + dw 6270, 6363, 6455, 6547, 6639, 6731, 6823, 6914 + dw 7005, 7096, 7186, 7276, 7366, 7456, 7545, 7635 + dw 7723, 7812, 7900, 7988, 8076, 8163, 8250, 8337 + dw 8423, 8509, 8595, 8680, 8765, 8850, 8935, 9019 + dw 9102, 9186, 9269, 9352, 9434, 9516, 9598, 9679 + dw 9760, 9841, 9921, 10001, 10080, 10159, 10238, 10316 + dw 10394, 10471, 10549, 10625, 10702, 10778, 10853, 10928 + dw 11003, 11077, 11151, 11224, 11297, 11370, 11442, 11514 + dw 11585, 11656, 11727, 11797, 11866, 11935, 12004, 12072 + dw 12140, 12207, 12274, 12340, 12406, 12472, 12537, 12601 + dw 12665, 12729, 12792, 12854, 12916, 12978, 13039, 13100 + dw 13160, 13219, 13279, 13337, 13395, 13453, 13510, 13567 + dw 13623, 13678, 13733, 13788, 13842, 13896, 13949, 14001 + dw 14053, 14104, 14155, 14206, 14256, 14305, 14354, 14402 + dw 14449, 14497, 14543, 14589, 14635, 14680, 14724, 14768 + dw 14811, 14854, 14896, 14937, 14978, 15019, 15059, 15098 + dw 15137, 15175, 15213, 15250, 15286, 15322, 15357, 15392 + dw 15426, 15460, 15493, 15525, 15557, 15588, 15619, 15649 + dw 15679, 15707, 15736, 15763, 15791, 15817, 15843, 15868 + dw 15893, 15917, 15941, 15964, 15986, 16008, 16029, 16049 + dw 16069, 16088, 16107, 16125, 16143, 16160, 16176, 16192 + dw 16207, 16221, 16235, 16248, 16261, 16273, 16284, 16295 + dw 16305, 16315, 16324, 16332, 16340, 16347, 16353, 16359 + dw 16364, 16369, 16373, 16376, 16379, 16381, 16383, 16384 + dw 16384, 16384, 16383, 16381, 16379, 16376, 16373, 16369 + dw 16364, 16359, 16353, 16347, 16340, 16332, 16324, 16315 + dw 16305, 16295, 16284, 16273, 16261, 16248, 16235, 16221 + dw 16207, 16192, 16176, 16160, 16143, 16125, 16107, 16088 + dw 16069, 16049, 16029, 16008, 15986, 15964, 15941, 15917 + dw 15893, 15868, 15843, 15817, 15791, 15763, 15736, 15707 + dw 15679, 15649, 15619, 15588, 15557, 15525, 15493, 15460 + dw 15426, 15392, 15357, 15322, 15286, 15250, 15213, 15175 + dw 15137, 15098, 15059, 15019, 14978, 14937, 14896, 14854 + dw 14811, 14768, 14724, 14680, 14635, 14589, 14543, 14497 + dw 14449, 14402, 14354, 14305, 14256, 14206, 14155, 14104 + dw 14053, 14001, 13949, 13896, 13842, 13788, 13733, 13678 + dw 13623, 13567, 13510, 13453, 13395, 13337, 13279, 13219 + dw 13160, 13100, 13039, 12978, 12916, 12854, 12792, 12729 + dw 12665, 12601, 12537, 12472, 12406, 12340, 12274, 12207 + dw 12140, 12072, 12004, 11935, 11866, 11797, 11727, 11656 + dw 11585, 11514, 11442, 11370, 11297, 11224, 11151, 11077 + dw 11003, 10928, 10853, 10778, 10702, 10625, 10549, 10471 + dw 10394, 10316, 10238, 10159, 10080, 10001, 9921, 9841 + dw 9760, 9679, 9598, 9516, 9434, 9352, 9269, 9186 + dw 9102, 9019, 8935, 8850, 8765, 8680, 8595, 8509 + dw 8423, 8337, 8250, 8163, 8076, 7988, 7900, 7812 + dw 7723, 7635, 7545, 7456, 7366, 7276, 7186, 7096 + dw 7005, 6914, 6823, 6731, 6639, 6547, 6455, 6363 + dw 6270, 6177, 6084, 5990, 5897, 5803, 5708, 5614 + dw 5520, 5425, 5330, 5235, 5139, 5044, 4948, 4852 + dw 4756, 4660, 4563, 4467, 4370, 4273, 4176, 4078 + dw 3981, 3883, 3786, 3688, 3590, 3492, 3393, 3295 + dw 3196, 3098, 2999, 2900, 2801, 2702, 2603, 2503 + dw 2404, 2305, 2205, 2105, 2006, 1906, 1806, 1706 + dw 1606, 1506, 1406, 1306, 1205, 1105, 1005, 904 + dw 804, 704, 603, 503, 402, 302, 201, 101 + dw 0, -101, -201, -302, -402, -503, -603, -704 + dw -804, -904, -1005, -1105, -1205, -1306, -1406, -1506 + dw -1606, -1706, -1806, -1906, -2006, -2105, -2205, -2305 + dw -2404, -2503, -2603, -2702, -2801, -2900, -2999, -3098 + dw -3196, -3295, -3393, -3492, -3590, -3688, -3786, -3883 + dw -3981, -4078, -4176, -4273, -4370, -4467, -4563, -4660 + dw -4756, -4852, -4948, -5044, -5139, -5235, -5330, -5425 + dw -5520, -5614, -5708, -5803, -5897, -5990, -6084, -6177 + dw -6270, -6363, -6455, -6547, -6639, -6731, -6823, -6914 + dw -7005, -7096, -7186, -7276, -7366, -7456, -7545, -7635 + dw -7723, -7812, -7900, -7988, -8076, -8163, -8250, -8337 + dw -8423, -8509, -8595, -8680, -8765, -8850, -8935, -9019 + dw -9102, -9186, -9269, -9352, -9434, -9516, -9598, -9679 + dw -9760, -9841, -9921, -10001, -10080, -10159, -10238, -10316 + dw -10394, -10471, -10549, -10625, -10702, -10778, -10853, -10928 + dw -11003, -11077, -11151, -11224, -11297, -11370, -11442, -11514 + dw -11585, -11656, -11727, -11797, -11866, -11935, -12004, -12072 + dw -12140, -12207, -12274, -12340, -12406, -12472, -12537, -12601 + dw -12665, -12729, -12792, -12854, -12916, -12978, -13039, -13100 + dw -13160, -13219, -13279, -13337, -13395, -13453, -13510, -13567 + dw -13623, -13678, -13733, -13788, -13842, -13896, -13949, -14001 + dw -14053, -14104, -14155, -14206, -14256, -14305, -14354, -14402 + dw -14449, -14497, -14543, -14589, -14635, -14680, -14724, -14768 + dw -14811, -14854, -14896, -14937, -14978, -15019, -15059, -15098 + dw -15137, -15175, -15213, -15250, -15286, -15322, -15357, -15392 + dw -15426, -15460, -15493, -15525, -15557, -15588, -15619, -15649 + dw -15679, -15707, -15736, -15763, -15791, -15817, -15843, -15868 + dw -15893, -15917, -15941, -15964, -15986, -16008, -16029, -16049 + dw -16069, -16088, -16107, -16125, -16143, -16160, -16176, -16192 + dw -16207, -16221, -16235, -16248, -16261, -16273, -16284, -16295 + dw -16305, -16315, -16324, -16332, -16340, -16347, -16353, -16359 + dw -16364, -16369, -16373, -16376, -16379, -16381, -16383, -16384 + dw -16384, -16384, -16383, -16381, -16379, -16376, -16373, -16369 + dw -16364, -16359, -16353, -16347, -16340, -16332, -16324, -16315 + dw -16305, -16295, -16284, -16273, -16261, -16248, -16235, -16221 + dw -16207, -16192, -16176, -16160, -16143, -16125, -16107, -16088 + dw -16069, -16049, -16029, -16008, -15986, -15964, -15941, -15917 + dw -15893, -15868, -15843, -15817, -15791, -15763, -15736, -15707 + dw -15679, -15649, -15619, -15588, -15557, -15525, -15493, -15460 + dw -15426, -15392, -15357, -15322, -15286, -15250, -15213, -15175 + dw -15137, -15098, -15059, -15019, -14978, -14937, -14896, -14854 + dw -14811, -14768, -14724, -14680, -14635, -14589, -14543, -14497 + dw -14449, -14402, -14354, -14305, -14256, -14206, -14155, -14104 + dw -14053, -14001, -13949, -13896, -13842, -13788, -13733, -13678 + dw -13623, -13567, -13510, -13453, -13395, -13337, -13279, -13219 + dw -13160, -13100, -13039, -12978, -12916, -12854, -12792, -12729 + dw -12665, -12601, -12537, -12472, -12406, -12340, -12274, -12207 + dw -12140, -12072, -12004, -11935, -11866, -11797, -11727, -11656 + dw -11585, -11514, -11442, -11370, -11297, -11224, -11151, -11077 + dw -11003, -10928, -10853, -10778, -10702, -10625, -10549, -10471 + dw -10394, -10316, -10238, -10159, -10080, -10001, -9921, -9841 + dw -9760, -9679, -9598, -9516, -9434, -9352, -9269, -9186 + dw -9102, -9019, -8935, -8850, -8765, -8680, -8595, -8509 + dw -8423, -8337, -8250, -8163, -8076, -7988, -7900, -7812 + dw -7723, -7635, -7545, -7456, -7366, -7276, -7186, -7096 + dw -7005, -6914, -6823, -6731, -6639, -6547, -6455, -6363 + dw -6270, -6177, -6084, -5990, -5897, -5803, -5708, -5614 + dw -5520, -5425, -5330, -5235, -5139, -5044, -4948, -4852 + dw -4756, -4660, -4563, -4467, -4370, -4273, -4176, -4078 + dw -3981, -3883, -3786, -3688, -3590, -3492, -3393, -3295 + dw -3196, -3098, -2999, -2900, -2801, -2702, -2603, -2503 + dw -2404, -2305, -2205, -2105, -2006, -1906, -1806, -1706 + dw -1606, -1506, -1406, -1306, -1205, -1105, -1005, -904 + dw -804, -704, -603, -503, -402, -302, -201, -101 + +;# + + end diff --git a/LIB386/LIB_3D/P_TRIGO.ASM b/LIB386/LIB_3D/P_TRIGO.ASM new file mode 100644 index 0000000..33e69b1 --- /dev/null +++ b/LIB386/LIB_3D/P_TRIGO.ASM @@ -0,0 +1,1764 @@ + + .386p + jumps + + .model SMALL, SYSCALL + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÜ ÜÛ ßßÛßß ÛßßßÛ Û Ûßßßß ÛßßßÛ +; ÛÛß Û ÛÛ ÛÛßÛß ÛÛ ÛÛ ßÛ ÛÛ Û +; ßß ß ßßßßß ßß ßß ß ßß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + .data + + include P_define.ash + + + extrn NoLanguage P_SinTab:WORD + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; locales + +compteur dw 00 + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; globales + + + public NoLanguage TypeProj +TypeProj dw 00 + + + public NoLanguage XCentre + public NoLanguage YCentre +XCentre dd 320 +YCentre dd 200 + + public NoLanguage Xp + public NoLanguage Yp +Xp dw 00 +Yp dw 00 + + public NoLanguage IsoScale +IsoScale dw 500 + + public NoLanguage Z_Min + public NoLanguage Z_Max +Z_Min dw 00 +Z_Max dw 00 + + +ALIGN 4 + + public NoLanguage KFactor + public NoLanguage LFactorX + public NoLanguage LFactorY +KFactor dd 128 +LFactorX dd 1024 +LFactorY dd 840 + + public NoLanguage CameraX + public NoLanguage CameraY + public NoLanguage CameraZ +CameraX dd 00 +CameraY dd 00 +CameraZ dd 00 + + public NoLanguage CameraXr + public NoLanguage CameraYr + public NoLanguage CameraZr +CameraXr dd 00 +CameraYr dd 00 +CameraZr dd 00 + + public NoLanguage AlphaLight + public NoLanguage BetaLight + public NoLanguage GammaLight +AlphaLight dd 0000 +BetaLight dd 0000 +GammaLight dd 0000 + + public NoLanguage Alpha + public NoLanguage Beta + public NoLanguage Gamma +Alpha dd 0000 +Beta dd 0000 +Gamma dd 0000 + + + public NoLanguage LMatriceWorld + public NoLanguage LMatriceRot + public NoLanguage LMatriceTempo + +; public NoLanguage MatriceEntity + + public NoLanguage LMat00 + public NoLanguage LMat01 + public NoLanguage LMat02 + public NoLanguage LMat10 + public NoLanguage LMat11 + public NoLanguage LMat12 + public NoLanguage LMat20 + public NoLanguage LMat21 + public NoLanguage LMat22 + + public NoLanguage compteur + + + ; Je les ai bouge ici pour qu'il soit a cote des + ; Matrices afin d'essayer d'optimiser le cache + ; (on sait jamais....) + + public NoLanguage lAlpha + public NoLanguage lBeta + public NoLanguage lGamma +lAlpha dd 0000 +lBeta dd 0000 +lGamma dd 0000 + + public NoLanguage NormalXLight + public NoLanguage NormalYLight + public NoLanguage NormalZLight +NormalXLight dd 0061 +NormalYLight dd 0000 +NormalZLight dd 0000 + + public NoLanguage X0 + public NoLanguage Y0 + public NoLanguage Z0 +X0 dd 0000 +Y0 dd 0000 +Z0 dd 0000 + +LMatriceRot label DWORD +LMat00 dd 0000 +LMat01 dd 0000 +LMat02 dd 0000 +LMat10 dd 0000 +LMat11 dd 0000 +LMat12 dd 0000 +LMat20 dd 0000 +LMat21 dd 0000 +LMat22 dd 0000 + +LMatriceDummy label DWORD +LMatD00 dd 0000 +LMatD01 dd 0000 +LMatD02 dd 0000 +LMatD10 dd 0000 +LMatD11 dd 0000 +LMatD12 dd 0000 +LMatD20 dd 0000 +LMatD21 dd 0000 +LMatD22 dd 0000 + +Public NoLanguage LMatriceWorld +Public NoLanguage LMatW00 +Public NoLanguage LMatW01 +Public NoLanguage LMatW02 +Public NoLanguage LMatW10 +Public NoLanguage LMatW11 +Public NoLanguage LMatW12 +Public NoLanguage LMatW20 +Public NoLanguage LMatW21 +Public NoLanguage LMatW22 + +LMatriceWorld label DWORD +LMatW00 dd 0000 +LMatW01 dd 0000 +LMatW02 dd 0000 +LMatW10 dd 0000 +LMatW11 dd 0000 +LMatW12 dd 0000 +LMatW20 dd 0000 +LMatW21 dd 0000 +LMatW22 dd 0000 + + +LMatriceTempo label DWORD +LMatT00 dd 0000 +LMatT01 dd 0000 +LMatT02 dd 0000 +LMatT10 dd 0000 +LMatT11 dd 0000 +LMatT12 dd 0000 +LMatT20 dd 0000 +LMatT21 dd 0000 +LMatT22 dd 0000 + + public NoLanguage TabMat ; 30 Matrix max +TabMat dd 9*30 dup (?) + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +Save1 dd 0000 + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;h dw 00 + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + .code + + public NoLanguage Rotate + public NoLanguage RotatePoint + public NoLanguage LongInverseRotatePoint + public NoLanguage RotateMatriceWorld + public NoLanguage CopyMatrice + public NoLanguage LongWorldRotatePoint + public NoLanguage WorldRotatePoint + public NoLanguage SetFollowCamera + public NoLanguage SetPosCamera + public NoLanguage SetAngleCamera + public NoLanguage SetInverseAngleCamera + public NoLanguage SetProjection + public NoLanguage SetIsoProjection + public NoLanguage ProjettePoint + public Nolanguage LongProjettePoint + public NoLanguage TestVuePoly + + public NoLanguage LongWorldRot + public NoLanguage WorldRot + public NoLanguage RotMatW + public NoLanguage RotMatIndex2 + public NoLanguage Rot +; public NoLanguage Proj + public NoLanguage Proj_3D + public NoLanguage Proj_ISO + + public NoLanguage RotList + public NoLanguage TransRotList +; public NoLanguage RotListNormal + + public NoLanguage SetLightVector + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛßßßÛ Û ÛÛÜ Û ßßÛßß +; ÛÛßßß ÛÛ Û ÛÛ ÛÛßÛÛ ÛÛ +; ßß ßßßßß ßß ßß ß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; Rotation d'une liste d'apr‚s MatriceRot (ASM) +; ESI source XYZ +; EDI dest XYZ +; EAX Matrice +; ECX nbpoints +; EBP ‚clat‚ + +RotList proc near + + mov [compteur], cx + + jmp short start + +rl0: mov esi, [Save1] + add edi, 6 + add esi, 6 +start: mov [Save1], esi + + mov ebx, [esi] + movsx edx, bx + sar ebx, 16 + movsx ecx, word ptr[esi+04] + + mov esi, [ eax+LT00 ] + mov ebp, [ eax+LT01 ] + imul esi, edx + imul ebp, ebx + add esi, ebp + mov ebp, [ eax+LT02 ] + imul ebp, ecx + add esi, ebp + sar esi, 14 + add si, word ptr[X0] + mov word ptr[edi], si + + mov esi, [ eax+LT10 ] + mov ebp, [ eax+LT11 ] + imul esi, edx + imul ebp, ebx + add esi, ebp + mov ebp, [ eax+LT12 ] + imul ebp, ecx + add esi, ebp + sar esi, 14 + add si, word ptr[Y0] + mov word ptr[edi+2], si + + imul edx, [ eax+LT20 ] + imul ebx, [ eax+LT21 ] + imul ecx, [ eax+LT22 ] + add ecx, edx + add ecx, ebx + sar ecx, 14 + add cx, word ptr[Z0] + mov word ptr[edi+4], cx + + dec [compteur] + jnz rl0 + + ret + +RotList endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; Rotation et Translation d'une liste d'apr‚s MatriceRot (ASM) +; ESI source XYZ +; EDI dest XYZ +; EAX Matrice +; ECX nbpoints +; EBP ‚clat‚ + +TransRotList proc near + + mov [compteur], cx + + jmp short start + +rl0: mov esi, [Save1] + add edi, 6 + add esi, 6 +start: mov [Save1], esi + + movsx edx, word ptr[esi] + movsx ebx, word ptr[esi+02] + movsx ecx, word ptr[esi+04] + + add edx, [lAlpha] + add ebx, [lBeta] + add ecx, [lGamma] + + mov esi, [ eax+LT00 ] + mov ebp, [ eax+LT01 ] + imul esi, edx + imul ebp, ebx + add esi, ebp + mov ebp, [ eax+LT02 ] + imul ebp, ecx + add esi, ebp + sar esi, 14 + add si, word ptr[X0] + mov word ptr[edi], si + + mov esi, [ eax+LT10 ] + mov ebp, [ eax+LT11 ] + imul esi, edx + imul ebp, ebx + add esi, ebp + mov ebp, [ eax+LT12 ] + imul ebp, ecx + add esi, ebp + sar esi, 14 + add si, word ptr[Y0] + mov word ptr[edi+2], si + + imul edx, [ eax+LT20 ] + imul ebx, [ eax+LT21 ] + imul ecx, [ eax+LT22 ] + add ecx, edx + add ecx, ebx + sar ecx, 14 + add cx, word ptr[Z0] + mov word ptr[edi+4], cx + + dec [compteur] + jnz rl0 + + ret + +TransRotList endp + + +comment @ + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; Rotation d'une liste d'apr‚s MatriceRot (ASM) +; ESI source XYZ +; EDI dest XYZ +; ECX nbpoints +; EBP ‚clat‚ + +RotListNormal proc near + + mov [compteur], cx + +bouclerot: push edi + + movsx ebp, word ptr[esi] + movsx ebx, word ptr[esi+2] + movsx ecx, word ptr[esi+4] + add esi, 6 + + mov edx, [ LMat00 ] + mov eax, [ LMat01 ] + imul edx, ebp + imul eax, ebx + add edx, eax + mov eax, [ LMat02 ] + imul eax, ecx + add eax, edx + sar eax, 14 + + imul eax, [NormalXLight] + mov edi, eax + + mov edx, [ LMat10 ] + mov eax, [ LMat11 ] + imul edx, ebp + imul eax, ebx + add edx, eax + mov eax, [ LMat12 ] + imul eax, ecx + add eax, edx + sar eax, 14 + + imul eax, [NormalYLight] + add edi, eax + + mov edx, [ LMat20 ] + mov eax, [ LMat21 ] + imul edx, ebp + imul eax, ebx + add edx, eax + mov eax, [ LMat22 ] + imul eax, ecx + add eax, edx + sar eax, 14 + + imul eax, [NormalZLight] + add edi, eax + + or edi, edi + js nointensity ; saut si negatif + + lodsw ; prenormalized range + xchg di, ax + cwd + idiv di + + pop edi + mov word ptr[edi], ax + add edi, 2 ; stock intensity + + dec word ptr[compteur] + jnz bouclerot + + ret + +nointensity: add esi, 2 + + pop edi + mov word ptr[edi], 0 + add edi, 2 + + dec word ptr[compteur] + jnz bouclerot + + ret + +RotListNormal endp + + @ + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +SetLightVector proc uses esi edi ebx ebp,\ + pa:DWORD, pb:DWORD, pg:DWORD + + mov eax, pa + mov [AlphaLight], eax + mov [lAlpha], eax + mov eax, pb + mov [BetaLight], eax + mov [lBeta], eax + mov eax, pg ; pfeu + mov [GammaLight], eax + mov [lGamma], eax + + call RotMatW + + xor eax, eax + mov ebx, eax + mov ecx, NORMAL_UNIT - 5 ; je sais je sais... + + call Rot + + mov eax, [X0] + mov [NormalXLight], eax + mov eax, [Y0] + mov [NormalYLight], eax + mov eax, [Z0] + mov [NormalZLight], eax + + ret + +SetLightVector endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; Rotation d'un point d'apr‚s MatriceRot (ASM) +; DX et SI inchang‚s BP ‚clat‚ + +Rot proc + + ; AX=X BX=Y CX=Z + + movsx ebp, ax + movsx ebx, bx + movsx ecx, cx + + mov edi, [ LMat00 ] + mov eax, [ LMat01 ] + imul edi, ebp + imul eax, ebx + add edi, eax + mov eax, [ LMat02 ] + imul eax, ecx + add eax, edi + sar eax, 14 + mov [ X0 ], eax + + mov edi, [ LMat10 ] + mov eax, [ LMat11 ] + imul edi, ebp + imul eax, ebx + add edi, eax + mov eax, [ LMat12 ] + imul eax, ecx + add eax, edi + sar eax, 14 + mov [ Y0 ], eax + + imul ebp, [ LMat20 ] + imul ebx, [ LMat21 ] + imul ecx, [ LMat22 ] + add ebx, ebp + add ebx, ecx + sar ebx, 14 + mov [ Z0 ], ebx + + ; X0=X' Y0=Y' Z0=Z' + + ret + +Rot endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; Rotation d'un point d'apr‚s MatriceRot (C) + + +RotatePoint proc uses edi ebx ebp ,\ + X:DWORD, Y:DWORD, Z:DWORD + + mov eax, X + mov ebx, Y + mov ecx, Z + + call Rot + + ret + +RotatePoint endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Rotation d'un point d'apr‚s MatriceWorld (ASM) +; TOUS LES REGISTRES ECLATES + +LongWorldRot proc + + ; EAX=X EBX=Y ECX=Z + + mov ebp, eax + + mov eax, [ LMatW00 ] + imul ebp + mov esi, eax + mov edi, edx + mov eax, [ LMatW01 ] + imul ebx + add esi, eax + adc edi, edx + mov eax, [ LMatW02 ] + imul ecx + add esi, eax + adc edi, edx + shrd esi, edi, 14 + mov [ X0 ], esi + + mov eax, [ LMatW10 ] + imul ebp + mov esi, eax + mov edi, edx + mov eax, [ LMatW11 ] + imul ebx + add esi, eax + adc edi, edx + mov eax, [ LMatW12 ] + imul ecx + add esi, eax + adc edi, edx + shrd esi, edi, 14 + mov [ Y0 ], esi + + mov eax, [ LMatW20 ] + imul ebp + mov esi, eax + mov edi, edx + mov eax, [ LMatW21 ] + imul ebx + add esi, eax + adc edi, edx + mov eax, [ LMatW22 ] + imul ecx + add esi, eax + adc edi, edx + shrd esi, edi, 14 + mov [ Z0 ], esi + + ; X0=X' Y0=Y' Z0=Z' + + ret + +LongWorldRot endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; Rotation d'un point d'apr‚s MatriceWorld (C) + +LongWorldRotatePoint proc uses esi edi ebx ebp,\ + X:DWORD, Y:DWORD, Z:DWORD + + mov eax, X + mov ebx, Y + mov ecx, Z + + call LongWorldRot + + ret + +LongWorldRotatePoint endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Rotation d'un point d'apr‚s MatriceWorld (ASM) +; DX SI inchang‚ BP ‚clat‚ + +WorldRot proc + + ; AX=X BX=Y CX=Z + + movsx ebp, ax + movsx ebx, bx + movsx ecx, cx + + mov edi, [ LMatW00 ] + mov eax, [ LMatW01 ] + imul edi, ebp + imul eax, ebx + add edi, eax + mov eax, [ LMatW02 ] + imul eax, ecx + add eax, edi + sar eax, 14 + mov [ X0 ], eax + + mov edi, [ LMatW10 ] + mov eax, [ LMatW11 ] + imul edi, ebp + imul eax, ebx + add edi, eax + mov eax, [ LMatW12 ] + imul eax, ecx + add eax, edi + sar eax, 14 + mov [ Y0 ], eax + + mov edi, [ LMatW20 ] + mov eax, [ LMatW21 ] + imul edi, ebp + imul eax, ebx + add edi, eax + mov eax, [ LMatW22 ] + imul eax, ecx + add eax, edi + sar eax, 14 + mov [ Z0 ], eax + + ; X0=X' Y0=Y' Z0=Z' + + ret + +WorldRot endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; Rotation d'un point d'apr‚s MatriceWorld (C) + +WorldRotatePoint proc uses edi ebx ebp,\ + X:DWORD, Y:DWORD, Z:DWORD + + mov eax, X + mov ebx, Y + mov ecx, Z + + call WorldRot + + ret + +WorldRotatePoint endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Rotation d'un point d'apr‚s MatriceInverse (ASM) +; DX SI inchang‚ BP ‚clat‚ + +LongInverseRot proc + + ; EAX=X EBX=Y ECX=Z + + mov ebp, eax + + mov eax, [ LMatW00 ] + imul ebp + mov esi, eax + mov edi, edx + mov eax, [ LMatW10 ] + imul ebx + add esi, eax + adc edi, edx + mov eax, [ LMatW20 ] + imul ecx + add esi, eax + adc edi, edx + shrd esi, edi, 14 + mov [ X0 ], esi + + mov eax, [ LMatW01 ] + imul ebp + mov esi, eax + mov edi, edx + mov eax, [ LMatW11 ] + imul ebx + add esi, eax + adc edi, edx + mov eax, [ LMatW21 ] + imul ecx + add esi, eax + adc edi, edx + shrd esi, edi, 14 + mov [ Y0 ], esi + + mov eax, [ LMatW02 ] + imul ebp + mov esi, eax + mov edi, edx + mov eax, [ LMatW12 ] + imul ebx + add esi, eax + adc edi, edx + mov eax, [ LMatW22 ] + imul ecx + add esi, eax + adc edi, edx + shrd esi, edi, 14 + mov [ Z0 ], esi + + ; X0=X' Y0=Y' Z0=Z' + + ret + +LongInverseRot endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; Rotation d'un point d'apr‚s MatriceInverse (C) + +LongInverseRotatePoint proc uses esi edi ebx ebp,\ + X:DWORD, Y:DWORD, Z:DWORD + + mov eax, X + mov ebx, Y + mov ecx, Z + + call LongInverseRot + + ret + +LongInverseRotatePoint endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; fonctions de travail sur les +; ÛÜ ÜÛ ÛßßßÛ ßßÛßß ÛßßßÛ Û Ûßßßß Ûßßßß +; ÛÛß Û ÛÛßßÛ ÛÛ ÛÛßÛß ÛÛ ÛÛ ÛÛßß +; ßß ß ßß ß ßß ßß ß ßß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Rotation de MatriceWorld vers MatriceRot (ASM) + + +RotMatW proc + + mov ebp, offset LMatriceWorld + mov eax, offset LMatriceRot + jmp RotMatIndex2 + +RotMatW endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; Rotation de MatriceWorld vers MatriceRot (C) + +RotateMatriceWorld proc uses esi edi ebp ebx,\ + palpha:DWORD, pbeta:DWORD, pgamma:DWORD + + mov eax, palpha + mov lAlpha, eax + mov eax, pbeta + mov lBeta, eax + mov eax, pgamma + mov lGamma, eax + + mov ebp, offset LMatriceWorld + mov eax, offset LMatriceRot + + call RotMatIndex2 + + ret + +RotateMatriceWorld endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; rotation de Matrice pointe par EBP vers EAX (ASM) +; EBP -> LONG, EAX -> LONG +; EAX pas modifie !!! +; EBX pas utilise !!! + +RotMatIndex2 proc + +a: mov edx, [lAlpha] + or edx, edx + jz g + +doalpha: ; si s=TabSinus[a&1023]; + ; cx c=TabSinus[(a+256)&1023]; + and edx, 1023 + movsx esi, word ptr[ P_SinTab + edx*2 ] + add edx, 256 + and edx, 1023 + movsx ecx, word ptr[ P_SinTab + edx*2 ] + + ; LMat00 = LMatT00 ; + ; LMat10 = LMatT10 ; + ; LMat20 = LMatT20 ; + mov edi, [ebp+LT00] + mov edx, [ebp+LT10] + mov [eax+LT00], edi + mov edi, [ebp+LT20] + mov [eax+LT10], edx + mov [eax+LT20], edi + ; LMat01 = ( c*LMatT01 + s*LMatT02 )>>15; + mov edx, [ebp+LT01] + mov edi, [ebp+LT02] + imul edx, ecx + imul edi, esi + add edi, edx + sar edi, 14 + mov [eax+LT01], edi + ; LMat02 = ( c*LMatT02 + -s*LMatT01 )>>15; + mov edx, [ebp+LT01] + mov edi, [ebp+LT02] + imul edx, esi + imul edi, ecx + sub edi, edx + sar edi, 14 + mov [eax+LT02], edi + ; LMat11 = ( c*LMatT11 + s*LMatT12 )>>15; + mov edx, [ebp+LT11] + mov edi, [ebp+LT12] + imul edx, ecx + imul edi, esi + add edi, edx + sar edi, 14 + mov [eax+LT11], edi + ; LMat12 = ( c*LMatT12 + -s*LMatT11 )>>15; + mov edx, [ebp+LT11] + mov edi, [ebp+LT12] + imul edx, esi + imul edi, ecx + sub edi, edx + sar edi, 14 + mov [eax+LT12], edi + ; LMat21 = ( c*LMatT21 + s*LMatT22 )>>15; + mov edx, [ebp+LT21] + mov edi, [ebp+LT22] + imul edx, ecx + imul edi, esi + add edi, edx + sar edi, 14 + mov [eax+LT21], edi + ; LMat22 = ( c*LMatT22 + -s*LMatT21 )>>15; + mov edx, [ebp+LT21] + mov edi, [ebp+LT22] + imul edx, esi + imul edi, ecx + sub edi, edx + sar edi, 14 + mov [eax+LT22], edi + + mov ebp, eax + +g: mov edx, [lGamma] + or edx, edx + jz b + +dogamma: ; si s=TabSinus[g&1023]; + ; cx c=TabSinus[(g+256)&1023]; + and edx, 1023 + movsx esi, word ptr[ P_SinTab + edx*2 ] + add edx, 256 + and edx, 1023 + movsx ecx, word ptr[ P_SinTab + edx*2 ] + + ; LMatD02 = LMat02; + ; LMatD12 = LMat12; + ; LMatD22 = LMat22; + mov edi, [ebp+LT02] + mov edx, [ebp+LT12] + mov LMatD02, edi + mov edi, [ebp+LT22] + mov LMatD12, edx + mov LMatD22, edi + ; LMatD00 = ( c*LMat00 + s*LMat01 )>>15; + mov edx, [ebp+LT00] + mov edi, [ebp+LT01] + imul edx, ecx + imul edi, esi + add edi, edx + sar edi, 14 + mov LMatD00, edi + ; LMatD01 = ( c*LMat01 + -s*LMat00 )>>15; + mov edx, [ebp+LT00] + mov edi, [ebp+LT01] + imul edx, esi + imul edi, ecx + sub edi, edx + sar edi, 14 + mov LMatD01, edi + ; LMatD10 = ( c*LMat10 + s*LMat11 )>>15; + mov edx, [ebp+LT10] + mov edi, [ebp+LT11] + imul edx, ecx + imul edi, esi + add edi, edx + sar edi, 14 + mov LMatD10, edi + ; LMatD11 = ( c*LMat11 + -s*LMat10 )>>15; + mov edx, [ebp+LT10] + mov edi, [ebp+LT11] + imul edx, esi + imul edi, ecx + sub edi, edx + sar edi, 14 + mov LMatD11, edi + ; LMatD20 = ( c*LMat20 + s*LMat21 )>>15; + mov edx, [ebp+LT20] + mov edi, [ebp+LT21] + imul edx, ecx + imul edi, esi + add edi, edx + sar edi, 14 + mov LMatD20, edi + ; LMatD21 = ( c*LMat21 + -s*LMat20 )>>15; + imul esi, [ebp+LT20] + imul ecx, [ebp+LT21] + sub ecx, esi + sar ecx, 14 + mov LMatD21, ecx + + mov ebp, offset LMatriceDummy + +b: mov edx, [lBeta] + or edx, edx + jnz dobeta + + cmp ebp, eax + je short fin + + mov esi, ebp + mov edi, eax + mov ecx, 9 + rep movsd +fin: + ret + +dobeta: cmp ebp, eax + jne short nopb + + mov esi, eax + mov ebp, offset LMatriceDummy + mov edi, ebp + mov ecx, 9 + rep movsd +nopb: + ; si s=TabSinus[g&1023]; + ; cx c=TabSinus[(g+256)&1023]; + and edx, 1023 + movsx esi, word ptr[ P_SinTab + edx*2 ] + add edx, 256 + and edx, 1023 + movsx ecx, word ptr[ P_SinTab + edx*2 ] + + ; LMat01 = LMatD01 ; + ; LMat11 = LMatD11 ; + ; LMat21 = LMatD21 ; + mov edi, [ebp+LT01] + mov edx, [ebp+LT11] + mov [eax+LT01], edi + mov edi, [ebp+LT21] + mov [eax+LT11], edx + mov [eax+LT21], edi + + ; LMat00 = ( c*LMatD00 + -s*LMatD02 )>>15; + mov edx, [ebp+LT02] + mov edi, [ebp+LT00] + imul edx, esi + imul edi, ecx + sub edi, edx + sar edi, 14 + mov [eax+LT00], edi + ; LMat02 = ( c*LMatD02 + s*LMatD00 )>>15; + mov edx, [ebp+LT02] + mov edi, [ebp+LT00] + imul edx, ecx + imul edi, esi + add edi, edx + sar edi, 14 + mov [eax+LT02], edi + ; LMat10 = ( c*LMatD10 + -s*LMatD12 )>>15; + mov edx, [ebp+LT12] + mov edi, [ebp+LT10] + imul edx, esi + imul edi, ecx + sub edi, edx + sar edi, 14 + mov [eax+LT10], edi + ; LMat12 = ( c*LMatD12 + s*LMatD10 )>>15; + mov edx, [ebp+LT12] + mov edi, [ebp+LT10] + imul edx, ecx + imul edi, esi + add edi, edx + sar edi, 14 + mov [eax+LT12], edi + ; LMat20 = ( c*LMatD20 + -s*LMatD22 )>>15; + mov edx, [ebp+LT22] + mov edi, [ebp+LT20] + imul edx, esi + imul edi, ecx + sub edi, edx + sar edi, 14 + mov [eax+LT20], edi + ; LMat22 = ( c*LMatD22 + s*LMatD20 )>>15; + imul ecx, [ebp+LT22] + imul esi, [ebp+LT20] + add ecx, esi + sar ecx, 14 + mov [eax+LT22], ecx + + ret + +RotMatIndex2 endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Ûßßßß ÛßßßÛ ÛÜ ÜÛ Ûßßßß ÛßßßÛ ÛßßßÛ +; ÛÛ ÛÛßßÛ ÛÛß Û ÛÛßß ÛÛßÛß ÛÛßßÛ +; ßßßßß ßß ß ßß ß ßßßßß ßß ß ßß ß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +SetPosCamera proc ,\ + poswx:DWORD, poswy:DWORD, poswz:DWORD + + mov eax, poswx + mov [CameraX], eax + mov eax, poswy + mov [CameraY], eax + mov eax, poswz + mov [CameraZ], eax + + ret + +SetPosCamera endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; initialisation de MatriceWorld (C) + +SetInverseAngleCamera proc uses esi edi ebx ebp,\ + palpha:DWORD, pbeta:DWORD, pgamma:DWORD + + push pgamma + push pbeta + push palpha + call SetAngleCamera + add esp, 12 + + push offset LMatriceDummy + push offset LMatriceWorld + call FlipMatrice + add esp, 8 + + push offset LMatriceWorld + push offset LMatriceDummy + call CopyMatrice + add esp, 8 + + mov eax, [CameraX] + mov ebx, [CameraY] + mov ecx, [CameraZ] + + call LongWorldRot ; LONG for Ext mode + + mov eax, [X0] + mov [CameraXr], eax + mov eax, [Y0] + mov [CameraYr], eax + mov eax, [Z0] + mov [CameraZr], eax + + ret + +SetInverseAngleCamera endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; initialisation de MatriceWorld (C) + +SetAngleCamera proc uses esi edi ebx ebp,\ + palpha:DWORD, pbeta:DWORD, pgamma:DWORD + + ; si s=TabSinus[a&1023]; + ; cx c=TabSinus[(a+256)&1023]; + mov ebx, palpha + and ebx, 1023 + mov [Alpha], ebx + movsx esi, word ptr[ P_SinTab + ebx*2 ] + add ebx, 256 + and ebx, 1023 + movsx ecx, word ptr[ P_SinTab + ebx*2 ] + + ; di s2=TabSinus[g&1023]; + ; bx c2=TabSinus[(g+256)&1023]; + mov ebx, pgamma + and ebx, 1023 + mov [Gamma], ebx + movsx edi, word ptr[ P_SinTab + ebx*2 ] + add ebx, 256 + and ebx, 1023 + movsx ebx, word ptr[ P_SinTab + ebx*2 ] + + ; LMatW00 = c2; + mov LMatW00, ebx + ; LMatW01 = -s2; + mov eax, edi + neg eax + mov LMatW01, eax + ; LMatW10 = (s2*c)>>15; + mov eax, edi + imul eax, ecx + sar eax, 14 + mov LMatW10, eax + ; LMatW11 = (c2*c)>>15; + mov eax, ebx + imul eax, ecx + sar eax, 14 + mov LMatW11, eax + ; LMatW20 = (s2*s)>>15; + mov eax, edi + imul eax, esi + sar eax, 14 + mov LMatW20, eax + ; LMatW21 = (c2*s)>>15; + mov eax, ebx + imul eax, esi + sar eax, 14 + mov LMatW21, eax + ; di s2=TabSinus[ b&1023]; + ; bx c2=TabSinus[(b+256)&1023]; + mov ebx, pbeta + and ebx, 1023 + mov [Beta], ebx + movsx edi, word ptr[ P_SinTab + ebx*2 ] + add ebx, 256 + and ebx, 1023 + movsx ebx, word ptr[ P_SinTab + ebx*2 ] + + ; h=LMatW00; + mov ebp, [LMatW00] + ; LMatW00 = ( c2*h )>>15; + mov eax, ebx + imul eax, ebp + sar eax, 14 + mov LMatW00, eax + ; LMatW02 = ( s2*h )>>15; + mov eax, edi + imul eax, ebp + sar eax, 14 + mov LMatW02, eax + ; h = LMatW10 = MatI01 + mov ebp, [LMatW10] + ; LMatW10 = ( c2*h + s2*s )>>15; + mov edx, ebx + mov eax, edi + imul edx, ebp + imul eax, esi + add eax, edx + sar eax, 14 + mov LMatW10, eax + ; LMatW12 = (-c2*s + s2*h )>>15 + mov edx, ebx + mov eax, edi + imul edx, esi + imul eax, ebp + sub eax, edx + sar eax, 14 + mov LMatW12, eax + ; h=LMatW20 = MatI02 + mov ebp, [LMatW20] + ; LMatW20 = ( c2*h + -s2*c )>>15 + mov edx, ecx + mov eax, ebx + imul edx, edi + imul eax, ebp + sub eax, edx + sar eax, 14 + mov LMatW20, eax + ; LMatW22 = ( c2*c + s2*h )>>15 + mov edx, ecx + mov eax, edi + imul edx, ebx + imul eax, ebp + add eax, edx + sar eax, 14 + mov LMatW22, eax + + mov eax, [CameraX] + mov ebx, [CameraY] + mov ecx, [CameraZ] + + call LongWorldRot ; LONG for Ext mode + + mov eax, [X0] + mov [CameraXr], eax + mov eax, [Y0] + mov [CameraYr], eax + mov eax, [Z0] + mov [CameraZr], eax + + ret + +SetAngleCamera endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ßßßÛÛ ÛßßßÜ ÛßßßÛ ÛßßßÛ ßßÛßß ÛßßßÛ ßßÛßß Ûßßßß +; ÛÛßßß ÛÛ Û ÛÛßÛß ÛÛ Û ÛÛ ÛÛßßÛ ÛÛ ÛÛßß +; ßßßßß ßßßß ßßßßß ßß ß ßßßßß ßß ßß ß ßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Rotation 2D autour d'un axe +; entr‚e: bx=X cx=Z bp=T +; +; sortie: ax = X'=Z*sin(T)+X*cos(T) +; dx = Z'=Z*cos(T)-X*sin(T) +; +; ( bx,cx,di,si d‚truits ) +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +RotXY proc + + or bp,bp + jz norot + + movsx ebx, bx ; X + movsx ecx, cx ; Y + + movzx eax, bp ; T + and eax, 03FFh + mov edi, offset P_SinTab + movsx ebp, word ptr[ edi+eax*2 ] ; ebp = Sin( T ) + add eax, 256 + and eax, 03FFh + movsx edx, word ptr[ edi+eax*2 ] ; edx = Cos( T ) +; X*cos(T) + mov eax, ebx + imul eax, edx + mov edi, eax +; Z*sin(T) + mov eax, ecx + imul eax, ebp + add edi, eax + sar edi, 14 ; di= X'= X*cos(T)+Z*sin(T) +; Z*cos(T) + imul edx, ecx +; X*sin(T) + imul ebx, ebp + sub edx, ebx ; Z' = -X*sin(T) + Y*cos(T) + sar edx, 14 ; dx = Z' + + mov eax, edi ; ax = X' + ret + +norot: mov eax, ebx ; ax = X' = X + mov edx, ecx ; dx = Z' = Z + ret + +RotXY endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +Rotate proc uses esi edi ebx ebp,\ + coorx:DWORD,coory:DWORD,angle:DWORD + + mov ebx, coorx + mov ecx, coory + mov ebp, angle + call RotXY + mov [X0], eax + mov [Y0], edx + ret + +Rotate endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +SetFollowCamera proc uses esi edi ebx ebp,\ + targetx:DWORD, targety:DWORD, targetz:DWORD,\ + camalpha:DWORD,cambeta:DWORD,camgamma:DWORD,\ + camzoom:DWORD + + mov eax, targetx + mov [CameraX], eax + mov eax, targety + mov [CameraY], eax + mov eax, targetz + mov [CameraZ], eax + + push camgamma + push cambeta + push camalpha + call SetAngleCamera + add sp,12 + + mov eax, [CameraXr] + mov ebx, [CameraYr] + mov ecx, [CameraZr] + add ecx, camzoom + mov [CameraZr], ecx + + call LongInverseRot + + mov eax, [X0] + mov ebx, [Y0] + mov ecx, [Z0] + mov [CameraX], eax + mov [CameraY], ebx + mov [CameraZ], ecx + + ret + +SetFollowCamera endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÛßßß Ûßßßß ÛßßßÛ Ûßßßß Ûßßßß ÛÛÜ Û +; ßßßßÛ ÛÛ ÛÛßÛß ÛÛßß ÛÛßß ÛÛßÛÛ +; ßßßßß ßßßßß ßß ß ßßßßß ßßßßß ßß ß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +ifdef 0 + +Proj proc ; ax:X bx:Y bp:Z + + cmp word ptr[TypeProj], TYPE_ISO + jz projiso + + add bp, word ptr[KFactor] + js overflow +fixed: imul word ptr[LFactorX] ; X + idiv bp + add ax, word ptr[XCentre] + xchg ax, bx + neg ax + imul word ptr[LFactorY] ; -Y + idiv bp + add ax, word ptr[YCentre] + xchg ax, bx + ret ; AX:Xp BX:Yp + +overflow: mov bp, 32767 ; max value + jmp short fixed + +projiso: shl ecx, 16 ; save CX + + mov cx, ax ; save x + +; add ax, bp +; mov dx, 24 +; imul dx +; idiv word ptr[IsoScale] +; add ax, [XCentre] + + add ax, bp + movzx eax, ax + imul eax, 24 ; mettre decalages + sar eax, 9 + add ax, [XCentre] + + xchg cx, ax ; mov ax, cx et cx, ax + + neg bp + add ax, bp + +; shl eax, 2 ; *4 +; mov edx, eax ; =4 +; shl eax, 1 ; *8 +; add eax, edx ; *12 +; mov edx, eax +; shr edx, 16 ; dx high + + mov dx, 12 + imul dx + + idiv word ptr[IsoScale] + mov bp, ax + mov ax, 30 + imul bx + idiv word ptr[IsoScale] + sub ax, bp + neg ax + add ax, [YCentre] + + mov bx, ax + mov ax, cx + + shr ecx, 16 ; restore CX + + ret + +Proj endp + +endif + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +Proj_3D proc ; ax:X bx:Y bp:Z + + add bp, word ptr[KFactor] + js overflow +fixed: imul word ptr[LFactorX] ; X + idiv bp + add ax, word ptr[XCentre] + xchg ax, bx + neg ax + imul word ptr[LFactorY] ; -Y + idiv bp + add ax, word ptr[YCentre] + xchg ax, bx + ret ; AX:Xp BX:Yp + +overflow: mov bp, 32767 ; max value + jmp short fixed + +Proj_3D endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +Proj_ISO proc ; eax:X ebx:Y ebp:Z + + mov ecx, eax ; save x + + sub eax, ebp ; x + zrot + add ebp, ecx ; -(x - zrot) + + lea eax, [eax*8] ; *8 + mov edx, eax + lea eax, [edx+eax*2] ; *24 + + sar eax, 9 ; /512 IsoScale + + add ax, word ptr[XCentre] + + lea edx, [ebp*4] ; *4 + lea ebp, [edx+ebp*8] ; *12 + + lea ecx, [ebx+ebx] ; =*2 + shl ebx, 5 ; 32 + sub ebx, ecx ; y*30 + + sub ebx, ebp ; - (x-zrot) * 12 + + sar ebx, 9 ; /512 IsoScale + + neg bx + add bx, word ptr[YCentre] + + ret + +Proj_ISO endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +ProjettePoint proc uses ebx ebp ,\ + CoorX:DWORD,CoorY:DWORD,CoorZ:DWORD + + cmp [TypeProj], TYPE_ISO + jz projiso + + mov eax, CoorX + sub eax, [CameraXr] + mov ebx, CoorY + sub ebx, [CameraYr] + mov ecx, [CameraZr] + sub ecx, CoorZ + mov ebp, ecx + + or cx, cx + js error ; si Z0 < 0 clip +; cmp ax, cx ; si X0 > Z0 clip +; jg error +; cmp bx, cx ; si Y0 > Z0 clip +; jg error +; neg cx +; cmp ax, cx +; jl error +; cmp bx, cx +; jl error + + call Proj_3D + + mov [Xp], ax + mov [Yp], bx + + mov eax, -1 + ret + +projiso: mov eax, CoorX + mov ebx, CoorY + mov ebp, CoorZ + + call Proj_ISO + + mov [Xp], ax + mov [Yp], bx + + mov eax, -1 + ret + +error: xor eax, eax + mov [Xp], ax + mov [Yp], ax + ret + +ProjettePoint endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +LongProjettePoint proc uses ebx,\ + CoorX:DWORD,CoorY:DWORD,CoorZ:DWORD + + mov eax, CoorX + sub eax, [CameraXr] + mov ebx, CoorY + sub ebx, [CameraYr] + mov ecx, [CameraZr] + sub ecx, CoorZ + + or ecx, ecx + js error ; si Z0 < 0 clip + + add ecx, [KFactor] + ; js overflow + js error +fixed: imul [LFactorX] ; X + idiv ecx + add eax, [XCentre] + xchg eax, ebx + neg eax + imul [LFactorY] ; -Y + idiv ecx + add eax, [YCentre] + xchg eax, ebx + + cmp eax, 32767 ; check if more than 16 bits + jg OverX + cmp eax, -32768 + jl OverX +fixedX: + cmp ebx, 32767 + jg OverY + cmp ebx, -32768 + jl OverY +fixedY: + + mov [Xp], ax ; result + mov [Yp], bx + + mov eax, -1 + ret + +overX: shl eax, 1 + mov ax, 7FFFh + adc ax, 0 + jmp fixedX + +overY: shl ebx, 1 + mov bx, 7FFFh + adc bx, 0 + jmp fixedY + +;overflow: mov ecx, 7FFFFFFFh ; max value +; jmp short fixed + +error: xor eax, eax + mov [Xp], ax + mov [Yp], ax + ret + +LongProjettePoint endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +SetProjection proc ,\ + xc:DWORD, yc:DWORD ,\ + kfact:DWORD ,\ + lfactx:DWORD,lfacty:DWORD + + mov eax, xc + mov [XCentre], eax + + mov eax, yc + mov [YCentre], eax + + mov eax, kfact + mov [KFactor], eax + + mov eax, lfactx + mov [LFactorX], eax + + mov eax, lfacty + mov [LFactorY], eax + + mov word ptr[TypeProj], TYPE_3D + + ret + +SetProjection endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +SetIsoProjection proc ,\ + xc:DWORD, yc:DWORD ,\ + scale:DWORD + + mov eax, xc + mov [XCentre], eax + + mov eax, yc + mov [YCentre], eax + + mov eax, scale + mov [IsoScale], ax + + mov word ptr[TypeProj], TYPE_ISO + + ret + +SetIsoProjection endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +TestVuePoly proc uses edi ebx ebp,\ + ptrpoly:DWORD + + mov edi, ptrpoly + + mov bx,word ptr[edi+8] + sub bx,word ptr[edi+2] + + mov ax,word ptr[edi+4] + sub ax,word ptr[edi+16] + + imul bx + + mov bp,ax + mov bx,dx + + mov cx,word ptr[edi+10] + sub cx,word ptr[edi+4] + + mov ax,word ptr[edi+2] + sub ax,word ptr[edi+14] + + imul cx + + sub ax,bp ; oublie face si bx:bp < dx:ax + sbb dx,bx + jnl nopoly + + mov eax,1 + ret + +nopoly: xor eax,eax + ret + +TestVuePoly endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +CopyMatrice proc uses esi edi,\ + matsour:DWORD, matdest:DWORD + + mov esi, matsour + mov edi, matdest + mov ecx, 9 + rep movsd + ret + +CopyMatrice endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +FlipMatrice proc uses esi edi,\ + matsour:DWORD, matdest:DWORD + + mov esi, matsour + mov edi, matdest + + mov eax, [esi+LT00] + mov ecx, [esi+LT01] + mov edx, [esi+LT02] + mov [edi+LT00], eax + mov [edi+LT10], ecx + mov [edi+LT20], edx + + mov eax, [esi+LT10] + mov ecx, [esi+LT11] + mov edx, [esi+LT12] + mov [edi+LT01], eax + mov [edi+LT11], ecx + mov [edi+LT21], edx + + mov eax, [esi+LT20] + mov ecx, [esi+LT21] + mov edx, [esi+LT22] + mov [edi+LT02], eax + mov [edi+LT12], ecx + mov [edi+LT22], edx + + ret + +FlipMatrice endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + + END diff --git a/LIB386/LIB_CD/BUILD.BAT b/LIB386/LIB_CD/BUILD.BAT new file mode 100644 index 0000000..21a7179 --- /dev/null +++ b/LIB386/LIB_CD/BUILD.BAT @@ -0,0 +1,5 @@ +call watcom10 +pkunzip -o obj >NUL +wmake /f lib_CD.mak +pkzip -m obj *.obj >NUL +call watcom9 diff --git a/LIB386/LIB_CD/CDROM.ASM b/LIB386/LIB_CD/CDROM.ASM new file mode 100644 index 0000000..a3ed8ae --- /dev/null +++ b/LIB386/LIB_CD/CDROM.ASM @@ -0,0 +1,1124 @@ +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +comment @ + +' ÛÛÛÛÛÛ¿ ÛÛÛÛÛ¿ ÛÛÛÛÛÛ¿ ÛÛÛÛÛÛ¿ Û¿ Û¿ + ÛÛÚÄÄÄÙ ÛÛÚÄÛÛ¿ ÛÛÚÄÛÛ³ ÛÛÚÄÛÛ³ ÛÛ¿ ÛÛ³ +' ÛÛ³ ÛÛ³ ÛÛ³ ÛÛÛÛÛÛ³ ÛÛ³ ÛÛ³ ÛÛÛÛÛÛ³ + ÛÛ³ ÛÛ³ ÛÛ³ ÛÛÚÛÛÚÙ ÛÛ³ ÛÛ³ ÛÛÚÄÛÛ³ +' ÛÛÛÛÛÛ¿ ÛÛÛÛÛÚÙ ÛÛ³ÀÛÛ¿ ÛÛÛÛÛÛ³ ÛÛ³ ÛÛ³ +' ÀÄÄÄÄÄÙ ÀÄÄÄÄÙ ÀÄÙ ÀÄÙ ÀÄÄÄÄÄÙ ÀÄÙ ÀÄÙ +' +' 25 Juillet 1994 +' + (c) Adeline Software International 1994 +@ +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + JUMPS + .386P + .model SMALL, C + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + .data + public NoLanguage LeadOut + public NoLanguage LowTrack + public NoLanguage HigTrack + public NoLanguage BufferData + public NoLanguage CptTimeOut + public NoLanguage DriveCDR + + public NoLanguage FileCD_Start + public NoLanguage FileCD_Sect + public NoLanguage FileCD_Size + +TIME_OUT equ 10 + + +FileCD_Start dd 0 +FileCD_Sect dd 0 +FileCD_Size dd 0 + + +LowTrack db 0 +HigTrack db 0 +LeadOut dd 0 +DriveCDR dw -2 +BufferData db 1000 dup(0) +CptTimeOut dw 0 + +PtDosCD dd ? ;' Pointeur Prot sur Dos Mem +OffDosCd dw ? ;' Offset Real sur Dos Mem + +;----------------------------------' PtDosCD : Structure IOCTL + +I_LENHDR equ 0 ;' Byte 1 +I_SUBUNIT equ 1 ;' Byte 1 +I_COMMAND equ 2 ;' Byte 1 +I_STATUS equ 3 ;' Word 1 +I_RESERVED equ 5 ;' Byte 8 + +I_MEDIA equ 13 ;' Byte 1 +I_TRANSPTR equ 14 ;' Long 1 +I_NBBYTE equ 18 ;' Word 1 +I_STARTING equ 20 ;' Word 1 +I_PTRREQUEST equ 22 ;' Long 1 +I_DUMM equ 26 ;' Byte 500 + +;----------------------------------' PtDosCD : End IOCTL, Begin BUFFERDATA + +I_BUFFERDATA equ 540 ;' Byte 1000 +I_SIZE equ 1540 + +;----------------------------------' PtDosCD : End BUFFERDATA + +RMI equ $ +RMI_EDI dd 0 +RMI_ESI dd 0 +RMI_EBP dd 0 +RMI_RESERVED dd 0 +RMI_EBX dd 0 +RMI_EDX dd 0 +RMI_ECX dd 0 +RMI_EAX dd 0 +RMI_flags dw 0 +RMI_ES dw 0 +RMI_DS dw 0 +RMI_FS dw 0 +RMI_GS dw 0 +RMI_IP dw 0 +RMI_CS dw 0 +RMI_SP dw 0 +RMI_SS dw 0 + + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + .code + + public NoLanguage InitCDR + public NoLanguage ClearCDR + public NoLanguage GetCopyrightName + public NoLanguage Red2Hsg + public NoLanguage GetLengthTrackCDR + public NoLanguage StartTrackCDR + public NoLanguage ResumeCDR + public NoLanguage EjectCDR + public NoLanguage CloseTrayCDR + public NoLanguage LockCDR + public NoLanguage UnLockCDR + public NoLanguage StatusCDR + public NoLanguage GetMusicCDR + public NoLanguage ResetCDR + public NoLanguage ControlCDR + public NoLanguage LocateHeadCDR + public NoLanguage PlayCDR + public NoLanguage StopCDR + public NoLanguage PlayTrackCDR + public NoLanguage ReadLongCDR + public NoLanguage GetBitCDR + public NoLanguage WaitDisk +;' public NoLanguage TestCDROM + public NoLanguage GetFileCDR + + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +TalkCDR_O proc uses ebx es + + mov ebx, [PtDosCD] + mov word ptr [ebx+I_STATUS], 0 + + mov RMI_EAX, 1510h + + movzx eax, DriveCDR + mov RMI_ECX, eax + + mov bx, [OffDosCD] + mov RMI_ES, bx + mov RMI_EBX, 0 + + mov ax, ds + mov es, ax + mov edi, offset RMI + mov ax, 300h + mov bx, 2fh + int 31h + + mov ebx, [PtDosCD] + mov eax, [ebx+I_STATUS] + + ret +TalkCDR_O endp + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +AudioInfoCDR proc uses ebx + + mov [CptTimeOut], TIME_OUT + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 13 ;' Longueur Command + mov byte ptr [ebx+I_COMMAND], 3 ;' Command Input + mov word ptr [ebx+I_NBBYTE], 7 ;' Nb Byte Sub Funct + + mov ax, I_BUFFERDATA + mov [ebx+I_TRANSPTR], ax ;' Offset + mov ax, [OffDosCD] + mov [ebx+I_TRANSPTR+2], ax ;' Segment + + mov byte ptr [ebx+I_BUFFERDATA], 10 ;' Audio Info + +Retry: call TalkCDR_O + test ax, 8000h + jz NoError + dec [CptTimeOut] + jne Retry + xor ax, ax + ret +NoError: + mov ebx, [PtDosCD] + + mov al, [ebx+I_BUFFERDATA+1] + mov ah, [ebx+I_BUFFERDATA+2] + + mov [LowTrack], al + mov [HigTrack], ah + + mov eax, [ebx+I_BUFFERDATA+3] + mov [LeadOut], eax + mov ax, 1 + ret +AudioInfoCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +WaitDisk proc + local timeout:DWORD + + mov [timeout], 256*3 +Again: + call StatusCDR + test ax, 100000000000b ;' Disk Present ? + je OkDisk + dec [timeout] + jne Again +OkDisk: + xor ax, ax + ret +WaitDisk endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +InitCDR proc uses es esi edi ebx,\ + nameid:DWORD + + local nbcddrive:WORD + local listdrive[26]:BYTE + local lennameid:DWORD + local save_ecx:DWORD + local timeout:DWORD + + mov [DriveCDR], -2 ;' Default No CD Drive + + xor bx, bx + mov ax, 1500h ;' Get Drive Number + int 2Fh + + or bx, bx + je NoCDRom + + mov [nbcddrive], bx + mov [DriveCDR], cx + +;----------------------'Init PtDosCD en Mem Dos par DPMI + + mov eax, 0100h ;' Dmpi Alloc Mem Dos + mov ebx, 128 ;' 2048 ( 128*16 ) + int 31h + + mov [OffDosCD], ax + shl eax, 4 ;' Con real->Prot + mov [PtDosCD], eax + +;----------------------'Calcul Taille nameid + + mov edi, nameid ;' Len of nameid + + mov ecx, 0FFh + xor al, al + repne scasb ;' Size+1 of nameid + sub ecx, 0FFh + neg ecx + dec ecx ;' Without 0 for "" + mov [lennameid], ecx + +;----------------------'Recup List CD Drive & Copy in listdrive + + mov RMI_EAX, 150Dh ;' Get List CD Drive + mov bx, [OffDosCD] + mov RMI_ES, bx + mov RMI_EBX, 0 + + mov ax, ds + mov es, ax + mov edi, offset RMI + mov ax, 300h + mov bx, 2fh + int 31h ;' ES:BX List Letter + + mov cx, [nbcddrive] + mov esi, [PtDosCD] + lea edi, listdrive + rep movsb ;' Save List CD Drive + +;----------------------'Scan des lecteurs CD pour trouver nameid + + lea ebx, listdrive + xor ecx, ecx +NextCDDrive: + mov [save_ecx], ecx + + xor eax, eax + + mov al, [ebx+ecx] ;' Recup Drive Letter + mov [DriveCDR], ax + + call CloseTrayCDR ;' CLOSETRAYCDR + jne NotGoodOne ; + + call WaitDisk ;' WAITDISK + jne NotGoodOne + + call LockCDR ;' LOCKCDR + call StopCDR ;' STOPCDR + + call StatusCDR ;' STATUSCDR 1ere + test ax, 8000h ;' Error + je NoError + + call ResetCDR ;' RESETCDR + + call StatusCDR ;' STATUSCDR 2eme + test ax, 8000h + jne NotGoodOne + +NoError: + jne NotGoodOne ;' Can t close + + cmp [lennameid], 0 + je TheGoodOne ;' No Copyright test + + call GetCopyrightName ;' GETCOPYRIGHTNAME + + mov esi, eax ;' Copyright Name + mov edi, nameid + mov ecx, [lennameid] + + rep cmpsb ;' Compar with Copyright + je TheGoodOne +NotGoodOne: + call UnLockCDR + mov ecx, [save_ecx] + inc ecx + cmp cx, [nbcddrive] + jne NextCDDrive + + jmp NoCDRom + +;----------------------'GOTCHA :-) +TheGoodOne: + call StatusCDR + test ax, 2048 ;' Pas de CD + jne NoCDRom +GetAudio: + call AudioInfoCDR + or ax, ax + je GetAudio ;' Ca doit passer! + + mov eax, 1 + ret +NoCDRom: + cmp [DriveCDR], -2 ;' No CD Drive + je ContError + mov [DriveCDR], -1 ;' No Adeline CD +ContError: + call UnLockCDR ;' UNLOCKCDR + xor eax, eax ;' No CDRom + ret +InitCDR endp + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ClearCDR proc + call StopCDR + call UnLockCDR + call ResetCDR + ret +ClearCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +GetCopyrightName proc uses ebx + + mov RMI_EAX, 1502h ;' Get List CD Drive + mov bx, [OffDosCD] + mov RMI_ES, bx + mov RMI_EBX, 0 + + mov ax, ds + mov es, ax + mov edi, offset RMI + mov ax, 300h + mov bx, 2fh + int 31h ;' ES:BX List Letter + + mov eax, [PtDosCD] + ret + +GetCopyrightName endp + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Red2Hsg proc ,\ + value:DWORD + + mov eax, value + + and eax, 00FF0000h ;' Recup Min + shr eax, 14 ;' Normal 16 mais... + mov edx, eax ;' ebx=v*4 + + shl eax, 4 ;' *64 ( eh oui! ) + sub eax, edx ;' min*60 + + mov edx, value + + and edx, 0000FF00h ;' Recup Sec + shr edx, 8 ;' >> 8 + add eax, edx ;'min*60+sec + + mov edx, 75 ;' flemme decalage :-( + imul edx ;'(min*60+sec)*75 + + mov edx, value + and edx, 000000FFh ;' Recup frame (100e) + + add eax, edx ;'(min*60+sec)*75+frame + + ret +Red2Hsg endp + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +GetLengthTrackCDR proc uses ebx,\ + track:DWORD + + local begin:DWORD + + mov ecx, [track] + + push ecx + call StartTrackCDR ;' b = Debut Track + pop ecx + + mov [begin], eax + + mov ebx, [LeadOut] + cmp cl, [HigTrack] + jge OkLastOne + + inc ecx + + push ecx + call StartTrackCDR ;' e = Debut Track+1 + add esp, 4 + + mov ebx, eax +OkLastOne: + push ebx + call Red2Hsg + mov ebx, eax + + push [begin] + call Red2Hsg + add esp, 8 + + sub ebx, eax ;' R2H(b)-R2H(e) + mov eax, ebx + + ret +GetLengthTrackCDR endp + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +StartTrackCDR proc uses ebx,\ + Track:DWORD + + mov [CptTimeOut], TIME_OUT + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 13 ;' Longueur Command + mov byte ptr [ebx+I_COMMAND], 3 ;' Command Input + mov word ptr [ebx+I_NBBYTE], 7 ;' Nb Byte Sub Funct + + mov ax, I_BUFFERDATA + mov word ptr [ebx+I_TRANSPTR], ax + mov ax, [OffDosCD] + mov word ptr [ebx+I_TRANSPTR+2], ax + + mov byte ptr [ebx+I_BUFFERDATA], 11 ;' Audio Info + mov eax, Track + mov byte ptr [ebx+I_BUFFERDATA+1], al +Retry: + call TalkCDR_O + test ax, 8000h + jz NoError + dec [CptTimeOut] + jne Retry +NoError: + mov ebx, [PtDosCD] + mov eax, dword ptr [ebx+I_BUFFERDATA+2] + + ret +StartTrackCDR endp + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ResumeCDR proc uses ebx + + mov [CptTimeOut], TIME_OUT + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 13 + mov byte ptr [ebx+I_COMMAND], 136 +Retry: + call TalkCDR_O + test ax, 8000h ;' Bit 15 + jz NoError + dec [CptTimeOut] + jne Retry +NoError: + ret +ResumeCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +EjectCDR proc uses ebx + + mov [CptTimeOut], TIME_OUT + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 13 ;' Longueur Command + mov byte ptr [ebx+I_COMMAND], 12 ;' Command IOCTLO + mov word ptr [ebx+I_NBBYTE], 1 ;' Nb Byte Sub Funct + + mov ax, I_BUFFERDATA + mov word ptr [ebx+I_TRANSPTR], ax + mov ax, [OffDosCD] + mov word ptr [ebx+I_TRANSPTR+2], ax + + mov byte ptr [ebx+I_BUFFERDATA], 0 ;' Command Eject +Retry: + call TalkCDR_O + test ax, 8000h + jz NoError + dec [CptTimeOut] + jne Retry +NoError: + ret +EjectCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +CloseTrayCDR proc uses ebx + local timeout:DWORD + + call StatusCDR + test ax, 1 ;' Door + je OkRoule ;' Aready Closed! + +;------------------------------------------------------- + + mov [CptTimeOut], TIME_OUT + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 13 ;' Longueur Command + mov byte ptr [ebx+I_COMMAND], 12 ;' Command IOCTLO + mov word ptr [ebx+I_NBBYTE], 1 ;' Nb Byte Sub Funct + + mov ax, I_BUFFERDATA + mov word ptr [ebx+I_TRANSPTR], ax + mov ax, [OffDosCD] + mov word ptr [ebx+I_TRANSPTR+2], ax + + mov byte ptr [ebx+I_BUFFERDATA], 5 ;' Command CloseTray +Retry: + call TalkCDR_O + test ax, 8000h + jz NoError + dec [CptTimeOut] + jne Retry + ret +NoError: +;------------------------------------------------------- + mov [timeout], 512 +Again_0: + call StatusCDR + test ax, 1b ;' Door + je OkRoule + dec [timeout] + jne Again_0 +;------------------------------------------------------- + ret +OkRoule: + xor eax, eax + ret +CloseTrayCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LockCDR proc + + mov [CptTimeOut], TIME_OUT + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 13 ;' Longueur Command + mov byte ptr [ebx+I_COMMAND], 12 ;' Command IOCTLO + mov word ptr [ebx+I_NBBYTE], 2 ;' Nb Byte Sub Funct + + mov ax, I_BUFFERDATA + mov word ptr [ebx+I_TRANSPTR], ax + mov ax, [OffDosCD] + mov word ptr [ebx+I_TRANSPTR+2], ax + + mov byte ptr [ebx+I_BUFFERDATA], 1 ;' Command Lock Unlock + mov byte ptr [ebx+I_BUFFERDATA+1], 1;' Lock +Retry: + call TalkCDR_O + test ax, 8000h + jz NoError + dec [CptTimeOut] + jne Retry +NoError: + ret +LockCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +UnLockCDR proc uses ebx + + mov [CptTimeOut], TIME_OUT + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 13 ;' Longueur Command + mov byte ptr [ebx+I_COMMAND], 12 ;' Command IOCTLO + mov word ptr [ebx+I_NBBYTE], 2 ;' Nb Byte Sub Funct + + mov ax, I_BUFFERDATA + mov word ptr [ebx+I_TRANSPTR], ax + mov ax, [OffDosCD] + mov word ptr [ebx+I_TRANSPTR+2], ax + + mov byte ptr [ebx+I_BUFFERDATA], 1 ;' Command Lock Unlock + mov byte ptr [ebx+I_BUFFERDATA+1], 0;' Lock +Retry: + call TalkCDR_O + test ax, 8000h + jz NoError + dec [CptTimeOut] + jne Retry +NoError: + ret +UnLockCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +StatusCDR proc uses ebx + + mov [CptTimeOut], TIME_OUT + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 13 ;' Longueur Command + mov byte ptr [ebx+I_COMMAND], 3 ;' Command IOCTLI + mov word ptr [ebx+I_NBBYTE], 5 ;' Nb Byte Sub Funct + + mov ax, I_BUFFERDATA + mov word ptr [ebx+I_TRANSPTR], ax + mov ax, [OffDosCD] + mov word ptr [ebx+I_TRANSPTR+2], ax + + mov byte ptr [ebx+I_BUFFERDATA], 6 ;' Command Status + mov dword ptr [ebx+I_BUFFERDATA+1], 0;' Status +Retry: + call TalkCDR_O + test ax, 8000h + jz NoError + dec [CptTimeOut] + jne Retry + xor eax, eax + ret +NoError: + mov ebx, [PtDosCD] + movzx eax, word ptr [ebx+I_BufferData+1] + ret + +StatusCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +GetMusicCDR proc uses ebx + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 13 ;' Longueur Command + mov byte ptr [ebx+I_COMMAND], 3 ;' Command IOCTLI + mov word ptr [ebx+I_NBBYTE], 11 ;' Nb Byte Sub Funct + + mov ax, I_BUFFERDATA + mov word ptr [ebx+I_TRANSPTR], ax + mov ax, [OffDosCD] + mov word ptr [ebx+I_TRANSPTR+2], ax + + mov byte ptr [ebx+I_BUFFERDATA], 0Ch;' Locate Head +Retry: + call TalkCDR_O + test ax, 8000h + jz NoError +NoPlay: + xor eax, eax + ret +NoError: + mov ebx, [PtDosCD] + test ax, 200h ;' Buzy + jz NoPlay + movzx eax, byte ptr [ebx+I_BufferData+2];' Num Track + ret + +GetMusicCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +GetBitCDR proc uses ebx + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 13 ;' Longueur Command + mov byte ptr [ebx+I_COMMAND], 3 ;' Command IOCTLI + mov word ptr [ebx+I_NBBYTE], 5 ;' Nb Byte Sub Funct + + mov ax, I_BUFFERDATA + mov word ptr [ebx+I_TRANSPTR], ax + mov ax, [OffDosCD] + mov word ptr [ebx+I_TRANSPTR+2], ax + + mov byte ptr [ebx+I_BUFFERDATA], 6 ;' Command Status + mov dword ptr [ebx+I_BUFFERDATA+1], 0;' Status + + call TalkCDR_O + + ret +GetBitCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ResetCDR proc uses ebx + + mov [CptTimeOut], TIME_OUT + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 26 ;' Longueur Command + mov byte ptr [ebx+I_COMMAND], 12 ;' Command IOCTLO + mov word ptr [ebx+I_NBBYTE], 1 ;' Nb Byte Sub Funct + + mov ax, I_BUFFERDATA + mov word ptr [ebx+I_TRANSPTR], ax + mov ax, [OffDosCD] + mov word ptr [ebx+I_TRANSPTR+2], ax + + mov byte ptr [ebx+I_BUFFERDATA], 2 ;' Command Reset +Retry: + call TalkCDR_O + test ax, 8000h + jz NoError + dec [CptTimeOut] + jne Retry +NoError: + ret +ResetCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ControlCDR proc uses ebx,\ + chan0:WORD, vol0:WORD, chan1:WORD, vol1:WORD + + + mov [CptTimeOut], TIME_OUT + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 13 ;' Longueur Command + mov byte ptr [ebx+I_COMMAND], 12 ;' Command IOCTLO + mov word ptr [ebx+I_NBBYTE], 9 ;' Nb Byte Sub Funct + + mov ax, I_BUFFERDATA + mov word ptr [ebx+I_TRANSPTR], ax + mov ax, [OffDosCD] + mov word ptr [ebx+I_TRANSPTR+2], ax + + mov byte ptr [ebx+I_BUFFERDATA], 3 ;' Command Control + mov ax, chan0 + mov byte ptr [ebx+I_BUFFERDATA+1], al + mov ax, vol0 + mov byte ptr [ebx+I_BUFFERDATA+2], al + mov ax, chan1 + mov byte ptr [ebx+I_BUFFERDATA+3], al + mov ax, vol1 + mov byte ptr [ebx+I_BUFFERDATA+4], al +Retry: + call TalkCDR_O + test ax, 8000h + jz NoError + dec [CptTimeOut] + jne Retry +NoError: + ret +ControlCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LocateHeadCDR proc uses ebx + + mov [CptTimeOut], TIME_OUT + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 13 ;' Longueur Command + mov byte ptr [ebx+I_COMMAND], 3 ;' Command Input + mov word ptr [ebx+I_NBBYTE], 6 ;' Nb Byte Sub Funct + mov byte ptr [ebx+I_MEDIA], 1 ;' Mode Red Book + + mov ax, I_BUFFERDATA + mov word ptr [ebx+I_TRANSPTR], ax + mov ax, [OffDosCD] + mov word ptr [ebx+I_TRANSPTR+2], ax + + mov byte ptr [ebx+I_BUFFERDATA], 1 ;' Command Locate + mov byte ptr [ebx+I_BUFFERDATA+1], 0;' Mode Address +Retry: + call TalkCDR_O + test ax, 8000h + jz NoError + dec [CptTimeOut] + jne Retry +NoError: + mov ebx, [PtDosCD] + mov eax, dword ptr [ebx+I_BUFFERDATA+2] + ret +LocateHeadCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +PlayCDR proc uses ebx,\ + Debut:DWORD, Duree:DWORD + + mov [CptTimeOut], TIME_OUT + + mov ebx, [PtDosCD] +Retry: + mov byte ptr [ebx+I_LENHDR], 26 ;' Len + mov byte ptr [ebx+I_COMMAND], 132 ;' Play + mov byte ptr [ebx+I_MEDIA], 1 ;' Mode Red Book +;----------------------- + mov eax, Duree + mov dword ptr [ebx+I_NBBYTE], eax + + mov eax, Debut + mov dword ptr [ebx+I_TRANSPTR], eax +;----------------------- + call TalkCDR_O + test ax, 200h ;' Buzy bit 9 + jnz Ok + + dec word ptr [CptTimeOut] + jne Retry + + mov eax, 1 + ret +Ok: + xor eax, eax + ret +PlayCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +StopCDR proc uses ebx + + mov [CptTimeOut], TIME_OUT + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 13 + mov byte ptr [ebx+I_COMMAND], 133 +Retry: + call TalkCDR_O + test ax, 8000h ;' Bit 15 + jz NoError + dec [CptTimeOut] + jne Retry +NoError: + ret +StopCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +PlayTrackCDR proc uses ebx,\ + Track:DWORD + + local len:DWORD + + push [track] + call GetLengthTrackCDR + add esp, 4 + mov [len], eax + + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 13 ;' Longueur Command + mov byte ptr [ebx+I_COMMAND], 3 ;' Command Input + mov word ptr [ebx+I_NBBYTE], 7 ;' Nb Byte Sub Funct + + mov ax, I_BUFFERDATA + mov word ptr [ebx+I_TRANSPTR], ax + mov ax, [OffDosCD] + mov word ptr [ebx+I_TRANSPTR+2], ax + + mov byte ptr [ebx+I_BUFFERDATA], 11 ;' Audio Info + mov eax, Track + mov byte ptr [ebx+I_BUFFERDATA+1], al +Retry: + call TalkCDR_O + test ax, 8000h + jz NoError + dec [CptTimeOut] + jne Retry + ret +NoError: + push [len] + mov eax, dword ptr [ebx+I_BUFFERDATA+2] + push eax + call PlayCDR + add esp, 8 + + ret +PlayTrackCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +comment @ +TestCDROM proc uses ebx + + xor eax, eax + mov ebx, 1 + + push eax + push [PtDosCD] + push ebx + push eax + call ReadLongCDR + add esp, 4*4 + or eax, eax + je NoError + xor eax, eax + ret +NoError: + mov eax, 1 + ret +TestCDROM endp +@ +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ReadLongCDR proc uses es esi edi ebx,\ + Start:DWORD, \ + NbSect:DWORD, \ + BufferTrans:DWORD + + mov [CptTimeOut], TIME_OUT +Error: + mov ebx, [PtDosCD] + + mov byte ptr [ebx+I_LENHDR], 27 ;' 27 Len + mov byte ptr [ebx+I_SUBUNIT], 0 ;' Drive + mov byte ptr [ebx+I_COMMAND], 128 ;' Read_L + mov word ptr [ebx+I_STATUS], 0 ;' Status +;--------------------------------------------------------------- + mov byte ptr [ebx+I_MEDIA], 0 ;' Mode HSG +;--------------------------------------------------------------- + mov eax, BufferTrans ;' Addresse Dest + shr eax, 4 ;' Prot->Real + mov word ptr [ebx+I_TRANSPTR], 0 + mov word ptr [ebx+I_TRANSPTR+2], ax +;--------------------------------------------------------------- + mov eax, NbSect ;' Nb Sector + mov word ptr [ebx+I_TRANSPTR+4], ax +;--------------------------------------------------------------- + mov eax, Start ;' Start Sector + mov dword ptr [ebx+I_TRANSPTR+6], eax +;--------------------------------------------------------------- + mov byte ptr [ebx+I_TRANSPTR+10], 0 ;' Mode Cooked + mov word ptr [ebx+I_TRANSPTR+11], 0 ;' Interl Size+Skip +;--------------------------------------------------------------- + + mov RMI_EAX, 1510h + movzx eax, DriveCDR + mov RMI_ECX, eax + mov bx, [OffDosCD] + mov RMI_ES, bx + mov RMI_EBX, 0 + mov ax, ds + mov es, ax + mov edi, offset RMI + mov ax, 300h + mov bx, 2fh + int 31h + mov ebx, [PtDosCD] + mov ax, word ptr [ebx+I_STATUS] + + test ax, 8000h + jz NoError + dec [CptTimeOut] + jne Error + ret +NoError: + xor eax, eax + ret +ReadLongCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +GetFileCDR proc uses esi edi ebx,\ + NameF:DWORD + +;-------------------------------------------- + mov edi, NameF + mov ecx, 0FFh + xor al, al + repne scasb ;' Size+1 of nameid + sub ecx, 0FFh + neg ecx + mov esi, NameF + mov edi, [PtDosCD] + rep movsb ;' Copy NameF low mem +;-------------------------------------------- + + mov RMI_EAX, 150Fh + movzx eax, DriveCDR + mov ah, 1 ;' + mov RMI_ECX, eax + movzx ebx, [OffDosCD] + mov RMI_ES, bx ;' ES:BX File Name + mov RMI_EBX, 0 + + mov RMI_ESI, ebx ;' Segment + mov RMI_EDI, 1024 ;' Offset + + mov edi, offset RMI + mov ax, 300h + mov bx, 2fh + int 31h +;-------------------------------------------------------- + + mov eax, RMI_EAX + + test ax, 8000h + jnz Error + + + mov ebx, [PtDosCD] + add ebx, 1024 + + inc ebx + mov eax, [ebx] + mov [FileCD_Start], eax + add ebx, 6 + mov eax, [ebx] + mov [FileCD_Size], eax + + add eax, 2048 + shr eax, 11 ; (Size+2048)/2048 + mov [FileCD_Sect], eax + + ret +Error: + xor eax, eax + ret + +GetFileCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ifdef DEBUG +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +OpenCDR proc + mov byte ptr LenHDR, 13 + mov byte ptr Command, 13 +Retry: call TalkCDR_O + test ax, 8000h ; Bit 15 + jz NoError + jmp Retry +NoError: ret +OpenCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +CloseCDR proc + mov byte ptr LenHDR, 13 + mov byte ptr Command, 14 +Retry: call TalkCDR_O + test ax, 8000h ; Bit 15 + jz NoError + jmp Retry +NoError: ret +CloseCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +SeekCDR proc ,\ + DebutL:WORD, DebutH:WORD + + mov byte ptr LenHdr, 24 + mov byte ptr Command, 131 + mov byte ptr Media, 1 + mov ax, DebutL + mov word ptr [Starting], ax + mov ax, DebutH + mov word ptr [Starting+2], ax +Retry: call TalkCDR_O + test ax, 8000h ; Bit 15 + jz NoError + jmp Retry +NoError: ret +SeekCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +GetFileCDR proc uses esi edi ebx,\ + NameF:DWORD, LowBuffer:DWORD + +;-------------------------------------------- + mov edi, NameF + mov ecx, 0FFh + xor al, al + repne scasb ;' Size+1 of nameid + sub ecx, 0FFh + neg ecx + mov esi, NameF + mov edi, [PtDosCD] + rep movsb ;' Copy NameF low mem +;-------------------------------------------- + + mov RMI_EAX, 150Fh + movzx eax, DriveCDR + mov ah, 1 ;' + mov RMI_ECX, eax + mov bx, [OffDosCD] + mov RMI_ES, bx ;' ES:BX File Name + mov RMI_EBX, 0 + + mov eax, LowBuffer + shr eax, 4 ;' Prot -> Real + + mov RMI_ESI, eax ;' Segment + shr eax, 16 ;' Zero, i know :-[ + mov RMI_EDI, eax ;' Offset + + mov edi, offset RMI + mov ax, 300h + mov bx, 2fh + int 31h +;-------------------------------------------------------- + + mov eax, RMI_EAX + ret + +GetFileCDR endp +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +endif +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +; The + End + + + + + + + + + + + + + + + diff --git a/LIB386/LIB_CD/LIB_CD.H b/LIB386/LIB_CD/LIB_CD.H new file mode 100644 index 0000000..8666187 --- /dev/null +++ b/LIB386/LIB_CD/LIB_CD.H @@ -0,0 +1,79 @@ + +//---------------------------------------------------------------------------- + + +#pragma library ("f:\projet\lib386\lib_cd\lib_cd.lib"); + + +extern WORD BufferData[] ; +extern WORD DriveCDR ;// Lettre drive 0=A 1=B etc. apres InitCDR +extern ULONG LeadOut ; +extern UBYTE LowTrack, HigTrack ; +extern LONG FileCD_Start ; +extern LONG FileCD_Sect ; +extern LONG FileCD_Size ; + +//---------------------------------------------------------------------------- +// Initialiser le lesteur de cdrom, si pas verif alors chaine vide +LONG InitCDR( char *nameid ) ; + +// Jouer seulement une track pr‚cise +LONG PlayTrackCDR( LONG track ) ; + +// Arreter le PlayTrackCDR +void StopCDR() ; + +// Verouiller ou d‚verouiller la porte du lecteur +void LockCDR() ; +void UnLockCDR() ; + +// Reset, Init ou suite a une erreur par exemple +void ResetCDR() ; + +// Ejecter le cdrom quand c'est possible ( pas toujours motoris‚ ) +void EjectCDR() ; + +// Fermer tiroir electrique quand c'est possible ( pas toujours motoris‚ ) +void CloseTrayCDR() ; + +// Reprends une track apres un stopCDR +void ResumeCDR() ; + +//-------------------------------------- Fonction bas niveau + +// Return pointeur sur Copyright File name ( pas forcement file ) +char *GetCopyrightName() ; + +// Conversion Red to Hsg ( belle jambe non ;-) ) +LONG Red2Hsg( LONG value ) ; + +// Return la taille d'une track en HSG +LONG GetLengthTrackCDR( LONG track ) ; + +// Return secteur depart Track +LONG StartTrackCDR( LONG track ) ; + +// Return status of CD Drive +LONG StatusCDR() ; + +// Return Track currently play or 0 +LONG GetMusicCDR() ; + +// Change volume selon chanel +void ControlCDR( WORD chan0, WORD vol0, WORD chan1, WORD vol1 ) ; + +// Return position de la tete +LONG LocateHeadCDR() ; + +// Play a part of cd +LONG PlayCDR( LONG debut, LONG duree ); + +// Lecture data +LONG ReadLongCDR( LONG start, LONG nbsect, void *buffer ) ; + +// Get Directory Entry +LONG GetFileCDR( char *name ) ; + +//---------------------------------------------------------------------------- + + diff --git a/LIB386/LIB_CD/LIB_CD.MAK b/LIB386/LIB_CD/LIB_CD.MAK new file mode 100644 index 0000000..c238c83 --- /dev/null +++ b/LIB386/LIB_CD/LIB_CD.MAK @@ -0,0 +1,31 @@ + +TASMFLAGS = /m2 /mx /q /p /z /t /jMASM51 /jQUIRKS +WCFLAGS = /l=dos4g /oaxet /s /zp2 /5s /c /x /zq +WLIBFLAGS = -b -n -c -q + +OBJETS1 = cdrom.obj +OBJETS2 = +OBJETS3 = +OBJETS4 = + +LIB = LIB_CD + +$(LIB).LIB: $(OBJETS1) $(OBJETS2) $(OBJETS3) $(OBJETS4) + @echo $(OBJETS1) > clibmak.rsp +# @echo $(OBJETS2) >> clibmak.rsp +# @echo $(OBJETS3) >> clibmak.rsp +# @echo $(OBJETS4) >> clibmak.rsp + + @WLIB $(WLIBFLAGS) $(LIB) @clibmak.rsp + @del clibmak.rsp + @prntitre G "$(LIB)" + +.asm.obj: + @PRNTITRE M "$*.ASM" + @TASM $(TASMFLAGS) $*; + +.c.obj: + @PRNTITRE M "$*.C" + @wcl386 $(WCFLAGS) $* + + diff --git a/LIB386/LIB_CD/M.BAT b/LIB386/LIB_CD/M.BAT new file mode 100644 index 0000000..9ef9604 --- /dev/null +++ b/LIB386/LIB_CD/M.BAT @@ -0,0 +1,2 @@ +build + diff --git a/LIB386/LIB_MENU/ASM_SORT.ASM b/LIB386/LIB_MENU/ASM_SORT.ASM new file mode 100644 index 0000000..422d875 --- /dev/null +++ b/LIB386/LIB_MENU/ASM_SORT.ASM @@ -0,0 +1,41 @@ + .386P + .model SMALL, SYSCALL + +;---------------------------------------------------------------------------- + .data +;---------------------------------------------------------------------------- + +public NoLanguage MySortCompFunc + +strcmp proto SYSCALL + + .code + +;//------------------------------------------------------------------------- + +MySortCompFunc proc uses ebx ecx edx esi edi ebp,\ + ptra:DWORD, ptrb:DWORD + + mov eax, ptrb + mov ecx, ptra + push [eax] + push [ecx] + + call strcmp + + add esp, 8 + + ret + +MySortCompFunc endp + +;---------------------------------------------------------------------------- +; The + End + + + + + + + diff --git a/LIB386/LIB_MENU/BUILD.BAT b/LIB386/LIB_MENU/BUILD.BAT new file mode 100644 index 0000000..3b9991b --- /dev/null +++ b/LIB386/LIB_MENU/BUILD.BAT @@ -0,0 +1,13 @@ +call watcom10 + +pkunzip -o obj >NUL +wmake +pkzip -m obj *.obj >NUL + +call watcom9 + +pkunzip -o obj9 >NUL +wmake WATCOM9=yes +pkzip -m obj9 *.obj >NUL + +call watcom10 diff --git a/LIB386/LIB_MENU/LIB_MENU.H b/LIB386/LIB_MENU/LIB_MENU.H new file mode 100644 index 0000000..6ad9687 --- /dev/null +++ b/LIB386/LIB_MENU/LIB_MENU.H @@ -0,0 +1,157 @@ +#ifdef WATCOM9 +#pragma library ("f:\projet\lib386\lib_menu\lb9_menu.lib"); +#else +#pragma library ("f:\projet\lib386\lib_menu\lib_menu.lib"); +#endif + +#define SELECT_NO_FLAG 0 +#define SELECT_SHOW_EXT 1 +#define SELECT_TEST_EXIST 2 +#define SELECT_TEST_OVERWRITE 4 +#define SELECT_KEEP_POS 8 + +#define NO_FLAG 0 +#define FLAG_PUSHED 0x0001 +#define FLAG_RED 0x0002 +#define FLAG_NO_PUSH 0x0004 +#define FLAG_CENTRE 0x0100 +#define FLAG_CONTOUR 0x0200 +#define FLAG_FILENAME 0x0400 + +#define TYPE_TEXT 0x0001 +#define TYPE_BUTTON 0x0002 +#define TYPE_WINDOW 0x0004 +#define TYPE_SWITCH 0x0008 +#define TYPE_CHANGE_VALUE 0x0010 +#define TYPE_DEC_VALUE 0x0020 +#define TYPE_INC_VALUE 0x0040 + +extern UBYTE SelectorPathname[] ; + +typedef struct { WORD X1 ; /* size/pos pixel box */ + WORD Y1 ; + WORD X2 ; + WORD Y2 ; + + WORD Type ; + WORD Flags ; /* texte centr‚... */ + + WORD Handle ; /* info retourn‚e si != -1 */ + UBYTE *PtrString ; + + WORD *PtrVar ; /* info switch */ + WORD Mask ; + + } T_CLICK_BOX ; + + +typedef struct { WORD NbBox ; + WORD LastClicked ; + T_CLICK_BOX *PtrMallocList ; + + WORD Largeur ; /* en caractere */ + WORD Hauteur ; + + WORD X1 ; + WORD Y1 ; + WORD X2 ; + WORD Y2 ; + + WORD Flags ; + + WORD Repeat ; + + } T_MENU ; + +typedef struct { WORD WindowX1 ; + WORD WindowY1 ; + WORD WindowX2 ; + WORD WindowY2 ; + WORD WindowLig ; + WORD WindowCol ; + WORD WindowTab ; + WORD WindowNbIndex ; + UBYTE **WindowArray ; + + } T_WINLIST ; + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +#define B_GRIS 1 +#define B_ROUGE 4 + +#define BLEU 9 +#define VERT 10 +#define CYAN 11 +#define ROUGE 12 +#define MAGENTA 13 +#define JAUNE 14 +#define BLANC 15 + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/* asm_sort.asm */ + +extern int MySortCompFunc( char**, char** ) ; + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/* menu.c */ + +extern void SetMenuAutoPal(short ); +extern void InitPalMenu(void); +extern void CopyPalMenu(unsigned char *); +extern void DrawWindow(long ,long ,long ,long ,long ); +extern void OpenWindow(T_WINLIST *,short ,short ,short ,short ); +extern void GetWindowButton(T_MENU *,short ,T_WINLIST *); +extern void WinText(T_WINLIST *,unsigned char *,long ); +extern void WinList(T_WINLIST *,unsigned char **,short ,short ); +extern void WinSelect(T_WINLIST *,short ,short ); +extern void WinSepar(T_WINLIST *); +extern void FlipWindow(T_WINLIST *); +extern short GetIndexWinList(T_WINLIST *); +extern void DrawBox(T_MENU *,short ,short ,short ); +extern T_CLICK_BOX *AddHeaderButton(T_MENU *,short ,short ,short ,short ); +extern void GetCoorButton(T_MENU *,short ,long *,long *,long *,long *); +extern void AddButton(T_MENU *,short ,short ,short ,short ,short ,short ,unsigned char *); +extern void AddChangeValue(T_MENU *,short ,short ,short ,short ,short ,short ,unsigned char *,short *,short ,short ,short ); +extern void AddSwitch(T_MENU *,short ,short ,short ,short ,short ,short ,unsigned char *,short *,short ); +extern void AddText(T_MENU *,short ,short ,short ,short ,short ,unsigned char *); +extern void AddWindow(T_MENU *,short ,short ,short ,short ,short ,short ); +extern short GetOptimalSize(short ); +extern short OpenMenu(T_MENU *,short ,short ); +extern void CloseMenu(T_MENU *); +extern short DrawMenu(T_MENU *,short ,short ); +extern void ClearMenu(T_MENU *); +extern short ScanListClick(T_MENU *); +extern long GereMenu(T_MENU *); + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* menufunc.c */ + +extern T_CLICK_BOX *GetPtrLcb(T_MENU *,short ); +extern void OrButtonFlagIfTrue(T_MENU *,short ,short ,short ); +extern void SwitchButton(T_MENU *,short ); +extern void ChangeButtonFlags(T_MENU *,short ,short ,short ); +extern void ChangeButtonString(T_MENU *,short ,unsigned char *,short ); +extern void InputString(T_MENU *,short ,short ); +extern void Message(unsigned char *,long ); +extern long Confirm(unsigned char *,unsigned char *,unsigned char *); + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* selector.c */ + +extern void CutFileName(unsigned char *); +extern void DrawListFiles(short ); +extern void ScanFiles(unsigned char *,long ); +extern short ThereIsFiles(unsigned char *); +extern void ScanDirs(unsigned char *); +extern void ScanDrives(void); +extern long NumDrive(unsigned char *); +extern short FileSelector(unsigned char *,unsigned char *,unsigned char *,long ); + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + + + + + + diff --git a/LIB386/LIB_MENU/MAKEFILE b/LIB386/LIB_MENU/MAKEFILE new file mode 100644 index 0000000..ff7836b --- /dev/null +++ b/LIB386/LIB_MENU/MAKEFILE @@ -0,0 +1,61 @@ +# name the compiler +!ifdef %HOME +!ifeq WATCOM9 yes +CC = c:\compil\watcom\bin\wcc386p +WL = c:\compil\watcom\binb\wlib +!else +CC = c:\compil\watcom10\binb\wcc386 +WL = c:\compil\watcom10\binb\wlib +!endif +!else +!ifeq WATCOM9 yes +CC = f:\compil\watcom\bin\wcc386p +WL = f:\compil\watcom\binb\wlib +!else +CC = f:\compil\watcom10\binb\wcc386 +WL = f:\compil\watcom10\binb\wlib +!endif +!endif + +ASM = ml + +!ifeq WATCOM9 yes +CFLAGS = /oeaxt /zp2 /4s /zq /s /DWATCOM9 +!else +CFLAGS = /oeaxt /zp2 /5s /zq /s +!endif +LFLAGS = /c /q /b /n +#AFLAGS = /m2 /mx /z /zi /t /jMASM51 /jQUIRKS +AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=; + +OBJETS1 = menu.obj selector.obj menufunc.obj +OBJETS2 = asm_sort.obj +OBJETS3 = +OBJETS4 = + +!ifeq WATCOM9 yes +LIB = LB9_MENU +!else +LIB = LIB_MENU +!endif + +$(LIB).LIB: $(OBJETS1) $(OBJETS2) $(OBJETS3) $(OBJETS4) + + @echo $(OBJETS1) > clibmak.rsp + @echo $(OBJETS2) >> clibmak.rsp +# @echo $(OBJETS3) >> clibmak.rsp +# @echo $(OBJETS4) >> clibmak.rsp + + @$(WL) $(LIBFLAGS) $(LIB) @clibmak.rsp + @del clibmak.rsp + @prntitre M "$(LIB) OK" + +.asm.obj: + @PRNTITRE M "$*.ASM" + @$(ASM) $(AFLAGS) $*.ASM + +.c.obj: + @PRNTITRE M "$*.C" + @$(CC) $(CFLAGS) $* + + diff --git a/LIB386/LIB_MENU/MENU.C b/LIB386/LIB_MENU/MENU.C new file mode 100644 index 0000000..3739ace --- /dev/null +++ b/LIB386/LIB_MENU/MENU.C @@ -0,0 +1,1056 @@ +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_svga\lib_svga.h" + +#include "lib_menu.h" + +#include +#include +#include +#include + +#ifndef WATCOM9 +#include +#endif + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +UBYTE PalMenu[16*3] = { 0,0,0, + 71,71,119, + 127,127,215, + 171,167,231, + 115,0,0, + 171,0,0, + 215,0,0, + 0,0,0, + 87,87,87, + 87,87,255, + 87,255,87, + 87,255,255, + 255,87,87, + 255,87,255, + 255,255,87, + 255,255,255 } ; + + +T_CLICK_BOX *GetPtrLcb( T_MENU *ptrmenu, WORD handle ) ; + + +WORD FlagAutoPal = FALSE ; + +char InputValueString[64] ; + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void SetMenuAutoPal( WORD flag ) +{ + FlagAutoPal = flag ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void InitPalMenu() +{ + WORD n ; + + for( n=0; n<16; n++ ) + PalOne( n, PalMenu[n*3+0], PalMenu[n*3+1], PalMenu[n*3+2] ) ; +} + +void CopyPalMenu( UBYTE *ptrpal ) +{ + WORD n ; + + for( n=0; n<16; n++ ) + { + *ptrpal++ = PalMenu[n*3+0] ; + *ptrpal++ = PalMenu[n*3+1] ; + *ptrpal++ = PalMenu[n*3+2] ; + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void DrawWindow( LONG x1, LONG y1, LONG x2, LONG y2, + LONG flags ) +{ + LONG coul, up, down ; + + MemoClip() ; + UnSetClip() ; + if( FlagAutoPal ) InitPalMenu() ; + + if( flags & FLAG_RED ) coul = B_ROUGE ; + else coul = B_GRIS ; + + if( flags & FLAG_PUSHED ) + { + up = coul ; + down = coul+2 ; + } + else + { + up = coul+2 ; + down = coul ; + } + + Line( x1 , y1 , x2 ,y1 , up ) ; + Line( x1 , y1+1, x2-1,y1+1, up ) ; + Line( x1 , y1+2, x1 ,y2 , up ) ; + Line( x1+1, y1+2, x1+1,y2-1, up ) ; + + Line( x2 , y1+1, x2 ,y2 , down ) ; + Line( x2-1, y1+2, x2-1,y2 , down ) ; + Line( x1+2, y2-1, x2-2,y2-1, down ) ; + Line( x1+1, y2 , x2-2,y2 , down ) ; + + Box( x1+2,y1+2,x2-2,y2-2, coul+1 ) ; + + Line( x1-1,y1-1,x2+1,y1-1, 0 ) ; + Line( x2+1,y1-1,x2+1,y2+1, 0 ) ; + Line( x1-1,y2+1,x2+1,y2+1, 0 ) ; + Line( x1-1,y1-1,x1-1,y2+1, 0 ) ; + + RestoreClip() ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û Û Û ÛÛÜ Û ÛßßßÜ ÛßßßÛ Û Û ÛÛßßß + ÛÛßÜÛ ÛÛ ÛÛßÛÛ ÛÛ Û ÛÛ Û ÛÛßÜÛ ßßßßÛ + ß ß ßß ßß ß ßßßß ßßßßß ß ß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void OpenWindow( T_WINLIST *wlist, WORD x1, WORD y1, WORD largeur, WORD hauteur ) +{ + WORD recal, x2, y2 ; + + x1++ ; + y1++ ; + + if( (x1==0) AND (y1==0) ) /* centre window */ + { + x1 = (Screen_X/2) - ((largeur*SizeCar-3))/2 ; + y1 = (Screen_Y/2) - ((hauteur*(SizeCar+1)-3))/2 ; + x2 = x1 + largeur*SizeCar+14 ; /* 3 bord 4 espace *2 */ + y2 = y1 + hauteur*(SizeCar+1)+14 ; + } + else /* normal window */ + { + x2 = x1 + largeur*SizeCar+14 ; + y2 = y1 + hauteur*(SizeCar+1)+14 ; + } + + if( y2 >= 479 ) + { + recal = y2 - 478 ; + y2 -= recal ; + y1 -= recal ; + } + if( x2 >= 639 ) + { + recal = x2 - 638 ; + x2 -= recal ; + x1 -= recal ; + } + + + wlist->WindowX1 = x1 ; + wlist->WindowY1 = y1 ; + wlist->WindowX2 = x2 ; + wlist->WindowY2 = y2 ; + wlist->WindowLig = y1 + 7 ; + wlist->WindowCol = x1 + 7 ; + wlist->WindowTab = 10 ; + + DrawWindow( x1,y1,x2,y2, NO_FLAG ) ; + + CoulText( 0, -1 ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void GetWindowButton( T_MENU *ptrmenu, WORD handle, T_WINLIST *wlist ) +{ + WORD n, nblcb ; + T_CLICK_BOX *ptrlcb ; + + wlist->WindowX1 = 1 ; + wlist->WindowY1 = 1 ; + wlist->WindowX2 = Screen_X-2 ; + wlist->WindowY2 = Screen_Y-2 ; + wlist->WindowCol = wlist->WindowX1 + 7 ; + wlist->WindowLig = wlist->WindowY1 + 7 ; + wlist->WindowTab = 10 ; + + nblcb = ptrmenu->NbBox ; + ptrlcb = ptrmenu->PtrMallocList ; + for( n=0; nHandle == handle ) + { + wlist->WindowX1 = ptrlcb->X1 ; + wlist->WindowY1 = ptrlcb->Y1 ; + wlist->WindowX2 = ptrlcb->X2 ; + wlist->WindowY2 = ptrlcb->Y2 ; + wlist->WindowCol = wlist->WindowX1 + 7 ; + wlist->WindowLig = wlist->WindowY1 + 7 ; + break ; + } + ptrlcb++ ; + } + DrawWindow( wlist->WindowX1,wlist->WindowY1, + wlist->WindowX2,wlist->WindowY2, + ptrlcb->Flags ) ; + CoulText( 0, -1 ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void WinText( T_WINLIST *wlist, UBYTE *string, LONG value ) +{ + Text( wlist->WindowCol, wlist->WindowLig, "%s%l", string, value ) ; + wlist->WindowLig += SizeCar+1 ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void WinList( T_WINLIST *wlist, UBYTE **index, WORD nb, WORD size ) +{ + WORD n ; + + wlist->WindowArray = index ; + wlist->WindowNbIndex = nb ; + wlist->WindowTab = size ; + + for( n=0; nWindowCol, wlist->WindowLig, "%s", *index ) ; + index ++ ; + wlist->WindowLig += SizeCar+1 ; + if( wlist->WindowLig > wlist->WindowY2 -4 -SizeCar ) + { + wlist->WindowCol += size * SizeCar ; + wlist->WindowLig = wlist->WindowY1 + 7 ; + + if( wlist->WindowCol > wlist->WindowX2-4-size*SizeCar ) + { + wlist->WindowNbIndex = n+1 ; + break ; + } + } + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void WinSelect( T_WINLIST *wlist, WORD selected, WORD coul ) +{ + WORD n ; + UBYTE **index ; + + index = wlist->WindowArray ; + wlist->WindowCol = wlist->WindowX1 + 7 ; + wlist->WindowLig = wlist->WindowY1 + 7 ; + + for( n=0; nWindowNbIndex; n++ ) + { + if( n == selected ) + { + ShowMouse( 0 ) ; + CoulText( coul, -1 ) ; + Text( wlist->WindowCol, wlist->WindowLig, "%s", *index ) ; + CopyBlockPhys( wlist->WindowCol, + wlist->WindowLig, + wlist->WindowCol+strlen(*index)*SizeCar-1, + wlist->WindowLig+7 ) ; + ShowMouse( 1 ) ; + } + index ++ ; + wlist->WindowLig += SizeCar+1 ; + if( wlist->WindowLig > wlist->WindowY2 -4 -SizeCar ) + { + wlist->WindowCol += wlist->WindowTab * SizeCar ; + wlist->WindowLig = wlist->WindowY1 + 7 ; + } + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void WinSepar( T_WINLIST *wlist ) +{ + Line( wlist->WindowX1+2, wlist->WindowLig, wlist->WindowX2-2 ,wlist->WindowLig , B_GRIS ) ; + Line( wlist->WindowX1+2, wlist->WindowLig+1, wlist->WindowX2-2 ,wlist->WindowLig+1 , B_GRIS+2 ) ; + wlist->WindowLig += 3 ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void FlipWindow( T_WINLIST *wlist ) +{ + CopyBlockPhys( wlist->WindowX1-1, wlist->WindowY1-1, wlist->WindowX2+1, wlist->WindowY2+1 ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +WORD GetIndexWinList( T_WINLIST *wlist ) +{ + WORD num ; + LONG x, y, sizecol ; + + x = Mouse_X ; + y = Mouse_Y ; + + if( (x>=wlist->WindowX1+7) AND (x<=wlist->WindowX2-7) + AND (y>=wlist->WindowY1+7) AND (y<=wlist->WindowY2-4) ) + { + sizecol = ((wlist->WindowY2-2) - (wlist->WindowY1+7)) / (SizeCar+1) ; + + x -= wlist->WindowX1+7 ; + y -= wlist->WindowY1+7 ; + + x /= wlist->WindowTab*SizeCar ; + y /= (SizeCar+1) ; + + num = x * sizecol + y ; + + if( num < wlist->WindowNbIndex ) + { + return num ; + } + } + return -1 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛÜ ÜÛ Ûßßßß ÛÛÜ Û Û Û + ÛÛß Û ÛÛßß ÛÛßÛÛ ÛÛ Û + ßß ß ßßßßß ßß ß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + + +void DrawBox( T_MENU *ptrmenu, WORD numlcb, WORD pushed, WORD copyphys ) +{ + WORD flags ; + WORD nbaffcar ; + WORD len, x, y ; + UBYTE string[256] ; + UBYTE valuestring[64] ; + T_CLICK_BOX *ptrlcb ; + + MemoClip() ; + UnSetClip() ; + + ptrlcb = ptrmenu->PtrMallocList + numlcb ; + + if( ptrlcb->Type == TYPE_SWITCH ) + { + ptrlcb->Flags &= ~FLAG_PUSHED ; + if( *(ptrlcb->PtrVar) & ptrlcb->Mask ) + ptrlcb->Flags |= FLAG_PUSHED ; + } + + flags = ptrlcb->Flags ; + + /* dessin de la boite */ + + if( ptrlcb->Handle != -1 ) + { + flags |= pushed ; + DrawWindow( ptrlcb->X1,ptrlcb->Y1, + ptrlcb->X2,ptrlcb->Y2, + flags ) ; + } + + /* aff du text */ + + strcpy( string, ptrlcb->PtrString ) ; + if( ptrlcb->Type == TYPE_CHANGE_VALUE ) + { + strcat( string, itoa( *(ptrlcb->PtrVar), valuestring, 10 ) ) ; + } + + nbaffcar = ((ptrlcb->X2-3)-(ptrlcb->X1+3))/SizeCar ; + + len = strlen( string ) ; + if( (len > nbaffcar) AND (len!=1) ) + { + if( ptrlcb->Flags & FLAG_FILENAME ) /* perd le debut */ + { + memmove(string, + string+(len-nbaffcar), + nbaffcar +1 ) ; /* perd le debut */ + } + else /* perd la fin */ + { + string[nbaffcar] = 0 ; + } + } + + if( ptrlcb->Flags & FLAG_CENTRE ) + { + len = (len*SizeCar) /2 ; + x = (ptrlcb->X1+ptrlcb->X2)/2 - len ; + y = (ptrlcb->Y1+ptrlcb->Y2)/2 - (SizeCar/2) + 1 ; + } + else + { + x = ptrlcb->X1 + 3 ; + y = ptrlcb->Y1 + 3 ; + } + + if( flags & FLAG_PUSHED ) x++ ; + + if( ptrlcb->Flags & FLAG_CONTOUR ) + { + CoulText( 0, -1 ) ; + Text( x-1, y-1, string ) ; + Text( x , y-1, string ) ; + Text( x+1, y-1, string ) ; + Text( x-1, y , string ) ; + Text( x+1, y , string ) ; + Text( x-1, y+1, string ) ; + Text( x , y+1, string ) ; + Text( x+1, y+1, string ) ; + + CoulText( JAUNE, -1 ) ; + Text( x, y, string ) ; + } + else + { + CoulText( JAUNE, -1 ) ; + Text( x, y, string ) ; + } + + if( copyphys ) + { + ShowMouse( 0 ) ; + CopyBlockPhys( ptrlcb->X1-1,ptrlcb->Y1-1,ptrlcb->X2+1,ptrlcb->Y2+1 ); + ShowMouse( 1 ) ; + } + + RestoreClip() ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +T_CLICK_BOX *AddHeaderButton( T_MENU *ptrmenu, + WORD x1, WORD y1, + WORD largeur, WORD hauteur ) +{ + WORD x2, y2 ; + T_CLICK_BOX *ptrlcb ; + UBYTE *ptr ; + ULONG newsize ; + + x1 = ptrmenu->X1 + 6 + x1*(SizeCar+7)-2 ; + y1 = ptrmenu->Y1 + 6 + y1*(SizeCar+7)-2 ; + x2 = x1 + largeur*(SizeCar+7)-2 ; + y2 = y1 + hauteur*(SizeCar+7)-2 ; + + ptrmenu->NbBox++ ; + newsize = ptrmenu->NbBox * sizeof(T_CLICK_BOX) ; + + if( Mshrink( ptrmenu->PtrMallocList, newsize ) == 0L ) + { + ptr = (UBYTE*)ptrmenu->PtrMallocList ; + ptrmenu->PtrMallocList = Malloc( newsize ) ; + memmove( ptrmenu->PtrMallocList, ptr, newsize-sizeof(T_CLICK_BOX) ) ; + Free( ptr ) ; + } + + ptrlcb = ptrmenu->PtrMallocList + ptrmenu->NbBox - 1 ; + + ptrlcb->X1 = x1 ; + ptrlcb->Y1 = y1 ; + ptrlcb->X2 = x2 ; + ptrlcb->Y2 = y2 ; + + return ptrlcb ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void GetCoorButton( T_MENU *ptrmenu, WORD handle, LONG *x0, LONG *y0, LONG *x1, LONG *y1 ) +{ + WORD n, nblcb ; + T_CLICK_BOX *ptrlcb ; + + *x0 = 0 ; + *y0 = 0 ; + *x1 = Screen_X ; + *y1 = Screen_Y ; + + nblcb = ptrmenu->NbBox ; + ptrlcb = ptrmenu->PtrMallocList ; + for( n=0; nHandle == handle ) + { + *x0 = ptrlcb->X1 + 3 ; + *y0 = ptrlcb->Y1 + 3 ; + *x1 = ptrlcb->X2 - 3 ; + *y1 = ptrlcb->Y2 - 3 ; + break ; + } + ptrlcb++ ; + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void AddButton( T_MENU *ptrmenu, + WORD handle, + WORD x1, WORD y1, + WORD largeur, WORD hauteur, + WORD flags, + UBYTE *ptrstring ) +{ + T_CLICK_BOX *ptrlcb ; + + ptrlcb = AddHeaderButton( ptrmenu, x1,y1, largeur, hauteur ) ; + + ptrlcb->Handle = handle ; + ptrlcb->Flags = flags ; + ptrlcb->PtrString = ptrstring ; + ptrlcb->Type = TYPE_BUTTON ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void AddChangeValue( T_MENU *ptrmenu, + WORD handle, + WORD x1, WORD y1, + WORD largeur, WORD hauteur, + WORD flags, + UBYTE *ptrstring, + WORD *ptrvar, + WORD step, + WORD minvar, + WORD maxvar ) +{ + T_CLICK_BOX *ptrlcborg ; + T_CLICK_BOX *ptrlcb ; + + /* bouton valeur */ + + ptrlcborg = AddHeaderButton( ptrmenu, x1+hauteur,y1, largeur-2*hauteur, hauteur ) ; + + ptrlcborg->Handle = handle ; + ptrlcborg->Flags = flags ; + ptrlcborg->PtrString = ptrstring ; + ptrlcborg->Type = TYPE_CHANGE_VALUE ; + ptrlcborg->PtrVar = ptrvar ; + ptrlcborg->Mask = step ; + + /* bouton - */ + ptrlcb = AddHeaderButton( ptrmenu, x1,y1, hauteur, hauteur ) ; + + ptrlcb->Handle = handle ; + ptrlcb->Flags = FLAG_CENTRE | flags ; + ptrlcb->PtrString = "-" ; + ptrlcb->Type = TYPE_DEC_VALUE ; + ptrlcb->PtrVar = ptrvar ; + ptrlcb->Mask = minvar ; + + /* bouton + */ + ptrlcb = AddHeaderButton( ptrmenu, x1+largeur-hauteur,y1, hauteur, hauteur ) ; + + ptrlcb->Handle = handle ; + ptrlcb->Flags = FLAG_CENTRE | flags ; + ptrlcb->PtrString = "+" ; + ptrlcb->Type = TYPE_INC_VALUE ; + ptrlcb->PtrVar = ptrvar ; + ptrlcb->Mask = maxvar ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void AddSwitch( T_MENU *ptrmenu, + WORD handle, + WORD x1, WORD y1, + WORD largeur, WORD hauteur, + WORD flags, + UBYTE *ptrstring, + WORD *ptrvar, + WORD mask ) +{ + T_CLICK_BOX *ptrlcb ; + + ptrlcb = AddHeaderButton( ptrmenu, x1,y1, largeur, hauteur ) ; + + ptrlcb->Handle = handle ; + ptrlcb->Flags = flags ; + ptrlcb->PtrString = ptrstring ; + ptrlcb->Type = TYPE_SWITCH ; + ptrlcb->PtrVar = ptrvar ; + ptrlcb->Mask = mask ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void AddText( T_MENU *ptrmenu, + WORD x1, WORD y1, + WORD largeur, WORD hauteur, + WORD flags, + UBYTE *ptrstring ) +{ + T_CLICK_BOX *ptrlcb ; + + ptrlcb = AddHeaderButton( ptrmenu, x1,y1, largeur, hauteur ) ; + + ptrlcb->Handle = -1 ; + ptrlcb->Flags = flags ; + ptrlcb->PtrString = ptrstring ; + ptrlcb->Type = TYPE_TEXT ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void AddWindow( T_MENU *ptrmenu, + WORD handle, + WORD x1, WORD y1, + WORD largeur, WORD hauteur, + WORD flags ) +{ + T_CLICK_BOX *ptrlcb ; + + ptrlcb = AddHeaderButton( ptrmenu, x1,y1, largeur, hauteur ) ; + + ptrlcb->Handle = handle ; + ptrlcb->Flags = flags ; + ptrlcb->PtrString = "" ; + ptrlcb->Type = TYPE_WINDOW ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +WORD GetOptimalSize( WORD deltax ) +{ +/* return ((nbcar*SizeCar) / (SizeCar+7)) + 2 ; nbcar */ + return (deltax-8)/(SizeCar+7) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +WORD OpenMenu( T_MENU *ptrmenu, + WORD largeur, WORD hauteur ) +{ + ptrmenu->LastClicked = -1 ; + ptrmenu->Repeat = FALSE ; + + ptrmenu->NbBox = 0 ; + + ptrmenu->Largeur = largeur ; + ptrmenu->Hauteur = hauteur ; + + ptrmenu->X1 = 0 ; + ptrmenu->Y1 = 0 ; + ptrmenu->X2 = 0 ; + ptrmenu->Y2 = 0 ; + ptrmenu->Flags = 0 ; + + /* init une fausse clickbox pour first time */ + ptrmenu->PtrMallocList = (T_CLICK_BOX*)Malloc( 42*sizeof(T_CLICK_BOX) ) ; + if( !ptrmenu->PtrMallocList ) return FALSE ; + + return TRUE ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void CloseMenu( T_MENU *ptrmenu ) +{ + Free( ptrmenu->PtrMallocList ) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + + +WORD DrawMenu( T_MENU *ptrmenu, WORD x1, WORD y1 ) +{ + WORD n, nb ; + WORD x2,y2 ; + WORD oldx1,oldy1 ; + T_CLICK_BOX *ptrlcb ; + +/* ptrmenu->LastClicked = -1 ; */ + + + oldx1 = ptrmenu->X1 ; + oldy1 = ptrmenu->Y1 ; + + if( (x1==-1) AND (y1==-1) ) /* centre window */ + { + x1 = (Screen_X/2) - ((ptrmenu->Largeur*(SizeCar+7)-3))/2 ; + y1 = (Screen_Y/2) - ((ptrmenu->Hauteur*(SizeCar+7)-3))/2 ; + x2 = x1 + ptrmenu->Largeur*(SizeCar+7)+6 ; + y2 = y1 + ptrmenu->Hauteur*(SizeCar+7)+6 ; + } + else /* normal window */ + { + x1++ ; + y1++ ; + + x2 = x1 + ptrmenu->Largeur*(SizeCar+7)+6 ; + y2 = y1 + ptrmenu->Hauteur*(SizeCar+7)+6 ; + } + + ptrmenu->X1 = x1 ; + ptrmenu->Y1 = y1 ; + ptrmenu->X2 = x2 ; + ptrmenu->Y2 = y2 ; + + DrawWindow( ptrmenu->X1, ptrmenu->Y1, + ptrmenu->X2, ptrmenu->Y2, + ptrmenu->Flags ) ; + + nb = ptrmenu->NbBox ; + ptrlcb = ptrmenu->PtrMallocList ; + for( n=0; nX1 += x1-oldx1 ; + ptrlcb->Y1 += y1-oldy1 ; + ptrlcb->X2 += x1-oldx1 ; + ptrlcb->Y2 += y1-oldy1 ; + + DrawBox( ptrmenu, n, NO_FLAG, FALSE ) ; + + ptrlcb++ ; + } + + CopyBlockPhys( x1-1,y1-1,x2+1,y2+1 ) ; + + return y2 + 1 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void ClearMenu( T_MENU *ptrmenu ) +{ + ptrmenu->LastClicked = -1 ; + + Box( ptrmenu->X1, ptrmenu->Y1, + ptrmenu->X2, ptrmenu->Y2, 0 ) ; + + CopyBlockPhys( ptrmenu->X1, ptrmenu->Y1, + ptrmenu->X2, ptrmenu->Y2 ) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/* on scan TOUJOURS une list de click box en DECREMENTANT */ + +WORD ScanListClick( T_MENU *ptrmenu ) +{ + WORD n ; + T_CLICK_BOX *ptrlcb ; + WORD x, y ; + WORD nb ; + + nb = ptrmenu->NbBox ; + + if( !nb ) return -2 ; + + x = Mouse_X ; + y = Mouse_Y ; + + if( (x>=ptrmenu->X1) AND (x<=ptrmenu->X2) + AND (y>=ptrmenu->Y1) AND (y<=ptrmenu->Y2) ) + { + ptrlcb = ptrmenu->PtrMallocList + (nb-1) ; + for( n=nb-1; n>=0; n-- ) + { + if( (x >= ptrlcb->X1) AND (y >= ptrlcb->Y1) + AND (x <= ptrlcb->X2) AND (y <= ptrlcb->Y2) ) + { + if( ptrlcb->Handle != -1 ) return n ; + else return -1 ; + } + ptrlcb-- ; + } + return -1 ; + } + return -2 ; +} + +/* + +WORD ScanListKey( T_MENU *ptrmenu ) +{ + WORD n ; + T_CLICK_BOX *ptrlcb ; + WORD x, y ; + WORD nb ; + + nb = ptrmenu->NbBox ; + + if( !nb ) return -2 ; + + k = Key ; + + ptrlcb = ptrmenu->PtrMallocList ; + for( n=0; nKey == k ) return ptrlcb->Handle ; + ptrlcb++ ; + } + return -1 ; +} + +WORD ScanListKey_prog( T_MENU *ptrmenu ) +{ + WORD n ; + T_CLICK_BOX *ptrlcb ; + WORD x, y ; + WORD nb ; + + nb = ptrmenu->NbBox ; + + if( !nb ) return -2 ; + + k = Key ; + + ptrlcb = ptrmenu->PtrMallocList ; + for( n=0; nKey == k ) return n ; + ptrlcb++ ; + } + return -1 ; +} + +*/ + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +#ifdef ANCIEN +LONG GereMenu( T_MENU *ptrmenu, WORD flagwaitclick ) +{ + LONG exitflag = -1 ; + WORD select ; + + T_CLICK_BOX *ptrlcb ; + T_CLICK_BOX *ptrlcborg ; + WORD value ; + WORD vmin, vmax ; + + select = ScanListClick( ptrmenu ) ; + + if( select == -2 ) exitflag = -2 ; + + if( Click ) + { + if( select > -1 )/* AND (select != ptrmenu->LastClicked) )*/ + { + ptrlcb = ptrmenu->PtrMallocList + select ; + exitflag = ptrlcb->Handle ; + + if( ptrmenu->LastClicked == select ) + { + if( flagwaitclick ) + { + /* methode du click/run/wait */ + while( Click ) AffMouse() ; + return -1 ; + } + return exitflag ; + } + switch( ptrlcb->Type ) + { + case TYPE_SWITCH: + *(ptrlcb->PtrVar) ^= ptrlcb->Mask ; + break ; + + case TYPE_CHANGE_VALUE: /* scroll value */ + vmin = (ptrmenu->PtrMallocList + select +1 )->Mask ; + vmax = (ptrmenu->PtrMallocList + select +2 )->Mask ; + value = *(ptrlcb->PtrVar) ; + GetMouseDep() ; + while( Click ) + { + GetMouseDep() ; + value += ((WORD)Mouse_X_Dep/4) * ptrlcb->Mask ; + if( value < vmin ) value = vmin ; + if( value > vmax ) value = vmax ; + *(ptrlcb->PtrVar) = value ; + DrawBox( ptrmenu, select, FLAG_PUSHED, TRUE ) ; + } + DrawBox( ptrmenu, select, NO_FLAG, TRUE ) ; + break ; + + case TYPE_DEC_VALUE: + ptrlcborg = GetPtrLcb( ptrmenu, ptrlcb->Handle ) ; + value = *ptrlcb->PtrVar ; + value -= ptrlcborg->Mask ; /* step */ + if( value < ptrlcb->Mask ) + value = ptrlcb->Mask ; /* minvar */ + *ptrlcb->PtrVar = value ; + /* draw value box */ + DrawBox( ptrmenu, select-1, NO_FLAG, TRUE ) ; + break ; + + case TYPE_INC_VALUE: + ptrlcborg = GetPtrLcb( ptrmenu, ptrlcb->Handle ) ; + value = *ptrlcb->PtrVar ; + value += ptrlcborg->Mask ; /* step */ + if( value > ptrlcb->Mask ) + value = ptrlcb->Mask ; /* maxvar */ + *ptrlcb->PtrVar = value ; + /* draw value box */ + DrawBox( ptrmenu, select-2, NO_FLAG, TRUE ) ; + break ; + } + + if( ptrlcb->Type != TYPE_WINDOW ) + { + DrawBox( ptrmenu, select, FLAG_PUSHED, TRUE ) ; + ptrmenu->LastClicked = select ; + } + } + } + else /* pas de click */ + { + if( ptrmenu->LastClicked != -1 ) + { + DrawBox( ptrmenu, ptrmenu->LastClicked, NO_FLAG, TRUE ) ; + ptrmenu->LastClicked = -1 ; + } + } + + return exitflag ; +} +#endif + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +LONG GereMenu( T_MENU *ptrmenu ) +{ + LONG exitflag = -1 ; + WORD select ; + + T_CLICK_BOX *ptrlcb ; + T_CLICK_BOX *ptrlcborg ; + LONG value, ivalue ; + WORD vmin, vmax ; + WORD click ; + char *memostring ; + + + select = ScanListClick( ptrmenu ) ; + + if( select == -2 ) exitflag = -2 ; + + if( (click=Click) != 0 ) + { + if( select > -1 ) + { + ptrlcb = ptrmenu->PtrMallocList + select ; + exitflag = ptrlcb->Handle ; + + if( ptrmenu->LastClicked == select ) + { + if( !ptrmenu->Repeat ) + { + /* methode du click/run/wait */ + while( Click ) AffMouse() ; + return -1 ; + } + else + { + ptrmenu->Repeat = FALSE ; + } + } + switch( ptrlcb->Type ) + { + case TYPE_SWITCH: + *(ptrlcb->PtrVar) ^= ptrlcb->Mask ; + break ; + + case TYPE_CHANGE_VALUE: /* scroll value */ + vmin = (ptrmenu->PtrMallocList + select +1 )->Mask ; + vmax = (ptrmenu->PtrMallocList + select +2 )->Mask ; + value = *(ptrlcb->PtrVar) ; + if( click & 2 ) /* slide value */ + { + GetMouseDep() ; + while( Click ) + { + GetMouseDep() ; + value += (Mouse_X_Dep/4) * ptrlcb->Mask ; + if( value < vmin ) value = vmin ; + if( value > vmax ) value = vmax ; + *(ptrlcb->PtrVar) = (WORD)value ; + DrawBox( ptrmenu, select, FLAG_PUSHED, TRUE ) ; + } + } + else /* input value */ + { + memostring = ptrlcb->PtrString ; + itoa( value, InputValueString, 10 ) ; + ptrlcb->PtrString = InputValueString ; + ptrlcb->Type = TYPE_TEXT ; + DrawBox( ptrmenu, select, FLAG_PUSHED, TRUE ) ; + InputString( ptrmenu, ptrlcb->Handle , 63 ) ; + ivalue = atoi( InputValueString ) ; + if( ivalue < vmin ) ivalue = vmin ; + if( ivalue > vmax ) ivalue = vmax ; + *(ptrlcb->PtrVar) = ivalue ; + ptrlcb->Type = TYPE_CHANGE_VALUE ; + ptrlcb->PtrString = memostring ; + } + DrawBox( ptrmenu, select, NO_FLAG, TRUE ) ; + break ; + + case TYPE_DEC_VALUE: + ptrlcborg = GetPtrLcb( ptrmenu, ptrlcb->Handle ) ; + value = *ptrlcb->PtrVar ; + value -= ptrlcborg->Mask ; /* step */ + if( value < ptrlcb->Mask ) + value = ptrlcb->Mask ; /* minvar */ + *ptrlcb->PtrVar = value ; + /* draw value box */ + DrawBox( ptrmenu, select-1, NO_FLAG, TRUE ) ; + break ; + + case TYPE_INC_VALUE: + ptrlcborg = GetPtrLcb( ptrmenu, ptrlcb->Handle ) ; + value = *ptrlcb->PtrVar ; + value += ptrlcborg->Mask ; /* step */ + if( value > ptrlcb->Mask ) + value = ptrlcb->Mask ; /* maxvar */ + *ptrlcb->PtrVar = value ; + /* draw value box */ + DrawBox( ptrmenu, select-2, NO_FLAG, TRUE ) ; + break ; + } + + if( ptrlcb->Type != TYPE_WINDOW ) + { + DrawBox( ptrmenu, select, FLAG_PUSHED, TRUE ) ; + ptrmenu->LastClicked = select ; + } + } + } + else /* pas de click */ + { + if( ptrmenu->LastClicked != -1 ) + { + DrawBox( ptrmenu, ptrmenu->LastClicked, NO_FLAG, TRUE ) ; + ptrmenu->LastClicked = -1 ; + } + } + + return exitflag ; +} + diff --git a/LIB386/LIB_MENU/MENUFUNC.C b/LIB386/LIB_MENU/MENUFUNC.C new file mode 100644 index 0000000..8b4b240 --- /dev/null +++ b/LIB386/LIB_MENU/MENUFUNC.C @@ -0,0 +1,489 @@ +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_svga\lib_svga.h" + +#include "lib_menu.h" + +#include +#include +#include +#include + +#ifndef WATCOM9 +#include +#endif + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + + +T_CLICK_BOX *GetPtrLcb( T_MENU *ptrmenu, WORD handle ) +{ + WORD n, nblcb ; + T_CLICK_BOX *ptrlcb ; + + nblcb = ptrmenu->NbBox ; + ptrlcb = ptrmenu->PtrMallocList ; + + for( n=0; nHandle == handle ) + { + return ptrlcb ; + } + ptrlcb++ ; + } + return 0L ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void OrButtonFlagIfTrue( T_MENU *ptrmenu, WORD handle, WORD flags, WORD test ) +{ + WORD n, nblcb ; + T_CLICK_BOX *ptrlcb ; + + if( test != 0 ) + { + nblcb = ptrmenu->NbBox ; + ptrlcb = ptrmenu->PtrMallocList ; + for( n=0; nHandle == handle ) + { + ptrlcb->Flags |= flags ; + return ; + } + ptrlcb++ ; + } + } +} + +void SwitchButton( T_MENU *ptrmenu, WORD handle ) +{ + WORD n, nblcb ; + T_CLICK_BOX *ptrlcb ; + + nblcb = ptrmenu->NbBox ; + ptrlcb = ptrmenu->PtrMallocList ; + + for( n=0; nHandle == handle ) + { + ptrlcb->Flags ^= FLAG_PUSHED ; +/* if( flagaff ) + { + DrawBox( ptrmenu, n, NO_FLAG, TRUE ) ; + } +*/ + return ; + } + ptrlcb++ ; + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void ChangeButtonFlags( T_MENU *ptrmenu, WORD handle, WORD flags, WORD flagaff ) +{ + WORD n, nblcb ; + T_CLICK_BOX *ptrlcb ; + + nblcb = ptrmenu->NbBox ; + ptrlcb = ptrmenu->PtrMallocList ; + + for( n=0; nHandle == handle ) + { + ptrlcb->Flags = flags ; + if( flagaff ) + { + DrawBox( ptrmenu, n, NO_FLAG, TRUE ) ; + } + return ; + } + ptrlcb++ ; + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* +WORD GetButtonFlags( T_MENU *ptrmenu, WORD handle ) +{ + WORD n, nblcb ; + T_CLICK_BOX *ptrlcb ; + + nblcb = ptrmenu->NbBox ; + ptrlcb = ptrmenu->PtrMallocList ; + + for( n=0; nHandle == handle ) + { + return ptrlcb->Flags ; + } + ptrlcb++ ; + } + return 0 ; +} +*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void ChangeButtonString( T_MENU *ptrmenu, WORD handle, UBYTE *string, WORD flagaff ) +{ + WORD n, nblcb ; + T_CLICK_BOX *ptrlcb ; + + nblcb = ptrmenu->NbBox ; + ptrlcb = ptrmenu->PtrMallocList ; + + for( n=0; nHandle == handle ) + { + ptrlcb->PtrString = string ; + if( flagaff ) + { + DrawBox( ptrmenu, n, NO_FLAG, TRUE ) ; + } + return ; + } + ptrlcb++ ; + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* +UBYTE* GetButtonString( T_MENU *ptrmenu, WORD handle ) +{ + WORD n, nblcb ; + T_CLICK_BOX *ptrlcb ; + + nblcb = ptrmenu->NbBox ; + ptrlcb = ptrmenu->PtrMallocList ; + + for( n=0; nHandle == handle ) + { + return ptrlcb->PtrString ; + } + ptrlcb++ ; + } + return 0L ; +} +*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void InputString( T_MENU *ptrmenu, WORD handle, WORD maxcar ) +{ + WORD n, nblcb, numlcb ; + WORD coul,x,y ; + LONG x1,y1,x2,y2 ; + WORD start,pc ; + WORD exit ; + WORD len ; + WORD nbaffcar ; + WORD carsizex ; + WORD myclick, mykey ; + WORD memoasciimode ; + + UBYTE car ; + UBYTE string[256] ; + + T_CLICK_BOX *ptrlcb ; + + nblcb = ptrmenu->NbBox ; + ptrlcb = ptrmenu->PtrMallocList ; + for( n=0; nHandle == handle ) break ; + ptrlcb++ ; + } + if( n==nblcb ) return ; + + numlcb = n ; + strcpy( string, ptrlcb->PtrString ) ; + + pc = -1 ; /* pos curseur (-1 no cursor) */ + start = 0 ; + + x1 = ptrlcb->X1+3 ; + y1 = ptrlcb->Y1+3 ; + + x2 = ptrlcb->X2-3 ; + y2 = ptrlcb->Y2-3 ; + + nbaffcar = (carsizex=((x2 - x1)+1)/SizeCar) * (((y2-y1)+1)/SizeCar) ; + + if( ptrlcb->Flags & FLAG_RED ) coul = B_ROUGE+1 ; + else coul = B_GRIS+1 ; + + memoasciimode = AsciiMode ; + AsciiMode = TRUE ; + CoulText( BLANC,-1 ) ; + + ShowMouse( 0 ) ; + + while( Click ) ; + + exit = FALSE ; + while( !exit ) + { + /* affichage */ + +/* DrawInputString( string, nbffcar, start, pc, */ + + len = strlen( string ) ; + + if( pc-start >= nbaffcar ) start = pc - nbaffcar + 1 ; + if( pc < start ) start = pc ; + + Vsync() ; + if( pc == -1 ) + { + x = x1+(len*SizeCar) ; + if( x>x2 ) x = x2 ; + Box( x1,y1,x,y2, 9 ) ; + } + else + { + Box( x1,y1,x2,y2, coul ) ; + } + + x = x1 ; + y = y1 ; + for( n=0; n<=len; n++ ) + { + if( n < start ) continue ; + if( n == pc ) + { + Box(x,y,x+SizeCar-2,y+SizeCar-1,BLANC ) ; + x += SizeCar ; + if( x > x2-SizeCar-1 ) + { + if( y > y2-SizeCar-1 ) + { + break ; + } + else + { + y += SizeCar ; + x = x1 ; + } + } + } + + Text( x,y, "%c", string[n] ) ; + x += SizeCar ; + if( x > x2-SizeCar-1 ) + { + y += SizeCar ; + if( y > y2-SizeCar-1 ) + { + break ; + } + else + { + x = x1 ; + } + } + } + CopyBlockPhys( ptrlcb->X1, ptrlcb->Y1, ptrlcb->X2, ptrlcb->Y2 ) ; + + /* input */ + + while( !(mykey=GetAscii()) AND (!(myclick=Click)) ) ; + + if( myclick ) + { + exit = TRUE ; + break ; + } + + car = mykey & 255 ; + + if( (car >= 32) AND (car < 255) ) + { + if( pc == -1 ) + { + pc = 1 ; + string[0] = car ; + string[1] = 0 ; + } + else + { + if( len < maxcar ) + { /* insert */ + memmove( &string[pc+1],&string[pc],strlen(&string[pc])+1 ) ; + string[pc] = car ; + pc++ ; + if( pc > len ) string[pc] = 0 ; + } + } + } + else + { + switch( mykey ) + { + + case A_ESC: + exit = TRUE ; + break ; + + case A_RETURN: + exit = TRUE ; + break ; + + case A_END: + pc = len ; + break ; + + case A_HOME: + pc = 0 ; + break ; + + case A_BACKSPACE: + if( pc == -1 ) pc = len ; + if( pc > 0 ) + { + pc-- ; + memmove( &string[pc],&string[pc+1],strlen(&string[pc+1])+1 ) ; + } + break ; + + case A_SUPPR: + if( pc == -1 ) pc = len ; + if( pc < len ) + { + memmove( &string[pc],&string[pc+1],strlen(&string[pc+1])+1 ) ; + } + break ; + + case A_LEFT: + if( pc == -1 ) pc = len-1 ; + else + if( pc > 0 ) pc-- ; + break ; + + case A_RIGHT: + if( pc == -1 ) pc = 1 ; + else + if( pc < len ) pc++ ; + break ; + + case A_DOWN: + if( pc == -1 ) + { + if( carsizex < len ) + pc = carsizex ; + else + pc = 0 ; + } + else + if( pc+carsizex < len ) + pc += carsizex ; + break ; + + case A_UP: + if( pc == -1 ) pc = 0 ; + else + if( pc-carsizex >= 0 ) + pc -= carsizex ; + break ; + } + } + + } + + if( (mykey==A_RETURN) OR (myclick) ) + { + strcpy( ptrlcb->PtrString, string ) ; + } + + DrawBox( ptrmenu, numlcb, NO_FLAG, TRUE ) ; + + AsciiMode = memoasciimode ; + ShowMouse( 1 ) ; + + while( Key OR Click OR Fire ) AffMouse() ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/* fontions evolu‚es */ + +void Message( UBYTE *message, LONG flag ) +{ + T_MENU menu ; + WORD len ; + + len = strlen(message)*SizeCar / (SizeCar+7) + 2 ; + + if( !OpenMenu( &menu, len,2 ) ) return ; + AddText( &menu, 0,0, len,2, FLAG_CENTRE+FLAG_CONTOUR, message ) ; + + DrawMenu( &menu, -1, -1 ) ; + + if( flag ) + { + ShowMouse( 1 ) ; + while( Click OR Fire OR Key ) ; + while( !Click AND !Fire AND !Key ) AffMouse() ; + while( Click OR Fire OR Key) ; + } + + CloseMenu( &menu ) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/* Confirm( "Voulez-vous vraiment ?", "OUI" (RETURN), "NON"(ESC) ) ; */ + +LONG Confirm( UBYTE *message, UBYTE *oui, UBYTE *non ) +{ + T_MENU menu ; + WORD len, select ; + + len = strlen(message)*SizeCar / (SizeCar+7) + 2 ; + + if( !OpenMenu( &menu, len,3 ) ) return 2 ; + AddText( &menu, 0,0, len,2, FLAG_CENTRE+FLAG_CONTOUR, message ) ; + AddButton( &menu, 1, 0,2, len/2,1, FLAG_CENTRE+FLAG_RED, oui ) ; + AddButton( &menu, 2, len/2,2, len/2,1, FLAG_CENTRE, non ) ; + DrawMenu( &menu, -1, -1 ) ; + + ShowMouse( 1 ) ; + while( Click OR Fire OR Key ) AffMouse() ; + select = 0 ; + while( select < 1 ) + { + AffMouse() ; + select = GereMenu( &menu ) ; + + if( Fire & F_RETURN ) + { + select = 1 ; + DrawBox( &menu, 1, FLAG_PUSHED, TRUE ) ; + } + if( Key == K_ESC ) + { + select = 2 ; + DrawBox( &menu, 2, FLAG_PUSHED, TRUE ) ; + } + } + while( Click OR Fire OR Key ) AffMouse() ; + + CloseMenu( &menu ) ; + + return select ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + + + + diff --git a/LIB386/LIB_MENU/SELECTOR.C b/LIB386/LIB_MENU/SELECTOR.C new file mode 100644 index 0000000..54eab25 --- /dev/null +++ b/LIB386/LIB_MENU/SELECTOR.C @@ -0,0 +1,554 @@ +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_svga\lib_svga.h" +#include "\projet\lib386\lib_menu\lib_menu.h" + +#include +#include +#include +#include +#include +#include + +#ifndef WATCOM9 +#include +#endif + +#define MAX_FILES 500 +#define MAX_DIRS 100 + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Ûßßßß Û Û Ûßßßß ÛÛßßß Ûßßßß Û Ûßßßß Ûßßßß ßßÛßß ÛßßßÛ ÛßßßÛ + ÛÛßß ÛÛ ÛÛ ÛÛßß ßßßßÛ ÛÛßß ÛÛ ÛÛßß ÛÛ ÛÛ ÛÛ Û ÛÛßÛß + ßß ßß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßß ßßßßß ßß ß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +UBYTE SelectorPathname [_MAX_PATH] ; +UBYTE SDrive[_MAX_DRIVE] ; +UBYTE SDir[_MAX_DIR] ; +UBYTE SName[_MAX_FNAME] ; +UBYTE SExt[_MAX_EXT] ; + +WORD NbFiles ; +UBYTE *ListFiles ; +UBYTE **IndexFiles ; +WORD NbDirs ; +UBYTE *ListDirs ; +UBYTE **IndexDirs ; + +WORD StartFile = 0 ; + +UBYTE SearchPathname[_MAX_PATH] ; + +T_MENU Selector ; + +T_WINLIST FilesWindow ; +T_WINLIST DirsWindow ; + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void CutFileName( UBYTE *filename ) +{ + while( (*filename!=0) AND (*filename!='.') ) + filename++ ; + *filename = 0 ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DrawListFiles( WORD flag ) +{ + WORD nb ; + + ShowMouse( 0 ) ; + GetWindowButton( &Selector, 10, &FilesWindow ) ; + + if( NbFiles ) + { + if( StartFile >= NbFiles ) StartFile = NbFiles-1 ; + nb = NbFiles - StartFile ; + + if( flag & SELECT_SHOW_EXT ) + WinList( &FilesWindow, IndexFiles+StartFile, nb, 14 ) ; + else + WinList( &FilesWindow, IndexFiles+StartFile, nb, 9 ) ; + } + else + { + WinList( &FilesWindow, IndexFiles, 0, 14 ) ; + } + FlipWindow( &FilesWindow ) ; + ShowMouse( 1 ) ; +} + +/* +int my_sort_function( char **a, char **b) +{ + return( strcmp( *a, *b) ) ; +} +*/ + +void ScanFiles( UBYTE *selection, LONG flag ) +{ + struct find_t fileinfo ; + ULONG rc ; + UBYTE *ptr ; + UBYTE path[_MAX_PATH] ; + + _splitpath( selection, SDrive, SDir, SName, SExt ) ; + _makepath( path, "", SearchPathname, SName, SExt ) ; + + rc = _dos_findfirst( path, _A_NORMAL, &fileinfo ) ; + NbFiles = 0 ; + ptr = ListFiles ; + while( !rc ) + { + IndexFiles[NbFiles] = ptr ; + if( !(flag & SELECT_SHOW_EXT) ) CutFileName( fileinfo.name ) ; + strcpy( ptr, fileinfo.name ) ; + ptr += strlen( fileinfo.name ) + 1 ; + NbFiles++ ; + if( NbFiles == MAX_FILES ) + { + Message( "Warning: Truncated List", TRUE ) ; + break ; + } + rc = _dos_findnext( &fileinfo ) ; + } + + if( NbFiles ) /* ? */ + qsort( (void *)IndexFiles, NbFiles, sizeof( char * ), MySortCompFunc ); + + DrawListFiles( flag ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +WORD ThereIsFiles( UBYTE *path ) +{ + struct find_t fileinfo ; + + if( !_dos_findfirst( path, _A_NORMAL, &fileinfo ) ) + return 1 ; + else + return 0 ; +} + +void ScanDirs( UBYTE *selection ) +{ + struct find_t fileinfo ; + ULONG rc ; + UBYTE *ptr ; + WORD n ; + UBYTE path[_MAX_PATH] ; + + rc = _dos_findfirst( "*.*", _A_SUBDIR, &fileinfo ) ; + NbDirs = 0 ; + ptr = ListDirs ; + while( !rc ) + { + if( fileinfo.attrib & _A_SUBDIR ) + { + IndexDirs[NbDirs] = ptr ; + strcpy( ptr, fileinfo.name ) ; + ptr += strlen( fileinfo.name ) + 1 ; + NbDirs++ ; + if( NbDirs == MAX_FILES ) + { + Message( "Warning: Truncated List", TRUE ) ; + break ; + } + } + rc = _dos_findnext( &fileinfo ) ; + } + + ShowMouse( 0 ) ; + GetWindowButton( &Selector, 11, &DirsWindow ) ; + WinList( &DirsWindow, IndexDirs, NbDirs, 14 ) ; + FlipWindow( &DirsWindow ) ; + + /* if option scan files */ + + for( n=0; n 2 ) + { + if( SDir[strlen(SDir)-1] == '\\' ) SDir[strlen(SDir)-1] = 0 ; + } + + if( SDrive[0] != 0 ) + { + SDrive[0] &= ~0x20 ; + + _dos_setdrive( SDrive[0]-'A'+1, &total ) ; + _dos_getdrive( &testdrive ) ; + if( testdrive == SDrive[0]-'A'+1 ) + { + chdir( SDir ) ; + } + else + { + Message( "Drive Error", TRUE ) ; + } + } + else chdir( SDir ) ; + + strcpy( SelectorPathname, SName ) ; + + _splitpath( selection, SDrive, SDir, SName, SExt ) ; + strcat( SelectorPathname, SExt ) ; + + getcwd( SearchPathname, _MAX_PATH ) ; + + /* window */ + + if( !OpenMenu( &Selector, 32,20 ) ) return 0 ; + AddText( &Selector, 0, 0, 32, 1, FLAG_CENTRE+FLAG_CONTOUR, titre ) ; + AddText( &Selector, 0, 1, 3, 1, NO_FLAG, "Path" ) ; + AddButton( &Selector, 0, 3, 1, 29, 1, NO_FLAG, SearchPathname ) ; + AddText( &Selector, 0, 2, 3, 1, NO_FLAG, "File" ) ; + AddButton( &Selector, 4, 3, 2, 29, 1, FLAG_RED, SelectorPathname ) ; + + AddWindow( &Selector,10, 0, 4, 16,14, NO_FLAG ) ; + + AddWindow( &Selector,11, 16, 4, 16,14, NO_FLAG ) ; + + AddText( &Selector, 0, 3, 16, 1, FLAG_CENTRE+FLAG_CONTOUR, selection ) ; + AddButton( &Selector, 2, 16, 3, 8, 1, FLAG_CENTRE+FLAG_PUSHED, "Dirs" ) ; + AddButton( &Selector, 3, 24, 3, 8, 1, FLAG_CENTRE, "Drives" ) ; + + AddButton( &Selector, 5, 16,18, 16, 2, FLAG_CENTRE+FLAG_CONTOUR, "Cancel" ) ; + AddButton( &Selector, 6, 0,18, 16, 2, FLAG_CENTRE+FLAG_CONTOUR+FLAG_RED, "OK" ) ; + + DrawMenu( &Selector, -1,-1 ) ; + ShowMouse( 1 ) ; + + IndexFiles = Malloc( MAX_FILES * sizeof(UBYTE*) ) ; + IndexDirs = Malloc( MAX_DIRS * sizeof(UBYTE*) ) ; + ListFiles = Malloc( MAX_FILES * 13 ) ; + ListDirs = Malloc( MAX_DIRS * 13 ) ; + /* test erreur malloc */ + if( !IndexFiles OR !ListFiles OR !IndexDirs OR !ListDirs ) + { + Message( "File List Malloc Error", TRUE ) ; + return 0 ; + } + + if( !(flags & SELECT_KEEP_POS) ) StartFile = 0 ; + + ScanFiles( selection, flags ) ; + ScanDirs( selection ) ; + + while( Click ) AffMouse() ; + + rcode = -1 ; + flag = 1 ; + while( flag != -1 ) + { + if( Key == K_ESC ) rcode = 0 ; + if( Fire == F_RETURN ) rcode = 1 ; + + AffMouse() ; + + handle = GereMenu( &Selector ) ; + + switch( handle ) + { + case 10: /* files list */ + if( Click & 2 ) + { + GetMouseDep() ; + while( Click & 2 ) + { + GetMouseDep() ; + StartFile -= Mouse_Y_Dep ; + if( StartFile < 0 ) StartFile = 0 ; + DrawListFiles(flags) ; + } + oldnum = -1 ; + } + else + { + num = GetIndexWinList( &FilesWindow ) + StartFile ; + if( oldnum != -1 ) + { + if( num == oldnum ) /* double click */ + { + rcode = 1 ; + break ; + } + WinSelect( &FilesWindow, oldnum-StartFile, 0 ) ; /* efface */ + } + if( num != -1 ) + { + WinSelect( &FilesWindow, num-StartFile, 15 ) ; + oldnum = num ; + if( flags & SELECT_SHOW_EXT ) + { + strcpy( SelectorPathname, IndexFiles[num] ) ; + } + else + { + strcpy( SelectorPathname, IndexFiles[num] ) ; + _splitpath( selection, SDrive, SDir, SName, SExt ) ; + strcat( SelectorPathname, SExt ) ; + } + ChangeButtonString( &Selector, 4, SelectorPathname , TRUE ) ; + while( Click ) AffMouse() ; + } + } + break ; + + case 11: /* dirs/drive list */ + num = GetIndexWinList( &DirsWindow ) ; + if( num != -1 ) + { + WinSelect( &DirsWindow, num, 15 ) ; + + if( !mode ) /* dir */ + { + chdir( IndexDirs[num] ) ; + getcwd( SearchPathname, _MAX_PATH ) ; + ChangeButtonString( &Selector, 0, SearchPathname, TRUE ) ; + ScanDirs( selection ) ; + } + else /* drive */ + { + n = IndexDirs[num][0] - 'A' + 1 ; + memoasciimode = AsciiMode ; + AsciiMode = TRUE ; + _dos_setdrive( n, &total ) ; + getcwd( SearchPathname, _MAX_PATH ) ; + AsciiMode = memoasciimode ; + ScanDrives() ; + } + getcwd( SearchPathname, _MAX_PATH ) ; + ChangeButtonString( &Selector, 0, SearchPathname, TRUE ) ; + ScanFiles( selection, flags ) ; + oldnum = -1 ; + while( Click ) AffMouse() ; + } + break ; + + case 0: /* input new searchpath */ + InputString( &Selector, 0, _MAX_PATH ) ; + _splitpath( SearchPathname, SDrive,SDir,SName,SExt ) ; + _dos_setdrive( SDrive[0]-'A'+1, &total ) ; + chdir( SDir ) ; + getcwd( SearchPathname, _MAX_PATH ) ; + ChangeButtonString( &Selector, 0, SearchPathname, TRUE ) ; + ScanFiles( selection, flags ) ; + ScanDirs( selection ) ; + oldnum = -1 ; + break ; + + case 2: /* dirs */ + ChangeButtonFlags( &Selector, 2, FLAG_CENTRE+FLAG_PUSHED, 1 ) ; + ChangeButtonFlags( &Selector, 3, FLAG_CENTRE, 1 ) ; + ScanDirs( selection ) ; + mode = 0 ; + oldnum = -1 ; + break ; + + case 3: /* drives */ + ChangeButtonFlags( &Selector, 2, FLAG_CENTRE, 1 ) ; + ChangeButtonFlags( &Selector, 3, FLAG_CENTRE+FLAG_PUSHED, 1 ) ; + ScanDrives() ; + mode = 1 ; + oldnum = -1 ; + break ; + + case 4: /* selected */ + InputString( &Selector, 4, _MAX_PATH ) ; + _splitpath( SelectorPathname, SDrive, SDir, SName, SExt ) ; + strcpy( SelectorPathname, SName ) ; + _splitpath( selection, SDrive,SDir,SName,SExt ) ; + strcat( SelectorPathname, SExt ) ; + ChangeButtonString( &Selector, 4, SelectorPathname, 1 ) ; + oldnum = -1 ; + break ; + + case 6: /* ok */ + rcode = 1 ; + break ; + + case 5: /* cancel */ + rcode = 0 ; + break ; + } + + + if( rcode == 1 ) + { + _splitpath( SelectorPathname, SDrive, SDir, SName, SExt ) ; + strcpy( SelectorPathname, SearchPathname ) ; + strcat( SelectorPathname, "\\" ) ; + strcat( SelectorPathname, SName ) ; + strcat( SelectorPathname, SExt ) ; + + if( flags & SELECT_TEST_EXIST ) + { + if( FileSize( SelectorPathname ) != 0L ) + { + strcpy( defaultname, SelectorPathname ) ; + flag = -1 ; /* OK */ + } + else + { + strcpy( workstring, SelectorPathname ) ; + strcat( workstring, " n'existe pas !" ) ; + Message( workstring, TRUE ) ; + } + } + else if( flags & SELECT_TEST_OVERWRITE ) + { + if( FileSize( SelectorPathname ) != 0L ) + { + strcpy( workstring, SelectorPathname ) ; + strcat( workstring, " existe d‚j… !" ) ; + if( Confirm(workstring, "Ecrase", "Oups") == 1 ) + { /* ok */ + strcpy( defaultname, SelectorPathname ) ; + flag = -1 ; + } + } + else + { + strcpy( defaultname, SelectorPathname ) ; + flag = -1 ; /* OK */ + } + } + else + { + strcpy( defaultname, SelectorPathname ) ; + flag = -1 ; /* OK */ + } + + if( flag != -1 ) + { + DrawMenu( &Selector, -1,-1 ) ; + ScanFiles( selection, flags ) ; + if( !mode ) /* dir */ + { + ScanDirs( selection ) ; + } + else /* drive */ + { + ScanDrives() ; + } + ShowMouse( 1 ) ; + rcode = -1 ; + } + } + + if( rcode == 0 ) + { + strcpy( SelectorPathname, "" ) ; + flag = -1 ; + } + } + + Free( IndexFiles ) ; + Free( ListFiles ) ; + Free( IndexDirs ) ; + Free( ListDirs ) ; + + CloseMenu( &Selector ) ; + + while( Click OR Key OR Fire ) AffMouse() ; + + RestoreClip() ; + + /* restore drive/dir org */ + _dos_setdrive( memopath[0]-'A'+1, &total ) ; + chdir( memopath ) ; + + return rcode ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ diff --git a/LIB386/LIB_MIDI/BUILD.BAT b/LIB386/LIB_MIDI/BUILD.BAT new file mode 100644 index 0000000..48bb043 --- /dev/null +++ b/LIB386/LIB_MIDI/BUILD.BAT @@ -0,0 +1,15 @@ +call watcom10 + +pkunzip -o obj >NUL +copy wr\ail32.obj +wmake +pkzip -m obj *.obj >NUL + +call watcom9 + +pkunzip -o obj9 >NUL +copy wr\ail32.obj +wmake WATCOM9=yes +pkzip -m obj9 *.obj >NUL + +call watcom10 diff --git a/LIB386/LIB_MIDI/INCLUDE.C b/LIB386/LIB_MIDI/INCLUDE.C new file mode 100644 index 0000000..ece21bb --- /dev/null +++ b/LIB386/LIB_MIDI/INCLUDE.C @@ -0,0 +1,7 @@ +#include +#include +#include +#include +#include +#include +#include diff --git a/LIB386/LIB_MIDI/LIB_MIDI.H b/LIB386/LIB_MIDI/LIB_MIDI.H new file mode 100644 index 0000000..c9395bb --- /dev/null +++ b/LIB386/LIB_MIDI/LIB_MIDI.H @@ -0,0 +1,28 @@ +#ifdef WATCOM9 +#pragma library ("f:\projet\lib386\lib_midi\lb9_midi.lib"); +#else +#pragma library ("f:\projet\lib386\lib_midi\lib_midi.lib"); +#endif + +#include "f:\projet\lib386\lib_midi\ail32.h" // Audio Interface Library API function header + +extern char Midi_Driver[_MAX_PATH] ; +extern char Midi_Driver_Name[80] ; +extern WORD Midi_Driver_Enable ; + +extern char GTL_filename[_MAX_PATH] ; // fichier des sons + +extern void AskMidiVars(char ***,long **); +extern long InitMidiDLL(char *); +extern long InitMidi(void); +extern void InitPathMidiSampleFile(unsigned char *); +extern void ClearMidi(void); +extern void PlayMidi(unsigned char *); +extern void StopMidi(void); +extern long IsMidiPlaying(void); +extern void FadeMidiDown(short ); +extern void FadeMidiUp(short ); +extern void WaitFadeMidi(void); +extern void VolumeMidi(short ); +extern void SetLoopMidi(short ); +extern void DoLoopMidi(void); diff --git a/LIB386/LIB_MIDI/MAKEFILE b/LIB386/LIB_MIDI/MAKEFILE new file mode 100644 index 0000000..97d9ea3 --- /dev/null +++ b/LIB386/LIB_MIDI/MAKEFILE @@ -0,0 +1,57 @@ +# name the compiler +!ifdef %HOME +!ifeq WATCOM9 yes +CC = c:\compil\watcom\bin\wcc386p +WL = c:\compil\watcom\binb\wlib +!else +CC = c:\compil\watcom10\binb\wcc386 +WL = c:\compil\watcom10\binb\wlib +!endif +!else +!ifeq WATCOM9 yes +CC = f:\compil\watcom95\bin\wcc386 +WL = f:\compil\watcom95\binb\wlib +!else +CC = f:\compil\watcom10\binb\wcc386 +WL = f:\compil\watcom10\binb\wlib +!endif +!endif + +ASM = ml + +!ifeq WATCOM9 yes +CFLAGS = /oaxet /s /zp2 /4s /zq /DWATCOM9 +!else +CFLAGS = /oaxet /s /zp2 /5s /zq /wx +!endif +LFLAGS = -b -n -c -q +#AFLAGS = /m2 /mx /z /zi /t /jMASM51 /jQUIRKS +AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=; + + +OBJETS1 = midi.obj ail32.obj +OBJETS2 = +OBJETS3 = +OBJETS4 = + +!ifeq WATCOM9 yes +LIB = LB9_MIDI +!else +LIB = LIB_MIDI +!endif + +$(LIB).LIB: $(OBJETS1) $(OBJETS2) $(OBJETS3) $(OBJETS4) + + @echo $(OBJETS1) > clibmak.rsp + + @$(WL) $(LIBFLAGS) $(LIB) @clibmak.rsp + @del clibmak.rsp + @prntitre M "$(LIB) OK" + +.asm.obj: + @PRNTITRE M "$*.ASM" + @$(ASM) $(AFLAGS) $*.ASM + +.c.obj: + @PRNTITRE M "$*.C" + @$(CC) $(CFLAGS) $* diff --git a/LIB386/LIB_MIDI/MIDI.C b/LIB386/LIB_MIDI/MIDI.C new file mode 100644 index 0000000..6ea677d --- /dev/null +++ b/LIB386/LIB_MIDI/MIDI.C @@ -0,0 +1,461 @@ +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ +//ÛÛ ÛÛ +//ÛÛ Project: IBM Audio Interface Library for 32-bit DPMI (AIL/32) ÛÛ +//ÛÛ Author: John Miles ÛÛ +//ÛÛ ÛÛ +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ +//ÛÛ ÛÛ +//ÛÛ Gestionnaire Midi for Adeline Soft le 2/4/94 ÛÛ +//ÛÛ ÛÛ +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +#include +#include +#include +#include +#include +#include +#include + +#include "f:\projet\lib386\lib_sys\adeline.h" +#include "f:\projet\lib386\lib_sys\lib_sys.h" +#include "f:\projet\lib386\lib_midi\lib_midi.h" + +/***************************************************************/ + +void NewProc08() ; + +WORD Midi_Driver_Enable = FALSE ; + +char *DriverError = "Error MidiDriver:" ; + +char *ListIdentifier[] = { "MidiBase" , + "MidiIRQ" , + "MidiDMA" , + "" }; + +LONG Midi_Base, Midi_IRQ, Midi_DMA ; + + +HDRIVER hdriver ; +HSEQUENCE hseq = -1 ; +drvr_desc *desc; + +//FILE *GTL; +char *ptrGTL; +char MidiPath[_MAX_PATH]; + +char *state; +char *drvr,*dll; +char *timb; +char *tc_addr; + +unsigned char *ail_buffer; + +unsigned long state_size; +unsigned short ail_bank,patch,tc_size,seqnum; +unsigned short treq; + +WORD MidiLoop = FALSE ; + +LONG MaxVolume = 100 ; + +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +void AskMidiVars( char ***listidentifier, LONG **ptrvars ) +{ + *listidentifier = ListIdentifier ; + *ptrvars = &Midi_Base ; +} + +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ +// +// Standard C routine for Global Timbre Library access +// + +#ifdef ytuyjbd + +void *load_global_timbre(FILE *GTL, unsigned short bank, unsigned short patch) +{ + unsigned short *timb_ptr; + static unsigned short len; + + static struct // GTL file header entry structure + { + signed char patch; + signed char bank; + unsigned long offset; + } + GTL_hdr; + + + if (GTL==NULL) return NULL; // if no GTL, return failure + + rewind(GTL); // else rewind to GTL header + + do // search file for requested timbre + { + fread(>L_hdr,sizeof(GTL_hdr),1,GTL); + + if (GTL_hdr.bank == -1) + return NULL; // timbre not found, return NULL + } + while ((GTL_hdr.bank != bank) || + (GTL_hdr.patch != patch)); + + fseek(GTL,GTL_hdr.offset,SEEK_SET); + fread(&len,2,1,GTL); // timbre found, read its length + + timb_ptr = malloc(len); // allocate memory for timbre .. + *timb_ptr = len; + // and load it + fread((timb_ptr+1),len-2,1,GTL); + + if (ferror(GTL)) // return NULL if any errors + { + free(timb_ptr); + return NULL; // occurred + } + else + return timb_ptr; // else return pointer to timbre +} + +#endif + +void *load_global_timbre(unsigned short bank, unsigned short patch) +{ + static struct GTL_h // GTL file header entry structure + { + signed char patch; + signed char bank; + unsigned long offset; + } + *GTL_hdr; + + + GTL_hdr = (struct GTL_h *)ptrGTL ;// to GTL header + + // search file for requested timbre + while ((GTL_hdr->bank != bank) || + (GTL_hdr->patch != patch)) + { + if (GTL_hdr->bank == -1) + return NULL; // timbre not found, return NULL + + GTL_hdr++; + } + + return((void *)(ptrGTL + GTL_hdr->offset)) ; +} + +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +LONG InitMidiDLL( char *driverpathname ) +{ + char *str; + + // + // Load driver file + // + + dll = FILE_read( driverpathname, NULL); + if (dll==NULL) + { + printf("%s Could not load driver '%s'.\n", DriverError, driverpathname ); + return FALSE ; + } + + drvr=DLL_load(dll,DLLMEM_ALLOC | DLLSRC_MEM,NULL); + if (drvr==NULL) + { + printf("%s Invalid DLL image.\n", DriverError ); + return FALSE ; + } + + Free(dll); + + // + // Initialize API before calling any Library functions + // + + AIL_startup(); + + // + // Register the driver with the API + // + + hdriver = AIL_register_driver(drvr); + if (hdriver==-1) + { + printf("%s Driver %s not compatible with linked API version.\n", + DriverError, driverpathname ); + AIL_shutdown(NULL); + return FALSE ; + } + + // + // Get driver type and factory default I/O parameters; exit if + // driver is not capable of interpreting MIDI files + // + + desc = AIL_describe_driver(hdriver); + + if (desc->drvr_type != XMIDI_DRVR) + { + printf("%s Driver %s not an XMIDI driver.\n", DriverError, driverpathname ); + AIL_shutdown(NULL); + return FALSE ; + } + + + // + // Print Driver name and copyright notice + // + + printf("AIL/32 midi driver for:\n"); + + str = desc->dev_name_table ; + while(*str != 0) + { + printf("%s\n", str); + while(*str != 0) + str++; + str++; + } + + printf("\nCopyright (C) 1991,1992 Miles Design, Inc.\n\n"); + + return TRUE ; +} + +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +LONG InitMidi() +{ + char GTL_filename[_MAX_PATH]; + + // use if defined new parameters + + if( Midi_Base != -1 ) desc->default_IO = Midi_Base ; + if( Midi_IRQ != -1 ) desc->default_IRQ = Midi_IRQ ; + if( Midi_DMA != -1 ) + { + desc->default_DMA = Midi_DMA ; + desc->default_DRQ = Midi_DMA ; + } + + // + // Verify presence of driver's sound hardware and prepare + // driver/hardware for use + // + if (!AIL_detect_device(hdriver,desc->default_IO,desc->default_IRQ, + desc->default_DMA,desc->default_DRQ)) + { + AIL_shutdown(NULL); + printf( "%s Sound Hardware not found.\n", DriverError ) ; + return FALSE ; + } + + + Midi_Driver_Enable = TRUE ; + + AIL_init_driver(hdriver,desc->default_IO,desc->default_IRQ, + desc->default_DMA,desc->default_DRQ); + + state_size = AIL_state_table_size(hdriver); + // + // Set up local timbre cache; open Global Timbre Library file + // + + tc_size = AIL_default_timbre_cache_size(hdriver); + + if (tc_size) + { + tc_addr = malloc((unsigned long) tc_size); + AIL_define_timbre_cache(hdriver,tc_addr,tc_size); + } + + state = malloc(state_size); + + // + // Get name of Global Timbre Library file by appending suffix + // supplied by XMIDI driver to GTL filename prefix "SAMPLE." + // + strcpy(GTL_filename, MidiPath ) ; + strcat(GTL_filename,"SAMPLE."); + strcat(GTL_filename,desc->data_suffix); + + // Load it into memory + + if(!(ptrGTL = DosMalloc(FileSize(GTL_filename), NULL))) + return FALSE ; + + Load( GTL_filename, ptrGTL ); + + return TRUE ; +} + +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +void InitPathMidiSampleFile( UBYTE *path ) +{ +// +// Get name of Global Timbre Library file by appending suffix +// supplied by XMIDI driver to GTL filename prefix "SAMPLE." +// + strcpy(MidiPath, path ) ; +} + +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +void ClearMidi() +{ + if( !Midi_Driver_Enable ) return ; + + AIL_shutdown( "" ); + hseq = -1 ; +} + +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +void PlayMidi( /*char *filename*/ UBYTE *ail_buffer ) +{ + if( !Midi_Driver_Enable ) return ; + + // + // Look up and register desired sequence in XMIDI file, loading + // timbres if needed + // + if( hseq != -1 ) + { + AIL_stop_sequence(hdriver,hseq) ; + AIL_release_sequence_handle( hdriver, hseq ) ; + } + + seqnum = 0 ; + + if ((hseq = AIL_register_sequence( hdriver, + ail_buffer, + seqnum, + state, + NULL ) + ) == -1) + { +// printf("Sequence %u not present in XMIDI file \"%s\".\n",seqnum,argv[1]); + return ; + } + +// GTL = NULL ; + + while ((treq=AIL_timbre_request(hdriver,hseq)) != 0xffff) + { +// if( GTL == NULL ) +// { +// GTL = fopen(GTL_filename,"rb"); // sample.ad/.opl +// } + + ail_bank = treq / 256; patch = treq % 256; + +// timb = load_global_timbre(GTL,ail_bank,patch); + timb = load_global_timbre(ail_bank,patch); + + if (timb != NULL) + { +// printf("Installed timbre bank %u, patch %u\n",bank,patch); + AIL_install_timbre(hdriver,ail_bank,patch,timb); +// free(timb); + } + else + { +// printf("Timbre bank %u, patch %u not found ",bank,patch); +// if (GTL != NULL) fclose(GTL); + return ; + } +// AIL_install_timbre(hdriver,ail_bank,patch,timb); + } + + // + // Start music playback + // + +/* printf("Playing sequence %u from XMIDI file \"%s\" ...\n\n", + seqnum,argv[1]); */ + + AIL_start_sequence(hdriver,hseq) ; +} + +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +void StopMidi() +{ + if( hseq != -1 ) + { + AIL_stop_sequence(hdriver,hseq) ; + AIL_release_sequence_handle( hdriver, hseq ) ; + hseq = -1 ; + } +} + +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +LONG IsMidiPlaying() +{ + if( hseq != -1 ) + { + if( AIL_sequence_status( hdriver, hseq ) == 1 ) + return TRUE ; + } + return FALSE ; +} + +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +void FadeMidiDown( WORD nbsec ) +{ + if( hseq != -1 ) + { + AIL_set_relative_volume(hdriver, 0, 0, 1000 * nbsec ) ; + } +} + +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +void FadeMidiUp( WORD nbsec ) +{ + if( hseq != -1 ) + { + AIL_set_relative_volume(hdriver, 0, MaxVolume, 1000 * nbsec ) ; + } +} +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +void WaitFadeMidi() +{ + if( hseq != -1 ) + { + while( AIL_relative_volume( hdriver, 0 ) != 0 ) ; + } +} + +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +void VolumeMidi( WORD volume ) +{ + if( hseq != -1 ) + { + AIL_set_relative_volume(hdriver, 0, (volume*MaxVolume)/100, 0 ) ; + } +} + +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +void DoLoopMidi() +{ + // loop track + + if( hseq != -1 ) + if( AIL_sequence_status( hdriver, 0 ) == 2 ) // seg done + AIL_start_sequence(hdriver,hseq) ; +} + +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ diff --git a/LIB386/LIB_MIDI/README.md b/LIB386/LIB_MIDI/README.md new file mode 100644 index 0000000..e5992f8 --- /dev/null +++ b/LIB386/LIB_MIDI/README.md @@ -0,0 +1,41 @@ +# LIB_MIDI + +In order to build LIB_MIDI, following third party SDK is required: + - Miles Sound System AIL32 v1.0 + +AIL32 v1.0 is licensed under "Copyright (C) 1991, 1992 Miles Design, Inc." +terms and so is not delivered in this package. + +Following files from AIL32 SDK are expected to be in LIB_MIDI folder: + +``` ++---LIB_MIDI +| | A32ADLIB.DLL +| | A32ALGFM.DLL +| | A32GFX.DLL +| | A32MT32.DLL +| | A32OP3FM.DLL +| | A32PASFM.DLL +| | A32PASOP.DLL +| | A32SP1FM.DLL +| | A32SP2FM.DLL +| | A32SPKR.DLL +| | A32TANDY.DLL +| | AIL32.H +| | GUSMID32.DLL +| | +| +---GUS +| | DEMO.BAT +| | DEMO.XMI +| | DLLLOAD.C +| | DOS4GW.EXE +| | GUSDIG32.DLL +| | GUSMID32.DLL +| | LOADPATS.EXE +| | PATCHES.INI +| | README +| | VPRICE.VOC +| | +| +---WR +| AIL32.OBJ +``` \ No newline at end of file diff --git a/LIB386/LIB_MIX/BUILD.BAT b/LIB386/LIB_MIX/BUILD.BAT new file mode 100644 index 0000000..3b9991b --- /dev/null +++ b/LIB386/LIB_MIX/BUILD.BAT @@ -0,0 +1,13 @@ +call watcom10 + +pkunzip -o obj >NUL +wmake +pkzip -m obj *.obj >NUL + +call watcom9 + +pkunzip -o obj9 >NUL +wmake WATCOM9=yes +pkzip -m obj9 *.obj >NUL + +call watcom10 diff --git a/LIB386/LIB_MIX/BUILDDLL.BAT b/LIB386/LIB_MIX/BUILDDLL.BAT new file mode 100644 index 0000000..9919641 --- /dev/null +++ b/LIB386/LIB_MIX/BUILDDLL.BAT @@ -0,0 +1,3 @@ +pkunzip -o obj >NUL +wmake /f mix_dll.mak +pkzip -m obj *.obj >NUL diff --git a/LIB386/LIB_MIX/LIB_MIX.H b/LIB386/LIB_MIX/LIB_MIX.H new file mode 100644 index 0000000..ef6cf7e --- /dev/null +++ b/LIB386/LIB_MIX/LIB_MIX.H @@ -0,0 +1,85 @@ +#ifdef WATCOM9 +#pragma library ("f:\projet\lib386\lib_mix\lb9_mix.lib"); +#else +#pragma library ("f:\projet\lib386\lib_mix\lib_mix.lib"); +#endif + +extern LONG Mixer_Driver_Enable; + +/*----------------------------------------------------------------------*/ +/* MixerAskVars : Get list of vars for the lib */ +/* */ +/* listidentifier : pointer to an array of string*/ +/* pointers, each string */ +/* contains the name of the var */ +/* to initialise for the DLL */ +/* ptrvars : pointer to an array of DWORD to */ +/* store the value of each var in */ +/* listidentifier */ +/* */ +/* Returns : nothing */ +/*----------------------------------------------------------------------*/ +void MixerAskVars( char ***listidentifier, + LONG **ptrvars ); + + +/*----------------------------------------------------------------------*/ +/* MixerChangeVolume : Change the hardware volume for MIDI, */ +/* WAVE, CD, Line, Master */ +/* */ +/* VolWave : Volume for WAVE (0-255) */ +/* VolMidi : Volume for MIDI (0-255) */ +/* VolCD : Volume for CD (0-255) */ +/* VolLine : Volume for LINE (0-255) */ +/* VolMaster : Volume for MASTER (0-255) */ +/* */ +/* NOTE : A VOLUME OF -1 MEANS NO CHANGE */ +/* */ +/* Returns : nothing */ +/*----------------------------------------------------------------------*/ +void MixerChangeVolume( LONG VolWave, + LONG VolMidi, + LONG VolCD, + LONG VolLine, + LONG VolMaster ); + + +/*----------------------------------------------------------------------*/ +/* MixerGetVolume : Get the hardware volume for MIDI, WAVE, */ +/* CD, Line and Master */ +/* */ +/* VolWave : ptr on Volume for WAVE (0-255) */ +/* VolMidi : ptr on Volume for MIDI (0-255) */ +/* VolCD : ptr on Volume for CD (0-255) */ +/* VolLine : ptr on Volume for LINE (0-255) */ +/* VolMaster : ptr on Volume for MASTER (0-255) */ +/* */ +/* NOTE : A NULL PTR MEANS NO GET */ +/* */ +/* Returns : nothing */ +/*----------------------------------------------------------------------*/ +void MixerGetVolume( LONG *VolWave, + LONG *VolMidi, + LONG *VolCD, + LONG *VolLine, + LONG *VolMaster ); + + +/*----------------------------------------------------------------------*/ +/* MixerGetInfo : Get the hardware volume capabilities */ +/* */ +/* VolWave : ptr on Volume for WAVE (0/1) */ +/* VolMidi : ptr on Volume for MIDI (0/1) */ +/* VolCD : ptr on Volume for CD (0/1) */ +/* VolLine : ptr on Volume for LINE (0/1) */ +/* VolMaster : ptr on Volume for MASTER (0/1) */ +/* */ +/* NOTE : A NULL PTR MEANS NO GET */ +/* */ +/* Returns : nothing */ +/*----------------------------------------------------------------------*/ +void MixerGetInfo( LONG *VolWave, + LONG *VolMidi, + LONG *VolCD, + LONG *VolLine, + LONG *VolMaster ); diff --git a/LIB386/LIB_MIX/MAKEFILE b/LIB386/LIB_MIX/MAKEFILE new file mode 100644 index 0000000..7ec2bec --- /dev/null +++ b/LIB386/LIB_MIX/MAKEFILE @@ -0,0 +1,54 @@ +# name the compiler +!ifdef %HOME +!ifeq WATCOM9 yes +CC = c:\compil\watcom\bin\wcc386p +WL = c:\compil\watcom\binb\wlib +!else +CC = c:\compil\watcom10\binb\wcc386 +WL = c:\compil\watcom10\binb\wlib +!endif +!else +!ifeq WATCOM9 yes +CC = f:\compil\watcom\bin\wcc386p +WL = f:\compil\watcom\binb\wlib +!else +CC = f:\compil\watcom10\binb\wcc386 +WL = f:\compil\watcom10\binb\wlib +!endif +!endif + +ASM = ml + +!ifeq WATCOM9 yes +CFLAGS = /oeaxt /zp2 /4s /zq /s /DWATCOM9 +!else +CFLAGS = /oeaxt /zp2 /5s /zq /s +!endif +LFLAGS = /c /q /b /n +#AFLAGS = /m2 /mx /z /zi /t /jMASM51 /jQUIRKS +AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=; + +OBJETS1 = mixer.obj mixer_i.obj +OBJETS2 = +OBJETS3 = +OBJETS4 = + +!ifeq WATCOM9 yes +LIB = LB9_MIX +!else +LIB = LIB_MIX +!endif + +$(LIB).LIB: $(OBJETS1) $(OBJETS2) $(OBJETS3) $(OBJETS4) + @echo $(OBJETS1) > clibmak.rsp + @$(WL) $(LIBFLAGS) $(LIB) @clibmak.rsp + @del clibmak.rsp + @prntitre M "$(LIB) OK" + +.asm.obj: + @PRNTITRE M "$*.ASM" + @$(ASM) $(AFLAGS) $*.ASM + +.c.obj: + @PRNTITRE M "$*.C" + @$(CC) $(CFLAGS) $* diff --git a/LIB386/LIB_MIX/MIXER.C b/LIB386/LIB_MIX/MIXER.C new file mode 100644 index 0000000..0422cb6 --- /dev/null +++ b/LIB386/LIB_MIX/MIXER.C @@ -0,0 +1,50 @@ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + SAMP.C 386 + (c) Adeline 1993 + *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_mix\lib_mix.h" +#include +#include +#include +#include + +char *MixerError = "Error MixerDriver:"; + +extern void *Mixer_listfcts; +extern LONG Mixer_Driver_Enable; + +/*-------------------------------------------------------------------------*/ +LONG MixerInitDLL(char *driverpathname) +{ + char *dll, *drvr; + + // + // Load driver file + // + + dll = FILE_read( driverpathname, NULL); + if (dll==NULL) + { + printf("%s Could not load driver '%s'.\n", MixerError, driverpathname ); + return FALSE ; + } + + drvr=DLL_load(dll,DLLMEM_ALLOC | DLLSRC_MEM,NULL); + if (drvr==NULL) + { + printf("%s Invalid DLL image.\n", MixerError ); + return FALSE ; + } + + Free(dll); + + Mixer_listfcts = *(void **)drvr; + printf("%s", drvr+4); + + return (Mixer_Driver_Enable = TRUE); +} + +/*-------------------------------------------------------------------------*/ diff --git a/LIB386/LIB_MIX/MIXER_A.ASM b/LIB386/LIB_MIX/MIXER_A.ASM new file mode 100644 index 0000000..85a47de --- /dev/null +++ b/LIB386/LIB_MIX/MIXER_A.ASM @@ -0,0 +1,1384 @@ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; MIXER_A.ASM 386 +; (c) Adeline 1993 +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + + .386 + jumps + + .model FLAT, SYSCALL + + .CODE + +;*--------------------------------------------------------------------------* + +IFDEF SB16 + SBLASTER equ 1 +ENDIF + +IFDEF SBPRO + SBLASTER equ 1 +ENDIF + +IFDEF SB2CD + SBLASTER equ 1 +ENDIF + +;*--------------------------------------------------------------------------* + + PUBLIC driver_start + +driver_start dd OFFSET ListFuncs + +IFDEF SB16 + db 'Sound Blaster 16 Mixer (CT1745) Driver' +ENDIF + +IFDEF SBPRO + db 'Sound Blaster Pro Mixer (CT1345) Driver' +ENDIF + +IFDEF SB2CD + db 'Sound Blaster 2 CD Interface Mixer (CT1335) Driver' +ENDIF + +IFDEF MWSS + db 'Microsoft Windows Sound System Mixer (AD1848 SoundPort) Driver' +ENDIF + +IFDEF GOLD + db 'Adlib Gold Mixer (Yamaha GOLD) Driver' +ENDIF + +IFDEF PAS + db 'Media Vision Pro Audio Spectrum/Spectrum Plus/Spectrum 16 Mixer Driver' +ENDIF + db ', Version 1.00,', 13, 10 + db 'Copyright (c) Adeline Software International 1994, All Rights Reserved.', 13, 10, 10, 0 + + +ListFuncs dd offset AskVars + + dd offset SetMixerVolume + dd offset GetMixerVolume + dd offset GetMixerInfo + +;*--------------------------------------------------------------------------* + +MixerBase db 'MixerBase' +Empty db 0 + +IFDEF PAS + +ListNames dd offset Empty + +MV_filter dd ? +MV_xchannel dd ? + +MVP_name db 'MVPROAS',0 + +MV_vl_txt db 'SET OUTPUT MIXER LEFT ' +MV_dl db 'PCM ' + db 'TO ' +MV_vl db '0' + db '0' + db '0' + db '%',13 +MV_vl_len equ ($-MV_vl_txt) + +MV_vr_txt db 'SET OUTPUT MIXER RIGHT ' +MV_dr db 'PCM ' + db 'TO ' +MV_vr db '0' + db '0' + db '0' + db '%',13 +MV_vr_len equ ($-MV_vr_txt) + +MV_ml_txt db 'SET VOLUME LEFT LEVEL TO ' +MV_ml db '0' + db '0' + db '0' + db '%',13 +MV_ml_len equ ($-MV_ml_txt) + +MV_mr_txt db 'SET VOLUME RIGHT LEVEL TO ' +MV_mr db '0' + db '0' + db '0' + db '%',13 +MV_mr_len equ ($-MV_mr_txt) + +ELSE + +ListNames dd offset MixerBase + dd offset Empty + +ENDIF + +;*--------------------------------------------------------------------------* +;*--------------------------------------------------------------------------* + +AskVars PROC ,\ + pListNames:DWORD, pListVars:DWORD + + mov eax, pListNames + mov dword ptr[eax], offset ListNames + mov eax, pListVars + mov dword ptr[eax], offset ListVars + ret + +AskVars ENDP + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +IFDEF PAS + +ListVars equ $ + +;---------------------------------------------------------------------------- + +SVolVoice dd 255 +SVolMidi dd 255 +SVolCD dd 255 +SVolLine dd 255 +SVolMaster dd 255 + +;---------------------------------------------------------------------------- + +decstr PROC USES ebx esi edi es,\ ;Decimal ASCII to string buffer + Buf,Num ;(no lz suppression) + LOCAL accum + + cld + + push ds + pop es + + mov edi,[Buf] + mov eax,[Num] + mov accum,eax + + mov ecx,100 +__div_loop: mov eax,accum + mov edx,0 + div ecx + mov accum,edx + add eax,'0' + + stosb + + mov eax,ecx + mov edx,0 + mov ebx,10 + div ebx + mov ecx,eax + cmp eax,0 + jne __div_loop + + ret +decstr ENDP + +;---------------------------------------------------------------------------- + +send_MV_cmd PROC USES ebx esi edi,\ ;Send command string to MVPROAS + String,Len ;(device alias for MVSOUND.SYS) + LOCAL handle + + mov eax,3d02h ;open MVPROAS for writing + mov edx,OFFSET MVP_name + int 21h + jc __exit + mov handle,eax + + mov ebx,eax ;write the command string + mov ah,40h + mov ecx,[Len] + mov edx,[String] + int 21h + + mov ah,3eh ;close MVPROAS + mov ebx,handle + int 21h +__exit: + ret +send_MV_cmd ENDP + +;---------------------------------------------------------------------------- + +SetMixerVolume PROC USES EDI\ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + mov dword ptr[MV_dr], 2043494Dh ; 'MIC ' + mov edi,OFFSET MV_vr + invoke decstr,edi,0 + mov edi,OFFSET MV_vr_txt + mov ecx,MV_vr_len + invoke send_MV_cmd,edi,ecx + + mov dword ptr[MV_dl], 2043494Dh + mov edi,OFFSET MV_vl + invoke decstr,edi,0 + mov edi,OFFSET MV_vl_txt + mov ecx,MV_vl_len + invoke send_MV_cmd,edi,ecx + + mov eax, VolVoice + cmp eax, -1 + je novoice + + mov SVolVoice, eax + + imul ax, 100 + xor dx, dx + mov cx, 255 + div cx + + push eax + + mov dword ptr[MV_dr], 204D4350h ; 'PCM ' + mov edi,OFFSET MV_vr + invoke decstr,edi,eax + mov edi,OFFSET MV_vr_txt + mov ecx,MV_vr_len + invoke send_MV_cmd,edi,ecx + + pop eax + + mov dword ptr[MV_dl], 204D4350h + mov edi,OFFSET MV_vl + invoke decstr,edi,eax + mov edi,OFFSET MV_vl_txt + mov ecx,MV_vl_len + invoke send_MV_cmd,edi,ecx + +novoice: + mov eax, VolMidi + cmp eax, -1 + je nomidi + + mov SVolMidi, eax + + imul ax, 100 + xor dx, dx + mov cx, 255 + div cx + + push eax + + mov dword ptr[MV_dr], 20204D46h ; 'FM ' + mov edi,OFFSET MV_vr + invoke decstr,edi,eax + mov edi,OFFSET MV_vr_txt + mov ecx,MV_vr_len + invoke send_MV_cmd,edi,ecx + + pop eax + + mov dword ptr[MV_dl], 20204D46h + mov edi,OFFSET MV_vl + invoke decstr,edi,eax + mov edi,OFFSET MV_vl_txt + mov ecx,MV_vl_len + invoke send_MV_cmd,edi,ecx + +nomidi: + mov eax, VolCD + cmp eax, -1 + je nocd + + mov SVolCD, eax + + imul ax, 100 + xor dx, dx + mov cx, 255 + div cx + + push eax + + mov dword ptr[MV_dr], 20204443h ; 'CD ' + mov edi,OFFSET MV_vr + invoke decstr,edi,eax + mov edi,OFFSET MV_vr_txt + mov ecx,MV_vr_len + invoke send_MV_cmd,edi,ecx + + pop eax + + mov dword ptr[MV_dl], 20204443h + mov edi,OFFSET MV_vl + invoke decstr,edi,eax + mov edi,OFFSET MV_vl_txt + mov ecx,MV_vl_len + invoke send_MV_cmd,edi,ecx + +nocd: + mov eax, VolLine + cmp eax, -1 + je noline + + mov SVolLine, eax + + imul ax, 100 + xor dx, dx + mov cx, 255 + div cx + + push eax + + mov dword ptr[MV_dr], 20545845h ; 'EXT ' + mov edi,OFFSET MV_vr + invoke decstr,edi,eax + mov edi,OFFSET MV_vr_txt + mov ecx,MV_vr_len + invoke send_MV_cmd,edi,ecx + + pop eax + + mov dword ptr[MV_dl], 20545845h + mov edi,OFFSET MV_vl + invoke decstr,edi,eax + mov edi,OFFSET MV_vl_txt + mov ecx,MV_vl_len + invoke send_MV_cmd,edi,ecx + +noline: + mov eax, VolMaster + cmp eax, -1 + je nomaster + + mov SVolMaster, eax + + imul ax, 100 + xor dx, dx + mov cx, 255 + div cx + + push eax + + mov edi,OFFSET MV_mr + invoke decstr,edi,eax + mov edi,OFFSET MV_mr_txt + mov ecx,MV_mr_len + invoke send_MV_cmd,edi,ecx + + pop eax + + mov edi,OFFSET MV_ml + invoke decstr,edi,eax + mov edi,OFFSET MV_ml_txt + mov ecx,MV_ml_len + invoke send_MV_cmd,edi,ecx +nomaster: + ret + +SetMixerVolume ENDP + +;---------------------------------------------------------------------------- + +GetMixerVolume PROC uses EBX,\ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + mov edx, VolMaster + or edx, edx + jz nomaster + + mov eax, SVolMaster + mov [edx], eax +nomaster: + mov edx, VolLine + or edx, edx + jz noline + + mov eax, SVolLine + mov [edx], eax +noline: + mov edx, VolCD + or edx, edx + jz nocd + + mov eax, SVolCD + mov [edx], ebx +nocd: + mov edx, VolMidi + or edx, edx + jz nomidi + + mov eax, SVolMidi + mov [edx], eax +nomidi: + mov edx, VolVoice + or edx, edx + jz novoice + + mov eax, SVolVoice + mov [edx], ecx +novoice: + ret + +GetMixerVolume ENDP + +;---------------------------------------------------------------------------- + +GetMixerInfo PROC \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + + mov ecx, VolVoice + or ecx, ecx + jz novoice + + mov dword ptr[ecx], 1 +novoice: + mov ecx, VolLine + or ecx, ecx + jz noline + + mov dword ptr[ecx], 1 +noline: + mov ecx, VolMidi + or ecx, ecx + jz nomidi + + mov dword ptr[ecx], 1 +nomidi: + mov ecx, VolCD + or ecx, ecx + jz nocd + + mov dword ptr[ecx], 1 +nocd: + mov ecx, VolMaster + or ecx, ecx + jz nomaster + + mov dword ptr[ecx], 1 +nomaster: + ret + +GetMixerInfo ENDP + +ENDIF + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +IFDEF MWSS + +ListVars equ $ +BASE_ADDR dd 530h ; By default 530h + +;---------------------------------------------------------------------------- + +WRITE_MIXER MACRO REG, VAL ; write to MIXER chip + + mov al, REG + out dx, al + inc dx + mov al, VAL + out dx, al + dec dx + + ENDM + +READ_MIXER MACRO REG ; read from MIXER chip + + mov al, REG + out dx, al + inc dx + in al, dx + dec dx + + ENDM + +;---------------------------------------------------------------------------- + +SetMixerVolume PROC \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + mov dx, word ptr[BASE_ADDR] + add dx, 4 + + mov eax, VolVoice + cmp eax, -1 + je novoice + + not al + shr al, 2 + mov ah, al + WRITE_MIXER 06h, ah + WRITE_MIXER 07h, ah +novoice: + mov eax, VolLine + cmp eax, -1 + je noline + + not al + shr al, 4 + mov ah, al + WRITE_MIXER 02h, ah + WRITE_MIXER 03h, ah +noline: + mov ah, 000000b + ret + +SetMixerVolume ENDP + +;---------------------------------------------------------------------------- + +GetMixerVolume PROC \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + + mov ecx, VolVoice + or ecx, ecx + jz novoice + + mov dx, word ptr[BASE_ADDR] + add dx, 4 + READ_MIXER 06h + not al + shl al, 2 + and eax, 255 + mov dword ptr[ecx], eax +novoice: + mov ecx, VolLine + or ecx, ecx + jz noline + + READ_MIXER 02h + not al + shl al, 4 + and eax, 255 + mov dword ptr[ecx], eax +noline: + mov ecx, VolMidi + or ecx, ecx + jz nomidi + + mov dword ptr[ecx], 255 +nomidi: + mov ecx, VolCD + or ecx, ecx + jz nocd + + mov dword ptr[ecx], 0 +nocd: + mov ecx, VolMaster + or ecx, ecx + jz nomaster + + mov dword ptr[ecx], 255 +nomaster: + ret + +GetMixerVolume ENDP + +;---------------------------------------------------------------------------- + +GetMixerInfo PROC \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + + mov ecx, VolVoice + or ecx, ecx + jz novoice + + mov dword ptr[ecx], 1 +novoice: + mov ecx, VolLine + or ecx, ecx + jz noline + + mov dword ptr[ecx], 1 +noline: + mov ecx, VolMidi + or ecx, ecx + jz nomidi + + mov dword ptr[ecx], 0 +nomidi: + mov ecx, VolCD + or ecx, ecx + jz nocd + + mov dword ptr[ecx], 0 +nocd: + mov ecx, VolMaster + or ecx, ecx + jz nomaster + + mov dword ptr[ecx], 0 +nomaster: + ret + +GetMixerInfo ENDP + +ENDIF + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +IFDEF SBLASTER + +WRITE_MIXER MACRO REG, VAL ; write to MIXER chip + + mov al, REG + out dx, al + inc dx + mov al, VAL + out dx, al + dec dx + + ENDM + +READ_MIXER MACRO REG ; read from MIXER chip + + mov al, REG + out dx, al + inc dx + in al, dx + dec dx + + ENDM + +ENDIF + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +IFDEF SB16 + +ListVars equ $ +BASE_ADDR dd 220h ; By default 220h + +;---------------------------------------------------------------------------- + +SetMixerVolume PROC \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + mov dx, word ptr[BASE_ADDR] ; MIXER + add dl, 4 ; offset 4 + + WRITE_MIXER 3Ch, 00011110b ; disable MIC + WRITE_MIXER 3Bh, 0 ; disable PC Speaker + + mov ecx, VolVoice + cmp ecx, -1 + je novoice + + WRITE_MIXER 32h, cl + WRITE_MIXER 33h, cl +novoice: + mov ecx, VolMidi + cmp ecx, -1 + je nomidi + + WRITE_MIXER 34h, cl + WRITE_MIXER 35h, cl +nomidi: + mov ecx, VolCD + cmp ecx, -1 + je nocd + + WRITE_MIXER 36h, cl + WRITE_MIXER 37h, cl +nocd: + mov ecx, VolLine + cmp ecx, -1 + je noline + + WRITE_MIXER 38h, cl + WRITE_MIXER 39h, cl +noline: + mov ecx, VolMaster + cmp ecx, -1 + je nomaster + + WRITE_MIXER 30h, cl + WRITE_MIXER 31h, cl +nomaster: + ret + +SetMixerVolume ENDP + +;---------------------------------------------------------------------------- + +GetMixerVolume PROC uses EBX,\ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + mov dx, word ptr[BASE_ADDR] ; MIXER + add dl, 4 ; offset 4 + + READ_MIXER 32h + mov cl, al + READ_MIXER 34h + mov ch, cl + READ_MIXER 36h + mov bl, al + READ_MIXER 38h + mov bh, al + READ_MIXER 30h + + mov edx, VolMaster + or edx, edx + jz nomaster + + and eax, 11111000b + mov [edx], eax +nomaster: + mov edx, VolLine + or edx, edx + jz noline + + mov al, bh + and eax, 11111000b + mov [edx], eax +noline: + mov edx, VolCD + or edx, edx + jz nocd + + and ebx, 11111000b + mov [edx], ebx +nocd: + mov edx, VolMidi + or edx, edx + jz nomidi + + mov al, ch + and eax, 11111000b + mov [edx], eax +nomidi: + mov edx, VolVoice + or edx, edx + jz novoice + + and ecx, 11111000b + mov [edx], ecx +novoice: + ret + +GetMixerVolume ENDP + +;---------------------------------------------------------------------------- + +GetMixerInfo PROC \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + + mov ecx, VolVoice + or ecx, ecx + jz novoice + + mov dword ptr[ecx], 1 +novoice: + mov ecx, VolLine + or ecx, ecx + jz noline + + mov dword ptr[ecx], 1 +noline: + mov ecx, VolMidi + or ecx, ecx + jz nomidi + + mov dword ptr[ecx], 1 +nomidi: + mov ecx, VolCD + or ecx, ecx + jz nocd + + mov dword ptr[ecx], 1 +nocd: + mov ecx, VolMaster + or ecx, ecx + jz nomaster + + mov dword ptr[ecx], 1 +nomaster: + ret + +GetMixerInfo ENDP + +ENDIF + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +IFDEF SBPRO + +ListVars equ $ +BASE_ADDR dd 220h ; By default 220h + +;---------------------------------------------------------------------------- + +SetMixerVolume PROC \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + mov dx, word ptr[BASE_ADDR] ; MIXER + add dl, 4 ; offset 4 + + WRITE_MIXER 0Ah , 0 ; MIC off + + mov eax, VolVoice + cmp eax, -1 + je novoice + + mov ah, al + shr ah, 4 + and al, 11110000b + or ah, al + and ah, 11101110b + WRITE_MIXER 04h, ah +novoice: + mov eax, VolMidi + cmp eax, -1 + je nomidi + + mov ah, al + shr ah, 4 + and al, 11110000b + or ah, al + and ah, 11101110b + WRITE_MIXER 26h, ah +nomidi: + mov eax, VolCD + cmp eax, -1 + je nocd + + mov ah, al + shr ah, 4 + and al, 11110000b + or ah, al + and ah, 11101110b + WRITE_MIXER 28h, ah +nocd: + mov eax, VolLine + cmp eax, -1 + je noline + + mov ah, al + shr ah, 4 + and al, 11110000b + or ah, al + and ah, 11101110b + WRITE_MIXER 2Eh, ah +noline: + mov eax, VolMaster + cmp eax, -1 + je nomaster + + mov ah, al + shr ah, 4 + and al, 11110000b + or ah, al + and ah, 11101110b + WRITE_MIXER 22h, ah +nomaster: + ret + +SetMixerVolume ENDP + +;---------------------------------------------------------------------------- + +GetMixerVolume PROC \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine, VolMaster:DWORD + + mov dx, word ptr[BASE_ADDR] ; MIXER + add dl, 4 ; offset 4 + + mov ecx, VolVoice + or ecx, ecx + jz novoice + + READ_MIXER 04h + and eax, 11100000b + mov [ecx], eax +novoice: + mov ecx, VolMidi + or ecx, ecx + jz nomidi + + READ_MIXER 26h + and eax, 11100000b + mov [ecx], eax +nomidi: + mov ecx, VolCD + or ecx, ecx + jz nocd + + READ_MIXER 28h + and eax, 11100000b + mov [ecx], eax +nocd: + mov ecx, VolLine + or ecx, ecx + jz noline + + READ_MIXER 2Eh + and eax, 11100000b + mov [ecx], eax +noline: + mov ecx, VolMaster + or ecx, ecx + jz nomaster + + READ_MIXER 22h + and eax, 11100000b + mov [ecx], eax +nomaster: + ret + +GetMixerVolume ENDP + +;---------------------------------------------------------------------------- + +GetMixerInfo PROC \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + + mov ecx, VolVoice + or ecx, ecx + jz novoice + + mov dword ptr[ecx], 1 +novoice: + mov ecx, VolLine + or ecx, ecx + jz noline + + mov dword ptr[ecx], 1 +noline: + mov ecx, VolMidi + or ecx, ecx + jz nomidi + + mov dword ptr[ecx], 1 +nomidi: + mov ecx, VolCD + or ecx, ecx + jz nocd + + mov dword ptr[ecx], 1 +nocd: + mov ecx, VolMaster + or ecx, ecx + jz nomaster + + mov dword ptr[ecx], 1 +nomaster: + ret + +GetMixerInfo ENDP + +ENDIF + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +IFDEF SB2CD + +ListVars equ $ +BASE_ADDR dd 220h ; By default 220h + +;---------------------------------------------------------------------------- + +SetMixerVolume PROC \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + mov dx, word ptr[BASE_ADDR] ; MIXER + add dl, 4 ; offset 4 + + mov eax, VolVoice + cmp eax, -1 + je novoice + + shl ax, 3 + and ah, 00000110b + WRITE_MIXER 0Ah, ah +novoice: + mov eax, VolMidi + cmp eax, -1 + je nomidi + + shl ax, 4 + and ah, 00001110b + WRITE_MIXER 06h, ah +nomidi: + mov eax, VolCD + cmp eax, -1 + je nocd + + shl ax, 4 + and ah, 00001110b + WRITE_MIXER 08h, ah +nocd: + mov eax, VolMaster + cmp eax, -1 + je nomaster + + shl ax, 4 + and ah, 00001110b + WRITE_MIXER 02h, ah +nomaster: + ret + +SetMixerVolume ENDP + +;---------------------------------------------------------------------------- + +GetMixerVolume PROC \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + mov dx, word ptr[BASE_ADDR] ; MIXER + add dl, 4 ; offset 4 + + mov ecx, VolVoice + or ecx, ecx + jz novoice + + READ_MIXER 0Ah + and eax, 00000110b + shl eax, 5 + mov [ecx], eax +novoice: + mov ecx, VolMidi + or ecx, ecx + jz nomidi + + READ_MIXER 06h + and eax, 00001110b + shl eax, 4 + mov [ecx], eax +nomidi: + mov ecx, VolCD + or ecx, ecx + jz nocd + + READ_MIXER 08h + and eax, 00001110b + shl eax, 4 + mov [ecx], eax +nocd: + mov ecx, VolLine + or ecx, ecx + jz noline + + mov dword ptr[ecx], 0 +noline: + mov ecx, VolMaster + or ecx, ecx + jz nomaster + + READ_MIXER 02h + and eax, 00001110b + shl eax, 4 + mov [ecx], eax +nomaster: + ret + +GetMixerVolume ENDP + +;---------------------------------------------------------------------------- + +GetMixerInfo PROC \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + + mov ecx, VolVoice + or ecx, ecx + jz novoice + + mov dword ptr[ecx], 1 +novoice: + mov ecx, VolLine + or ecx, ecx + jz noline + + mov dword ptr[ecx], 0 +noline: + mov ecx, VolMidi + or ecx, ecx + jz nomidi + + mov dword ptr[ecx], 1 +nomidi: + mov ecx, VolCD + or ecx, ecx + jz nocd + + mov dword ptr[ecx], 1 +nocd: + mov ecx, VolMaster + or ecx, ecx + jz nomaster + + mov dword ptr[ecx], 1 +nomaster: + ret + +GetMixerInfo ENDP + +ENDIF + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +IFDEF GOLD + +ListVars equ $ +BASE_ADDR dd 388h ; By default 388h + +;---------------------------------------------------------------------------- + +SELECT_MIXER MACRO + local wait + + cli + + mov al, 0FFh + out dx, al + out dx, al +wait: in al, dx + and al, 11000000b + jnz wait + + ENDM + +LEAVE_MIXER MACRO + local wait + +wait: in al, dx + and al, 11000000b + jnz wait + mov al, 0FEh + out dx, al + out dx, al + + sti + + ENDM + +WRITE_MIXER MACRO PORT, VAL + local wait1, wait2 + + mov al, PORT + out dx, al +wait1: in al, dx + and al, 11000000b + jnz wait1 + inc dx + mov al, VAL + out dx, al + dec dx +wait2: in al, dx + and al, 11000000b + jnz wait2 + + ENDM + +READ_MIXER MACRO PORT + local wait1, wait2 + + mov al, PORT + out dx, al +wait1: in al, dx + and al, 11000000b + jnz wait1 + inc dx + in al, dx + dec dx + mov ah, al +wait2: in al, dx + and al, 11000000b + jnz wait2 + mov al, ah + + ENDM + +;---------------------------------------------------------------------------- + +SetMixerVolume PROC \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + mov dx, word ptr[BASE_ADDR] + add dx, 2 ; MIXER + + SELECT_MIXER + + WRITE_MIXER 0Fh, 10000000b ; MIC off + WRITE_MIXER 10h, 10000000b ; TEL off + + mov ecx, VolVoice + cmp ecx, -1 + je novoice + + shr cl, 1 + or cl, 10000000b + WRITE_MIXER 0Bh, cl + WRITE_MIXER 0Ch, cl +novoice: + mov ecx, VolMidi + cmp ecx, -1 + je nomidi + + shr cl, 1 + or cl, 10000000b + WRITE_MIXER 09h, cl + WRITE_MIXER 0Ah, cl +nomidi: + mov ecx, VolCD + cmp ecx, -1 + je noCD + + shr cl, 1 + or cl, 10000000b + WRITE_MIXER 0Dh, cl + WRITE_MIXER 0Eh, cl +noCD: + mov ecx, VolMaster + cmp ecx, -1 + je nomaster + + shr cl, 2 + or cl, 11000000b + WRITE_MIXER 04h, cl + WRITE_MIXER 05h, cl +nomaster: + LEAVE_MIXER + + ret + +SetMixerVolume ENDP + +;---------------------------------------------------------------------------- + +GetMixerVolume PROC uses EBX, \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + mov dx, word ptr[BASE_ADDR] + add dx, 2 ; MIXER + + SELECT_MIXER + + READ_MIXER 0Bh + mov cl, al + READ_MIXER 09h + mov ch, al + READ_MIXER 0Dh + mov bl, al + READ_MIXER 04h + mov bh, al + + LEAVE_MIXER + + xor eax, eax + + mov edx, VolVoice + or edx, edx + jz novoice + + shl cl, 1 + mov al, cl + mov [edx], eax +novoice: + mov edx, VolMidi + or edx, edx + jz nomidi + + shl ch, 1 + mov al, ch + mov [edx], eax +nomidi: + mov edx, VolCD + or edx, edx + jz nocd + + shl bl, 1 + mov al, bl + mov [edx], eax +nocd: + mov edx, VolLine + or edx, edx + jz noline + + mov dword ptr[edx], 0 +noline: + mov edx, VolMaster + or edx, edx + jz nomaster + + shl bh, 2 + mov al, bh + mov [edx], eax +nomaster: + ret + +GetMixerVolume ENDP + +;---------------------------------------------------------------------------- + +GetMixerInfo PROC \ + VolVoice:DWORD, VolMidi:DWORD, VolCD:DWORD, \ + VolLine:DWORD, VolMaster:DWORD + + + mov ecx, VolVoice + or ecx, ecx + jz novoice + + mov dword ptr[ecx], 1 +novoice: + mov ecx, VolLine + or ecx, ecx + jz noline + + mov dword ptr[ecx], 0 +noline: + mov ecx, VolMidi + or ecx, ecx + jz nomidi + + mov dword ptr[ecx], 1 +nomidi: + mov ecx, VolCD + or ecx, ecx + jz nocd + + mov dword ptr[ecx], 1 +nocd: + mov ecx, VolMaster + or ecx, ecx + jz nomaster + + mov dword ptr[ecx], 1 +nomaster: + ret + +GetMixerInfo ENDP + +ENDIF + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + + END diff --git a/LIB386/LIB_MIX/MIXER_I.ASM b/LIB386/LIB_MIX/MIXER_I.ASM new file mode 100644 index 0000000..5ec838e --- /dev/null +++ b/LIB386/LIB_MIX/MIXER_I.ASM @@ -0,0 +1,83 @@ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; MIXER_I.ASM 386 +; (c) Adeline 1993 +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*--------------------------------------------------------------------------* + + .386 + jumps + + .model SMALL, SYSCALL + + .DATA + + PUBLIC NoLanguage Mixer_listfcts + PUBLIC NoLanguage Mixer_Driver_Enable + +Mixer_listfcts dd 0 +Mixer_Driver_Enable dd 0 + + .CODE + + PUBLIC NoLanguage MixerAskVars + PUBLIC NoLanguage MixerChangeVolume + PUBLIC NoLanguage MixerGetVolume + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +MixerCallFuncs PROC + + cmp byte ptr[Mixer_Driver_Enable], 0 + je return + + shl eax, 2 + add eax, dword ptr[Mixer_listfcts] + jmp dword ptr[eax] +return: + ret + +MixerCallFuncs ENDP + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + + +MixerAskVars PROC + + mov eax, 0 + jmp MixerCallFuncs + +MixerAskVars ENDP + +;---------------------------------------------------------------------------- + +MixerChangeVolume PROC + + mov eax, 1 + jmp MixerCallFuncs + +MixerChangeVolume ENDP + +;---------------------------------------------------------------------------- + +MixerGetVolume PROC + + mov eax, 2 + jmp MixerCallFuncs + +MixerGetVolume ENDP + +;---------------------------------------------------------------------------- + +MixerGetInfo PROC + + mov eax, 3 + jmp MixerCallFuncs + +MixerGetInfo ENDP + +;---------------------------------------------------------------------------- + + END diff --git a/LIB386/LIB_MIX/MIX_DLL.MAK b/LIB386/LIB_MIX/MIX_DLL.MAK new file mode 100644 index 0000000..71ceb09 --- /dev/null +++ b/LIB386/LIB_MIX/MIX_DLL.MAK @@ -0,0 +1,52 @@ +AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=; +LINKDIR = format os2 lx dll + +dll: m_pas.dll m_mwss.dll m_sb2cd.dll m_sbpro.dll m_sb16.dll m_gold.dll + +# +# Mixer driver: AD1848 SoundPort, Microsoft Windows Sound System +# + +m_mwss.dll: mixer_a.asm + ml $(AFLAGS) /DMWSS mixer_a.asm + wlink n m_mwss.dll f mixer_a $(LINKDIR) + +# +# Mixer driver: Pro Audio Spectrum +# + +m_pas.dll: mixer_a.asm + ml $(AFLAGS) /DPAS mixer_a.asm + wlink n m_pas.dll f mixer_a $(LINKDIR) + +# +# Mixer driver: Sound Blaster 2 CD Interface card +# + +m_sb2cd.dll: mixer_a.asm + ml $(AFLAGS) /DSB2CD mixer_a.asm + wlink n m_sb2cd.dll f mixer_a $(LINKDIR) + +# +# Mixer driver: Sound Blaster Pro +# + +m_sbpro.dll: mixer_a.asm + ml $(AFLAGS) /DSBPRO mixer_a.asm + wlink n m_sbpro.dll f mixer_a $(LINKDIR) + +# +# Mixer driver: Sound Blaster 16 +# + +m_sb16.dll: mixer_a.asm + ml $(AFLAGS) /DSB16 mixer_a.asm + wlink n m_sb16.dll f mixer_a $(LINKDIR) + +# +# Mixer driver: Yamaha Gold, Adlib Gold +# + +m_gold.dll: mixer_a.asm + ml $(AFLAGS) /DGOLD mixer_a.asm + wlink n m_gold.dll f mixer_a $(LINKDIR) diff --git a/LIB386/LIB_SAMP/BALANCE.ASM b/LIB386/LIB_SAMP/BALANCE.ASM new file mode 100644 index 0000000..2c702a4 --- /dev/null +++ b/LIB386/LIB_SAMP/BALANCE.ASM @@ -0,0 +1,44 @@ + + .386p + jumps + + .model SMALL, C + + .data + + extrn NoLanguage P_SinTab:WORD + + + .code + + public NoLanguage Balance + + +Balance PROC uses ebx,\ + bal:DWORD, vol:DWORD, volleft:DWORD, volright:DWORD + + mov eax, bal + shl eax, 1 + mov edx, vol + + xor ecx, ecx + mov cx, word ptr[P_SinTab + eax] + imul ecx, edx + shr ecx, 14 + + mov ebx, volright + mov dword ptr[ebx], ecx + + xor ecx, ecx + mov cx, word ptr[P_SinTab + 512 + eax] + imul ecx, edx + shr ecx, 14 + + mov ebx, volleft + mov dword ptr[ebx], ecx + + ret + +Balance ENDP + + END diff --git a/LIB386/LIB_SAMP/BALANCE.H b/LIB386/LIB_SAMP/BALANCE.H new file mode 100644 index 0000000..5619868 --- /dev/null +++ b/LIB386/LIB_SAMP/BALANCE.H @@ -0,0 +1,3 @@ +/* balance between 0 and 256, volume between 0 and 128 */ +void Balance( ULONG balance, ULONG volume, ULONG *vol_left, ULONG *vol_right ) ; + diff --git a/LIB386/LIB_SAMP/BUILD.BAT b/LIB386/LIB_SAMP/BUILD.BAT new file mode 100644 index 0000000..48bb043 --- /dev/null +++ b/LIB386/LIB_SAMP/BUILD.BAT @@ -0,0 +1,15 @@ +call watcom10 + +pkunzip -o obj >NUL +copy wr\ail32.obj +wmake +pkzip -m obj *.obj >NUL + +call watcom9 + +pkunzip -o obj9 >NUL +copy wr\ail32.obj +wmake WATCOM9=yes +pkzip -m obj9 *.obj >NUL + +call watcom10 diff --git a/LIB386/LIB_SAMP/BUILDDLL.BAT b/LIB386/LIB_SAMP/BUILDDLL.BAT new file mode 100644 index 0000000..13e1d7e --- /dev/null +++ b/LIB386/LIB_SAMP/BUILDDLL.BAT @@ -0,0 +1,3 @@ +pkunzip -o obj >NUL +wmake /f wave_dll.mak +pkzip -m obj *.obj >NUL diff --git a/LIB386/LIB_SAMP/DMA_CODE.ASM b/LIB386/LIB_SAMP/DMA_CODE.ASM new file mode 100644 index 0000000..bbdbd70 --- /dev/null +++ b/LIB386/LIB_SAMP/DMA_CODE.ASM @@ -0,0 +1,378 @@ + .DATA + +Status EQU 08h ;DMAC status port (read) \ same port +Command EQU 08h ;DMAC command port (write) / (read/write) +Request EQU 09h ;DMAC channel request (write-only) +DMA_Mask EQU 0Ah ;DMAC DMA_Mask (write-only) +Mode EQU 0Bh ;DMAC mode (write) +byte_ptr EQU 0Ch ;byte pointer flip-flop + +addr EQU 000h ; per-channel base address +count EQU 001h ; per-channel byte count + +read_cmd EQU 058h ; autoinitialising read +write_cmd EQU 054h ; auto write + +set_cmd EQU 000h ; DMA_Mask set (enable dma) +reset_cmd EQU 004h ; DMA_Mask reset (disable) + +page_table DW 00087h ; channel 0 + DW 00083h ; channel 1 + DW 00081h ; channel 2 + DW 00082h ; channel 3 + DW 0FFFFh ; ch 4 (not used) + DW 0008Bh ; ch 5 + DW 00089h ; ch 6 + DW 0008Ah ; ch 7 + +dmac2 DB 0 ; Flag set to non-zero when using the 2nd DMA controller + + .CODE + +MACRO adjust reg ; Adjust register port for 2nd DMA cont + local no_adjust + + cmp byte ptr[dmac2], 0 + jz no_adjust + shl reg, 1 + add reg, 0C0h +no_adjust: + +ENDM adjust + +;+---------------------------------------------------------------------------+ +;| int dma_setup(int Channel, char far *Buffer, unsigned Length) | +;| ------------------------------------------------------------------------- | +;| Channel = 0-7 | +;| Buffer = Address of data to transfer | +;| Length = Length of data to transfer | +;| ------------------------------------------------------------------------- | +;| Returns: 0 if no errors (dma_errno == 0) | +;| -1 if errors occurred (dma_errno set to indicate error.) | +;+---------------------------------------------------------------------------+ + +dma_setup PROC USES EBX,\ + Channel:DWORD, Buffer:DWORD, Len:DWORD + +;Convert 20-bit physical address of buffer into page:offset + + + mov edi, Buffer + mov ecx, edi + shr ecx, 8 + +; ch:di == The physical buffer base. + +; Adjust channel number + + mov byte ptr[dmac2], 0 + mov bx, Channel + cmp bx, 4 + jb OkChannel + and bx, 3 + mov byte ptr[dmac2], 1 +OkChannel: + +; BX contains the adjusted channel number + + mov si, read_cmd + add si, bx + mov cl, set_cmd ;allow dma requests + add cl, bl + +;si contains READ/WRITE command for DMA controller +;cl contains confirmation command for DMA controller + + shl bx, 1 + +;bx == Port # Channel*2 + +;------------------------------------------------------------------------- +; Calculations have been done ahead of time to minimize time with +; interrupts disabled. +; +; edi (ch:di) == physical base address (must be on word boundary for 16 bits) +; +; cl == Confirmation command (Unmasks the channel) +; +; bx == I/O port Channel*2 (This is where the address is written) +; +; si == Mode command for DMA +;------------------------------------------------------------------------- + +; Now we shift the address and word count right one bit if in 16 bit mode. + + cmp [dmac2], 0 + jz AddrOk + + shr ch, 1 + rcr di, 1 + shl ch, 1 + shr [Len], 1 ;Odd byte lengths are rounded down +AddrOk: + +;The "byte pointer" is also known as the LSB/MSB flip flop. +;By writing any value to it, the DMA controller registers are prepared +;to accept the address and length values LSB first. + + mov dx, byte_pt ;Reset byte pointer Flip/flop + adjust dx + out dx, al + + mov dx, bx ;dx=DMAC Base Address port + adjust dx + mov ax, di ;ax=LSW of 20-bit address + out dx, al ;Store LSB + mov al, ah + out dx, al ;Store MSB + +;Write length to port (Channel * 2 + 1) + + inc dx ;dx=DMAC Count port + mov eax, Len + out dx, al ;Write LSB of Length + mov al, ah + out dx, al ;Write MSB + +;Write page to port page_table[channel] + + mov ebx, Channel + shl bx, 1 + mov dx, word ptr[OFFSET page_table + bx] + mov al, ch ;al=Page number + out dx, al ;Store the page + +;Write Readcmd for channel to Mode port + + mov dx, Mode ;dx=DMAC mode register + adjust dx + mov ax, si ;Load pre-calculated mode + out dx, al ;Write it to the DSP + + mov dx, DMA_Mask ;dx=DMAX DMA_Mask register + adjust dx + mov al, cl ;al=pre-calulated DMA_Mask value + out dx, al ;Write DMA_Mask (allow dma on this channel) + + ret + +dma_setup ENDP + +;+---------------------------------------------------------------------------+ +;| int prevent_dma(int Channel) | +;| ------------------------------------------------------------------------- | +;| Channel = 0-7 | +;| Prevents DMA requests from Channel by masking bit in DMA_C. | +;| ------------------------------------------------------------------------- | +;+---------------------------------------------------------------------------+ + +prevent_dma PROC ,\ + Channel:DWORD + + +; Check channel number range + + mov dx, DMA_Mask + + mov eax, Channel + cmp al, 4 + jb OkChannel + and al, 3 + shl dx, 1 + add dx, 0C0h +OkChannel: + add al, reset_cmd ; Add disable DMA requests + out dx, al + + ret + +prevent_dma ENDP + +;+---------------------------------------------------------------------------+ +;| int allow_dma(int Channel) | +;| ------------------------------------------------------------------------- | +;| Channel = 0-7 | +;| Unmasks DMA on the specified channel. | +;| ------------------------------------------------------------------------- | +;+---------------------------------------------------------------------------+ + +allow_dma PROC ,\ + Channel:DWORD + +; Check channel number range + + mov dx, DMA_Mask + + mov eax, Channel + cmp al, 4 + jb OkChannel + and al, 3 + shl dx, 1 + add dx, 0C0h +OkChannel: + add al, set_cmd ; Add enable DMA requests + out dx, al + + ret + +allow_dma ENDP + +;+---------------------------------------------------------------------------+ +;| int dma_count(Channel) | +;| ------------------------------------------------------------------------- | +;| Channel = 0-7 | +;| ------------------------------------------------------------------------- | +;| Returns: -1 if DMA transaction completed | +;| else returns the number of bytes/words left to transfer | +;+---------------------------------------------------------------------------+ + +PROC dma_count ,\ + Channel:DWORD + + mov eax, Channel + + mov dx, ax + and dx, 3 + shl dx, 1 + add dx, count + + cmp al, 4 + jb OkChannel + shl dx, 1 + add dx, 0C0h +OkChannel: + xor eax, eax + cli + in al, dx + mov ah, al + in al, dx + sti + xchg al, ah + + ret + +dma_count ENDP + +;+---------------------------------------------------------------------------+ +;| unsigned dma_addr(Channel) | +;| ------------------------------------------------------------------------- | +;| Channel = 0-7 | +;| ------------------------------------------------------------------------- | +;| Returns: Current address word of that channel | +;| Value must be multiplied by 2 for a 16-bit channel. | +;| It is best to start at offset 0, ie on a 64K boundary | +;+---------------------------------------------------------------------------+ + +dma_addr PROC ,\ + Channel:DWORD + + mov eax, Channel + + mov dx, ax + and dx, 3 + shl dx, 1 + + cmp al, 4 + jb OkChannel + shl dx, 1 + add dx, 0C0h +OkChannel: + xor eax, eax + cli + in al, dx + mov ah, al + in al, dx + sti + xchg al, ah + + ret + +dma_addr ENDP + + + +VOID *DMABuffer, *DMAAllocBuffer; +BYTE LockedDMARegion; + +#define MAX_DMABUFFERATTEMPTS 10; + +;+---------------------------------------------------------------------------+ +;| BYTE *AlignOn4KBoundry( BYTE *Buf ) | +;| ------------------------------------------------------------------------- | +;| Align Buf to the nearest 4K page | +;+---------------------------------------------------------------------------+ + +#define AlignOn4KBoundry(Buf) ((Buf + 0x00000FFF) & 0xFFFFF000) + +;+---------------------------------------------------------------------------+ +;| BYTE *AllocateDMABuffer( WORD BufferSize ) | +;| ------------------------------------------------------------------------- | +;| BufferSize = 0-64K | +;| ------------------------------------------------------------------------- | +;| Returns: Buffer if successful | +;| NULL if error | +;+---------------------------------------------------------------------------+ + +BYTE *AllocateDMABuffer( WORD BufferSize ) +{ + VOID *Tried[ MAX_DMABUFFERATTEMPTS ] ; + VOID *Buf, *DMAAddr ; + int Tries, Error ; + + for (Tries = 0; Tries < MAX_DMABUFFERATTEMPTS; Tries++) + Tried[ Tries ] = NULL ; + + Tries = 0; + LockedDMARegion = FALSE; + + do + { +// printf( "DMA buffer allocation attempt: %d\n", Tries + 1 ) ; + if ((DMAAllocBuffer = (VOID *)DosMalloc( BufferSize + 0xFFF)) != NULL) + { + DMABuffer = AlignOn4KBoundry(DMAAllocBuffer); + + if ( ((LONG)DMABuffer & 0xF0000) != + (((LONG)DMABuffer + BufferSize) & 0xF0000) ) + { + Tried[ Tries ] = DMAAllocBuffer ; + DMAAllocBuffer = NULL ; + DMABuffer = NULL ; + + } + } + Tries++ ; + DMAAllocBuf = Buf; + DMABuffer = DMAAddr ; + } + while ((DMAAllocBuf == NULL) && (Tries < MAX_DMABUFFERATTEMPTS)) ; + + for (wTries = 0; wTries < MAX_DMABUFFERATTEMPTS; wTries++) + { + if (alpTried[ wTries ]) + free( alpTried[ wTries ] ) ; + else + break ; + } + + return( DMABuffer ) ; + + +;+---------------------------------------------------------------------------+ +;| VOID FreeDMABuffer( VOID ) | +;| ------------------------------------------------------------------------- | +;| Free the DMA buffer | +;+---------------------------------------------------------------------------+ + +VOID FreeDMABuffer( VOID ) +{ + if (LockedDMARegion) + UnlockDMARegion( &gDDS, 0 ) ; + + if (DMAAllocBuf) + { + free( glpDMAAllocBuf ) ; + DMAAllocBuf = NULL ; + } + +} diff --git a/LIB386/LIB_SAMP/GUS.BAT b/LIB386/LIB_SAMP/GUS.BAT new file mode 100644 index 0000000..a380f34 --- /dev/null +++ b/LIB386/LIB_SAMP/GUS.BAT @@ -0,0 +1 @@ +@nmake /f gus.mak gusdig32.obj diff --git a/LIB386/LIB_SAMP/GUS.C b/LIB386/LIB_SAMP/GUS.C new file mode 100644 index 0000000..3cbbd4e --- /dev/null +++ b/LIB386/LIB_SAMP/GUS.C @@ -0,0 +1,87 @@ +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" + +#pragma library ("\gussdk21\libs\ultra0wc.lib"); + +#include "forte.h" +#include "gf1proto.h" +#include "extern.h" +#include "ultraerr.h" + + +extern void NewIRQ(void); + + +extern void *BUFFER_DMA; + +extern ULONG R_BUFFER_CARD; +extern ULONG MID_R_BUFFER_CARD; +extern ULONG CURRENT_R_BUFFER_CARD; + +extern ULONG L_BUFFER_CARD; +extern ULONG MID_L_BUFFER_CARD; +extern ULONG CURRENT_L_BUFFER_CARD; + +extern LONG BUFFER_SIZE; +extern UWORD PlayRate; + + +void ResetCard(void) +{ + ULTRA_CFG config; + UBYTE RMode, LMode; + + /* Get the ULTRASND environment string parameters */ + UltraGetCfg(&config); + + /* Open the card with 14 voices (44 Khz) */ + UltraOpen(&config, 14); + + /* Get a chunk of memory on the card */ + UltraMemAlloc(BUFFER_SIZE << 1, &R_BUFFER_CARD); + MID_R_BUFFER_CARD = R_BUFFER_CARD + BUFFER_SIZE; + CURRENT_R_BUFFER_CARD = MID_R_BUFFER_CARD; + + /* Reset memory on the card to 0 */ + UltraDownload(BUFFER_DMA, DMA_8|DMA_CVT_2, R_BUFFER_CARD, BUFFER_SIZE, TRUE); + UltraDownload(BUFFER_DMA, DMA_8|DMA_CVT_2, MID_R_BUFFER_CARD, BUFFER_SIZE, TRUE); + + /* Get a chunk of memory on the card */ + UltraMemAlloc(BUFFER_SIZE << 1, &L_BUFFER_CARD); + MID_L_BUFFER_CARD = L_BUFFER_CARD + BUFFER_SIZE; + CURRENT_L_BUFFER_CARD = MID_L_BUFFER_CARD; + + /* Reset memory on the card to 0 */ + UltraDownload(BUFFER_DMA, DMA_8|DMA_CVT_2, L_BUFFER_CARD, BUFFER_SIZE, TRUE); + UltraDownload(BUFFER_DMA, DMA_8|DMA_CVT_2, MID_L_BUFFER_CARD, BUFFER_SIZE, TRUE); + + /* set Balance for each voice */ + UltraSetBalance(0, 7); + UltraSetBalance(1, 7); + + /* Set Frequency for each voice to PlayRate */ + UltraSetFrequency(0, PlayRate); + UltraSetFrequency(1, PlayRate); + + /* set Volume for each voice */ + UltraSetVolume(0, 511); + UltraSetVolume(1, 511); + + /* get voices ready... */ + RMode = UltraPrimeVoice(0, R_BUFFER_CARD, R_BUFFER_CARD, + R_BUFFER_CARD + (BUFFER_SIZE << 1), 0x20 | 0x08 | 0x04); + LMode = UltraPrimeVoice(1, L_BUFFER_CARD, MID_L_BUFFER_CARD, + L_BUFFER_CARD + (BUFFER_SIZE << 1), 0x20 | 0x08 | 0x04); + + /* Plug in our IRQ handler for wave events */ + UltraWaveHandler(NewIRQ); + + /*set, go ! */ + UltraGoVoice(0, RMode); + UltraGoVoice(1, LMode); +} + +void StartDMACard(void) +{ + UltraDownload(BUFFER_DMA, DMA_8|DMA_CVT_2, CURRENT_R_BUFFER_CARD, BUFFER_SIZE, FALSE); +} \ No newline at end of file diff --git a/LIB386/LIB_SAMP/GUS.INC b/LIB386/LIB_SAMP/GUS.INC new file mode 100644 index 0000000..3e310b7 --- /dev/null +++ b/LIB386/LIB_SAMP/GUS.INC @@ -0,0 +1,25 @@ +;*--------------------------------------------------------------------------* + +BUFFER_SIZE equ 1024 ; number of samples + ; in half-buffer +LIST_SIZE equ 50 +STRUCT_SIZE equ 40 +SNAP_SIZE equ 8 + +SHIFT_SAMPLE equ 3 ; max number of + ; samples mixed + +;*--------------------------------------------------------------------------* + +EXTERN SYSCALL playrate:WORD +EXTERN SYSCALL bufferhalf:DWORD +EXTERN SYSCALL buffer_dma:DWORD +EXTERN SYSCALL current_buffer:DWORD +EXTERN SYSCALL DoUpdate:WORD +EXTERN SYSCALL Critical:WORD + +;*--------------------------------------------------------------------------* + +UpdateBuffer PROTO SYSCALL + +;*--------------------------------------------------------------------------* diff --git a/LIB386/LIB_SAMP/LIB_WAVE.H b/LIB386/LIB_SAMP/LIB_WAVE.H new file mode 100644 index 0000000..03b9037 --- /dev/null +++ b/LIB386/LIB_SAMP/LIB_WAVE.H @@ -0,0 +1,206 @@ +#ifdef WATCOM9 +#pragma library ("f:\projet\lib386\lib_samp\lb9_wave.lib"); +#else +#pragma library ("f:\projet\lib386\lib_samp\lib_wave.lib"); +#endif + +typedef struct + { + ULONG LongHandle; + ULONG Info0; + ULONG Position; + } + T_WAVE; + +extern char Wave_Driver[]; + +extern char Wave_Driver_Name[]; + +extern LONG Wave_Driver_Enable; + + +/*----------------------------------------------------------------------*/ +/* WaveInitDLL : Load and connect the DLL to the program */ +/* */ +/* dlldriver : Pathname of the DLL */ +/* */ +/* Returns : TRUE if ok, FALSE if problems */ +/*----------------------------------------------------------------------*/ +LONG WaveInitDLL( char *dlldriver ) ; + +/*----------------------------------------------------------------------*/ +/* WaveAskVars : Get the list of variables needed by the DLL */ +/* */ +/* listidentifier : pointer to an array of string*/ +/* pointers, each string */ +/* contains the name of the var */ +/* to initialise for the DLL */ +/* ptrvars : pointer to an array of DWORD to */ +/* store the value of each var in */ +/* listidentifier */ +/* */ +/* Returns : TRUE if ok, FALSE if problems */ +/*----------------------------------------------------------------------*/ +void WaveAskVars( char ***listidentifier, LONG **ptrvars ) ; + +/*----------------------------------------------------------------------*/ +/* InitWave : Init the library */ +/* */ +/* Returns : TRUE if ok, FALSE if problems */ +/*----------------------------------------------------------------------*/ +ULONG InitWave( void ); + +/*----------------------------------------------------------------------*/ +/* ClearWave : Close the library */ +/* */ +/* Returns : nothing */ +/*----------------------------------------------------------------------*/ +void ClearWave( void ); + +/*----------------------------------------------------------------------*/ +/* WavePlay : Play a Sample */ +/* */ +/* Handle : a number identifying the sample */ +/* Pitchbend : 4096 is no bend */ +/* Repeat : number of times to play the sample */ +/* Follow : if TRUE, this sample will play after */ +/* the previous one */ +/* VolLeft : Volume for Left channel (128 max) */ +/* VolRight : Volume for Right channel (128 max) */ +/* Buffer : Pointer to the sample in mem */ +/* */ +/* Returns : the lib internal handle */ +/*----------------------------------------------------------------------*/ +ULONG WavePlay( UWORD Handle, + UWORD Pitchbend, + UWORD Repeat, + UBYTE Follow, + UWORD VolLeft, + UWORD VolRight, + void *Buffer ); + +/*----------------------------------------------------------------------*/ +/* WaveGiveInfo0 : Fill the user Info0 field */ +/* */ +/* LongHandle : Lib internal handle */ +/* Info0 : the info to be stored (up to you) */ +/* */ +/* Returns : nothing */ +/*----------------------------------------------------------------------*/ +void WaveGiveInfo0( ULONG LongHandle, + ULONG Info0 ); + +/*----------------------------------------------------------------------*/ +/* WaveStop : Stop all samples, clear all internal vars */ +/* */ +/* Returns : nothing */ +/*----------------------------------------------------------------------*/ +void WaveStop( void ); + +/*----------------------------------------------------------------------*/ +/* WaveStopOne : Stop one sample */ +/* */ +/* Handle : Your Handle */ +/* */ +/* Returns : nothing */ +/*----------------------------------------------------------------------*/ +void WaveStopOne( UWORD Handle ); + +/*----------------------------------------------------------------------*/ +/* WaveStopOneLong : Stop one sample */ +/* */ +/* LongHandle : Lib internal handle */ +/* */ +/* Returns : nothing */ +/*----------------------------------------------------------------------*/ +void WaveStopOneLong( ULONG LongHandle ); + +/*----------------------------------------------------------------------*/ +/* WaveInList : Test if one sample is currently used by */ +/* the lib */ +/* */ +/* Handle : Your Handle */ +/* */ +/* Returns : TRUE if used */ +/*----------------------------------------------------------------------*/ +int WaveInList( UWORD handle ); + +/*----------------------------------------------------------------------*/ +/* WaveGetSnap : Take a snapshot of all Internal handles and */ +/* Info0 for currently playing samples in array */ +/* ListSnapSample */ +/* */ +/* Buffer : A pointer that will be filled with */ +/* the address of the buffer */ +/* */ +/* Returns : The number of samples currently used by the */ +/* lib */ +/*----------------------------------------------------------------------*/ +int WaveGetSnap( void **Buffer ); + +/*----------------------------------------------------------------------*/ +/* WavePause : Pause all the playing samples */ +/* */ +/* Returns : TRUE if paused */ +/*----------------------------------------------------------------------*/ +int WavePause( void ); + +/*----------------------------------------------------------------------*/ +/* WaveContinue : Continue all the playing samples */ +/* */ +/* Returns : nothing */ +/*----------------------------------------------------------------------*/ +void WaveContinue( void ); + +/*----------------------------------------------------------------------*/ +/* WaveSaveState : Save the internal state of the lib and */ +/* get ready to play somme other samples */ +/* */ +/* Remark : Can be called only once */ +/* */ +/* Returns : nothing */ +/*----------------------------------------------------------------------*/ +void WaveSaveState( void ); + +/*----------------------------------------------------------------------*/ +/* WaveRestoreState: Restore the internal state of the lib */ +/* and resume playback */ +/* */ +/* Returns : nothing */ +/*----------------------------------------------------------------------*/ +void WaveRestoreState( void ); + +/*----------------------------------------------------------------------*/ +/* WaveChangeVolume: Change the volume of a sample */ +/* */ +/* LongHandle : Lib internal handle */ +/* VolLeft : New Left volume (128 max) */ +/* VolRight : New Right volume (128 max) */ +/* */ +/* Returns : nothing */ +/*----------------------------------------------------------------------*/ +void WaveChangeVolume( ULONG longhandle, + ULONG VolGauche, + ULONG VolDroit ); + +/*----------------------------------------------------------------------*/ +/* WaveMove : Tell the driver to move the samples from */ +/* SrcAddr to DestAddr. Size given by Size */ +/* */ +/* DestAddr : Dest */ +/* SrcAddr : Source */ +/* Size : number of bytes to move */ +/* */ +/* Returns : nothing */ +/*----------------------------------------------------------------------*/ +void WaveMove( void *DestAddr, + void *SrcAddr, + ULONG Size ); + +/*----------------------------------------------------------------------*/ +/* WaveGetAddr : Return a pointer to the current playing */ +/* sample data */ +/* */ +/* Returns : a pointer (FLAT) */ +/*----------------------------------------------------------------------*/ +void *WaveGetAddr( void ); diff --git a/LIB386/LIB_SAMP/MAKEFILE b/LIB386/LIB_SAMP/MAKEFILE new file mode 100644 index 0000000..5f12996 --- /dev/null +++ b/LIB386/LIB_SAMP/MAKEFILE @@ -0,0 +1,54 @@ +# name the compiler +!ifdef %HOME +!ifeq WATCOM9 yes +CC = c:\compil\watcom\bin\wcc386p +WL = c:\compil\watcom\binb\wlib +!else +CC = c:\compil\watcom10\binb\wcc386 +WL = c:\compil\watcom10\binb\wlib +!endif +!else +!ifeq WATCOM9 yes +CC = f:\compil\watcom\bin\wcc386p +WL = f:\compil\watcom\binb\wlib +!else +CC = f:\compil\watcom10\binb\wcc386 +WL = f:\compil\watcom10\binb\wlib +!endif +!endif + +ASM = ml + +!ifeq WATCOM9 yes +CFLAGS = /oeaxt /zp2 /4s /zq /s /DWATCOM9 +!else +CFLAGS = /oeaxt /zp2 /5s /zq /s +!endif +LFLAGS = /c /q /b /n +#AFLAGS = /m2 /mx /z /zi /t /jMASM51 /jQUIRKS +AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=; + +.SILENT + +OBJETS1 = wave.obj wave_i.obj + +!ifeq WATCOM9 yes +LIB = LB9_WAVE +!else +LIB = LIB_WAVE +!endif + +$(LIB).LIB: $(OBJETS1) + + @echo $(OBJETS1) > clibmak.rsp + @$(WL) $(LIBFLAGS) $(LIB) @clibmak.rsp + @del clibmak.rsp + @prntitre M "$(LIB) OK" + +.asm.obj: + @PRNTITRE M "$*.ASM" + @$(ASM) $(AFLAGS) $*.ASM + +.c.obj: + @PRNTITRE M "$*.C" + @$(CC) $(CFLAGS) $* diff --git a/LIB386/LIB_SAMP/N_WAVE.ASM b/LIB386/LIB_SAMP/N_WAVE.ASM new file mode 100644 index 0000000..8832de0 --- /dev/null +++ b/LIB386/LIB_SAMP/N_WAVE.ASM @@ -0,0 +1,3436 @@ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; SAMP_A.ASM 386 +; (c) Adeline 1993 +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*--------------------------------------------------------------------------* + +include wave.inc + +;*--------------------------------------------------------------------------* + +MIDPOINT MACRO + +IFDEF SAMPLE16BIT + xor eax, eax +ELSE + mov eax, 80808080h +ENDIF + + ENDM + +;*--------------------------------------------------------------------------* + + .386 + jumps + + .model FLAT, C + + .CODE + + +;*--------------------------------------------------------------------------* + + PUBLIC driver_start + +driver_start dd OFFSET ListFuncs + +IFDEF SB16 + db 'Sound Blaster 16 (DSP 4.XX)' + +ELSEIFDEF SBPRO + db 'Sound Blaster Pro (DSP 3.XX)' + +ELSEIFDEF SBLASTER1 + db 'Sound Blaster 2 (DSP 2.01+)' + +ELSEIFDEF SBLASTER + db 'Sound Blaster (DSP 1.00-2.00)' + +ELSEIFDEF MWSS + db 'Microsoft Windows Sound System (AD1848 SoundPort)' + +ELSEIFDEF GOLD + db 'Adlib Gold (Yamaha GOLD)' + +ELSEIFDEF GUS + db 'Advanced Gravis UltraSound' +ENDIF + + db ' Wave Driver,', 13, 10 + +IFDEF SAMPLE16BIT + db '16 bit' +ELSE + db '8 bit' +ENDIF +IFDEF STEREO + db ' Stereo' +ELSE + db ' Mono' +ENDIF +IFDEF SURROUND + db ' Surround' +ENDIF + + db ' playback, Version á2.00, ', ??date, 13, 10 +IFDEF GUS + db 'Copyright (C) 1991,1992 Miles Design, Inc.', 0Dh, 0Ah + db 'Copyright (C) 1993,1994 Advanced Gravis Computer ' + db 'Technology Ltd. All rights reserved.', 0Dh, 0Ah + db 'Copyright (C) 1992,1993,1994 Forte Technologies.', 0Dh, 0Ah + db 'Copyright (C) 1994 Adeline Software International.', 0Dh, 0Ah + db 'All rights reserved.', 0Dh, 0Ah + db 'Adeline conversion by Serge Plagnol.', 0Dh, 0Ah + db 'UltraSound conversion by Jayeson Lee-Steere. ', 0Dh, 0Ah + db 'MIDI and Digital sound library by Forte.', 0Dh, 0Ah, 0Ah, 0 +ELSE + db 'Copyright (c) Adeline Software International 1994, All Rights Reserved.', 13, 10, 10, 0 +ENDIF + +ListFuncs dd offset InitCard + dd offset ClearCard + + dd offset AskVars + + dd offset MixSample + dd offset GiveSampleInfo0 + + dd offset StopSample + dd offset StopOneSample + + dd offset SampleInList + dd offset GetSnapSample + + dd offset PauseSample + dd offset ContinueSample + + dd offset SaveStateSample + dd offset RestoreStateSample + + dd offset GetDMAAddr + + dd offset GetBufferSize + + dd offset ChangeVolume + + dd offset ShiftSamples + + dd offset StopOneSampleLong + +;*--------------------------------------------------------------------------* + +ADDRESS equ 0 +FRACT equ 4 +LEFT equ 8 +REPEAT equ 12 +INCR equ 14 +SON equ 16 +HANDLE equ 20 +START equ 24 +DLENGTH equ 28 +VOL_LEFT equ 32 +VOL_RIGHT equ 34 +INFO0 equ 36 +INTERPOL equ 40 +LAST_SAMPLE equ 41 + +;*--------------------------------------------------------------------------* + +DSP_VO8S_CMD equ 14h +DSP_VO8_CMD equ 1Ch +DSP_TIME_CMD equ 40h +DSP_RATE_CMD equ 41h +DSP_BSIZE_CMD equ 48h +DSP_VO8H_CMD equ 90h +DSP_VO16S_CMD equ 0B0h +DSP_VO16_CMD equ 0B6h +DSP_VO8S_4_CMD equ 0C0h +DSP_VO8_4_CMD equ 0C6h +DSP_ONSPK_CMD equ 0D1h +DSP_OFFSPK_CMD equ 0D3h + +DSP_16MONO_MODE equ 10h +DSP_16STEREO_MODE equ 30h +DSP_8MONO_MODE equ 00h +DSP_8STEREO_MODE equ 20h + +RESET_TEST_CODE equ 0AAh + + +;*--------------------------------------------------------------------------* + +ifndef NOIRQ + +VOICE_OUT equ 0 ; equ to access the 2 arrays below +AUTO_OUT equ 1 +MASK1 equ 2 +MASK2 equ 3 + +ADDX_REG equ 4 +COUNT_REG equ 6 +MASK_REG equ 8 +MODE_REG equ 10 +FF_REG equ 12 +PAGE_REG equ 14 + + +DMA0 equ $ ; Ports for DMA0 + +DMA0_VOICE_OUT db 48H +DMA0_AUTO_OUT db 58H +DMA0_MASK1 db 00H +DMA0_MASK2 db 04H + +DMA0_ADDX_REG dw 00H +DMA0_COUNT_REG dw 01H +DMA0_MASK_REG dw 0AH +DMA0_MODE_REG dw 0BH +DMA0_FF_REG dw 0CH +DMA0_PAGE_REG dw 87H + + +DMA1 equ $ ; Ports for DMA1 + +DMA1_VOICE_OUT db 49H +DMA1_AUTO_OUT db 59H +DMA1_MASK1 db 01H +DMA1_MASK2 db 05H + +DMA1_ADDX_REG dw 02H +DMA1_COUNT_REG dw 03H +DMA1_MASK_REG dw 0AH +DMA1_MODE_REG dw 0BH +DMA1_FF_REG dw 0CH +DMA1_PAGE_REG dw 83H + + +DMA3 equ $ ; Ports for DMA3 + +DMA3_VOICE_OUT db 4BH +DMA3_AUTO_OUT db 5BH +DMA3_MASK1 db 03H +DMA3_MASK2 db 07H + +DMA3_ADDX_REG dw 06H +DMA3_COUNT_REG dw 07H +DMA3_MASK_REG dw 0AH +DMA3_MODE_REG dw 0BH +DMA3_FF_REG dw 0CH +DMA3_PAGE_REG dw 82H + + +DMA5 equ $ ; Ports for DMA5 + +DMA5_VOICE_OUT db 49H +DMA5_AUTO_OUT db 59H +DMA5_MASK1 db 01H +DMA5_MASK2 db 05H + +DMA5_ADDX_REG dw 0C4H +DMA5_COUNT_REG dw 0C6H +DMA5_MASK_REG dw 0D4H +DMA5_MODE_REG dw 0D6H +DMA5_FF_REG dw 0D8H +DMA5_PAGE_REG dw 08BH + +DMA6 equ $ ; Ports for DMA6 + +DMA6_VOICE_OUT db 4AH +DMA6_AUTO_OUT db 5AH +DMA6_MASK1 db 02H +DMA6_MASK2 db 06H + +DMA6_ADDX_REG dw 0C8H +DMA6_COUNT_REG dw 0CAH +DMA6_MASK_REG dw 0D4H +DMA6_MODE_REG dw 0D6H +DMA6_FF_REG dw 0D8H +DMA6_PAGE_REG dw 089H + +DMA7 equ $ ; Ports for DMA7 + +DMA7_VOICE_OUT db 4BH +DMA7_AUTO_OUT db 5BH +DMA7_MASK1 db 03H +DMA7_MASK2 db 07H + +DMA7_ADDX_REG dw 0CCH +DMA7_COUNT_REG dw 0CEH +DMA7_MASK_REG dw 0D4H +DMA7_MODE_REG dw 0D6H +DMA7_FF_REG dw 0D8H +DMA7_PAGE_REG dw 08AH + +ALIGN 4 + +TAB_DMA dd offset DMA0 + dd offset DMA1 + dd 0 + dd offset DMA3 + dd 0 + dd offset DMA5 + dd offset DMA6 + dd offset DMA7 + +endif + +;*--------------------------------------------------------------------------* + +CurrentList db STRUCT_SIZE*LIST_SIZE dup (?) +SonList db STRUCT_SIZE*LIST_SIZE dup (?) + +BackCurrentList db STRUCT_SIZE*LIST_SIZE dup (?) +BackSonList db STRUCT_SIZE*LIST_SIZE dup (?) + +SnapList db SNAP_SIZE*LIST_SIZE dup (?) + +IRQ_mask db ? + +FlagPause db 0 + +WaveBase db 'WaveBase',0 +WaveIRQ db 'WaveIRQ',0 +WaveDMA db 'WaveDMA',0 +WaveRate db 'WaveRate' +Empty db 0 + +ifdef SBPRO + + OkIRQ db 0 + Filter db ? + +endif + +ifdef GOLD + + Mixer_13 db ? + Mixer_14 db ? + Gold_IRQ db 3, 4, 5, 7, 10, 11, 12, 15 +endif + +ifdef SB16 + SB16_IRQ db 2, 5, 7, 10 +endif + +EVEN + +ifdef MWSS + +MWSSFreq dw 11025, 3, 16000, 2, 18900, 5, 22050, 7 + dw 27429, 4, 32000, 6, 33075, 0dh, 37800, 9 + dw 44100, 0Bh + +MWSSIrq db 0, 0, 010000b, 0, 0, 0, 0, 001000b, 0, 010000b + db 011000b, 100000b, 0, 0, 0, 0 + +MWSSDma db 01b, 10b, 0, 11b, 0, 0, 0, 0 + +endif + +Critical dw ? +DoUpdate dw ? + +Old_RIRQ_Seg dw ? +Old_PIRQ_Sel dw ? +Old_18_Sel dw ? +Old_RIRQ_Off dw ? + +ALIGN 4 + +Old_PIRQ_Off dd ? +Old_18_Off dd ? + +ifdef GOLD + + ListNames dd offset WaveBase + dd offset Empty + +elseifdef SB16 + + ListNames dd offset WaveBase + dd offset WaveRate + dd offset Empty + +elseifdef GUS + + ListNames dd offset WaveRate + dd offset Empty + +else + + ListNames dd offset WaveBase + dd offset WaveRate + dd offset WaveIRQ + dd offset WaveDMA + dd offset Empty + +endif + +public Nolanguage PlayRate + +ListVars equ $ + +ifdef GOLD + + BASE_ADDR dd 388h ; By default 388h + PlayRate dd 22000 ; By default 22 Khz + IRQ_number dd ? ; no default (read card) + DMA_number dd ? ; no default (read card) + + +elseifdef SBLASTER + + BASE_ADDR dd 220h ; By default 220h + PlayRate dd 22000 ; By default 22 Khz + IRQ_number dd 5 ; By default 5 + DMA_number dd 1 ; By default 1 + +elseifdef MWSS + + BASE_ADDR dd 540h ; By default 540h + PlayRate dd 22000 ; By default 22 Khz + IRQ_number dd 9 ; By default 9 + DMA_number dd 1 ; By default 1 + +elseifdef GUS + + PlayRate dd 22000 ; By default 22 Khz + +else + + BASE_ADDR dd 0 ; no default + PlayRate dd 22000 ; By default 22 Khz + IRQ_number dd 0 ; no default + DMA_number dd 0 ; no default + +endif + +INT_number dd 0Dh ; By default 0Dh + +public Nolanguage BufferHalf + +BufferHalf dd ? + +follow dd -1 + +backfollow dd -1 + +ifndef NOIRQ + +DMA dd offset DMA1 ; By default DMA1 + +endif + +weirdcount dd ? +backweirdcount dd ? + +TheVolumeR dd ? +TheVolumeL dd ? + +save_1 dd ? +save_2 dd ? +save_3 dd ? +save_4 dd ? + + +public Nolanguage BUFFER_DMA +public Nolanguage CURRENT_BUFFER + + +ifdef RAM_CARD + + BUFFER_DMA dd ? ; adress of the buffer + + R_BUFFER_CARD dd ? ; adress of the buffer on the card for Right channel + MID_R_BUFFER_CARD dd ? ; adress of the mid buffer for Right channel + + CURRENT_R_BUFFER_CARD dd ? ; current half for Right channel + + L_BUFFER_CARD dd ? ; adress of the buffer on the card for Left channel + MID_L_BUFFER_CARD dd ? ; adress of the mid buffer for Left channel + + CURRENT_L_BUFFER_CARD dd ? ; current half for Left channel +else + + BUFFER_DMA dd ? ; adress of the buffer + MID_BUFFER_DMA dd ? ; adress of the mid buffer + + CURRENT_BUFFER dd ? ; current half +endif + +ifdef INTERRRUPT + + DMA_COUNT dd ? + DMA_PTR dd ? + +endif + + +;*--------------------------------------------------------------------------* + +Redirector PROC + + int 18h + iretd + +Redirector ENDP + +;*--------------------------------------------------------------------------* + +setalc MACRO + + db 0D6h + + ENDM + + +lve MACRO Reg, Exp + + lea Reg, [Exp] + + ENDM + + +;*--------------------------------------------------------------------------* + +GET_REAL_VECT MACRO + + mov ax, 0200h + int 31h + + ENDM + + +SET_REAL_VECT MACRO + + mov ax, 0201h + int 31h + + ENDM + +GET_PROT_VECT MACRO + + mov ax, 0204h + int 31h + + ENDM + + +SET_PROT_VECT MACRO + + mov ax, 0205h + int 31h + + ENDM + +CRIT_SECT MACRO ; Enter Critical Section ;-) + + mov word ptr[Critical], 1 ; tell the IRQ not to update the buffer + ; we'll take care of it if nescessary O:-) + ENDM + + +END_CRIT_SECT MACRO ; Exit Critical Section O:-) + local NoUpdate ; Update buffer if necessary + + ; Dealing with the critical section flags................ + ; DO NOT TOUCH !!!! + + mov word ptr[Critical], 0 ; exit crit. sect. + ; this way DoUpdate can't change to 1 anymore + cmp word ptr[DoUpdate], 0 ; IRQ happened ? + je NoUpdate ; if DopUpdate change to 0 now, we are in deep + ; shit anyway because we missed one round! + ; The program won't crash but we'll ear the old + ; content of half a buffer and also miss half a buffer + ; of new data... :-( + mov word ptr[Critical], 1 ; yes, crit. again, so we don't update twice + ; because UpdateBuffer is not reentrant + ; and we don't want to take a chance on crashing! + pushad ; if DoUpdate change to 1 HERE + ; it means again that we missed one round! + ; So we play the buffer we are updating! (funny noise :-( ) + ; and then will ear half buffer of old data! + call UpdateBuffer ; do the update + popad + mov word ptr[Critical], 0 ; exit crit. sect + ; this way DoUpdate can't change to 1 anymore + mov word ptr[DoUpdate], 0 ; Update done, so DoUpdate = 0 +NoUpDate: + + ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !!!! + ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE BUFFER + ; TAKES MORE THAN 46000 microsec! + ; (at 33 Mhz one cycle = .03 microsec so 4600 microsec = 1.5 million cycle) + ENDM + + +;*--------------------------------------------------------------------------* + +GetDMAAddr PROC USES EBX + + xor eax, eax + +ifndef NOIRQ + + mov ebx, dword ptr[DMA] + + cli + + mov dx, word ptr[ebx + PAGE_REG] + in al, dx + shl eax, 16 + + mov dx, word ptr[ebx + FF_REG] + out dx, al ; Flip-Flop + + mov dx, word ptr[ebx + ADDX_REG] ; to get offset + + in al, dx + mov ah, al + in al, dx + + sti + + xchg al, ah + + cmp word ptr[DMA_number], 3 + jbe noadjust + lve eax, eax*2 + +noadjust: +endif + ret + +GetDMAAddr ENDP + +;*--------------------------------------------------------------------------* + +ifndef NOIRQ + +NewIRQ PROC + + pushad + push ds + push es + cld ; DAMN IT !! :-o + +local_DS equ $+2 + mov ax, 1234h + mov ds, ax ; restore DS + mov es, ax ; and ES !!! + + mov al, 20h ; allows for new int + cmp byte ptr[IRQ_number], 7 + jbe short NoSecondCtrl + out 0A0h, al +NoSecondCtrl: out 20h, al + +ifndef DEBUG + + call AckIrq + jc short FinIRQ ; not a DMA IRQ +ifdef SINGLE_DMA + call BlockTransfert ; Normal ACK location +endif + +endif + mov eax, dword ptr[BufferHalf] + xor al, 4 ; switch half + mov byte ptr[BufferHalf], al + +ifdef RAM_CARD + mov eax, dword ptr[R_BUFFER_CARD+eax]; get current card buffer address + mov dword ptr[CURRENT_R_BUFFER_CARD], eax; update CURRENT_BUFFER_CARD +else + mov eax, dword ptr[BUFFER_DMA+eax] ; get current buffer address + mov dword ptr[CURRENT_BUFFER], eax ; update CURRENT_BUFFER +endif + + mov word ptr[DoUpdate], 1 ; Time to do the update + + cmp word ptr[Critical], 0 ; crit. sect ? + jne FinIRQ ; yes, don't update yet! + + mov word ptr[Critical], 1 ; just to make jure it case the interrupt + call UpdateBuffer ; happen again before its finished + mov word ptr[Critical], 0 + + mov word ptr[DoUpdate], 0 ; Update done + +ifdef DEBUG + + call AckIrq + jc short FinIRQ ; not a DMA IRQ +ifdef SINGLE_DMA + call BlockTransfert ; Normal ACK location +endif + +endif + +FinIRQ: + pop es + pop ds + popad + + iretd + +NewIRQ ENDP + +endif + +;*--------------------------------------------------------------------------* + +ifdef GUS + PUBLIC Nolanguage UpdateBuffer +endif + +UpdateBuffer PROC + + mov eax, BUFFER_SIZE +ifdef RAM_CARD + mov edi, dword ptr[BUFFER_DMA] ; Buffer +else + mov edi, dword ptr[CURRENT_BUFFER] ; Buffer +endif + cmp byte ptr[FlagPause], 1 + je short dopause + + lea ebx, CurrentList ; Point to List of samples + + mov esi, dword ptr[ebx] ; Current Source + or esi, esi ; if 0 then empty list + jnz process_1st +dopause: + mov ecx, (BUFFER_SIZE * SSIZE) / 4 + MIDPOINT + rep stosd + + jmp endfade + +exit: + mov al, byte ptr[FlagPause] + dec al + js reallyexit + +ifdef RAM_CARD + mov edi, dword ptr[BUFFER_DMA] ; Buffer +else + mov edi, dword ptr[CURRENT_BUFFER] ; Buffer +endif + + mov esi, ( BUFFER_SIZE * SSIZE ) / 4 + bsr cx, si + + dec si ; no need to fade first/last sample + ; since it will be multiplied by 1 + dec al + jnz short fadeout + + mov ebx, 1 ; skip 0 + +ifdef SAMPLE16BIT + +loopfadein: mov edx, dword ptr[edi] + movsx eax, dx + imul eax, ebx + sar eax, cl + sar edx, 16 + imul edx, ebx + sar edx, cl + shl edx, 16 + mov dx, ax + mov dword ptr[edi], edx + add edi, 4 + inc bx + dec si + jnz short loopfadein + +else + +loopfadein: mov edx, dword ptr[edi] + xor edx, 80808080h ; convert to signed + REPT 2 + movsx eax, dl + imul eax, ebx + sar eax, cl + mov dl, al + movsx eax, dh + imul eax, ebx + sar eax, cl + mov dh, al + rol edx, 16 + ENDM + xor edx, 80808080h ; back to unsigned + mov dword ptr[edi], edx + add edi, 4 + inc bx + dec si + jnz short loopfadein + +endif + + jmp short endfade + +fadeout: + add edi, 4 ; skip first + +ifdef SAMPLE16BIT + +loopfadeout: mov edx, dword ptr[edi] + movsx eax, dx + imul eax, esi + sar eax, cl + sar edx, 16 + imul edx, esi + sar edx, cl + shl edx, 16 + mov dx, ax + mov dword ptr[edi], edx + add edi, 4 + dec si + jnz short loopfadeout + +else + +loopfadeout: mov edx, dword ptr[edi] + xor edx, 80808080h ; convert to signed + REPT 2 + movsx eax, dl + imul eax, esi + sar eax, cl + mov dl, al + movsx eax, dh + imul eax, esi + sar eax, cl + mov dh, al + rol edx, 16 + ENDM + xor edx, 80808080h ; back to unsigned + mov dword ptr[edi], edx + add edi, 4 + dec si + jnz short loopfadeout +endif +endfade: + mov al, byte ptr[FlagPause] + and al, 1 + mov byte ptr[FlagPause], al +reallyexit: + + ret +FinishFill0: + or ax, ax ; still some room in the buffer? + jz Finish2 +process_1st: + mov cx, ax + shl eax, 16 + mov ax, cx ; eax = BUFFER_SIZE:BUFFER_SIZE + mov dx, word ptr[ebx+FRACT] ; fractionnal Source + mov bp, word ptr[ebx+INCR] ; fractionnal inc + mov ecx, dword ptr[ebx+LEFT] ; length left + + cmp ecx, 0FFFFh ; length left to fill after sample + ja Longer0 ; 64K or +, then more than the buffer + sub ax, cx + jae short NotLonger0 ; some left? +Longer0: + shr eax, 16 + mov ecx, eax ; length = buffer_size + sub dword ptr[ebx+LEFT], ecx ; reduce length left + mov word ptr[save_4], 0 ; no room left + jmp short StartMix0 +NotLonger0: + inc ax ; length + 1 (in case left = 0) + mov word ptr[save_4], ax +StartMix0: + shl edx, 16 + or ecx, edx ; hecx = FRACT + shl ebp, 16 ; hebp = INCR + +ifdef SAMPLE16BIT + + mov edx, dword ptr[ebx+VOL_LEFT] ; read left & right volume + + ifdef STEREO + + cmp byte ptr[ebx+INTERPOL], 0 + je nofilter + + mov dword ptr[save_3], ebx + + movsx eax, dx + mov [TheVolumeL], eax + sar edx, 16 + mov [TheVolumeR], edx + + shr ebp, 16 ; BP = fract inc + mov edx, ecx + shr edx, 16 ; DX = fract + + rol ecx, 8 + mov cl, [ebx+LAST_SAMPLE] + ror ecx, 8 + + jmp short next0 + +start0: rol ecx, 8 + mov cl, [esi] + inc esi + ror ecx, 8 +next0: mov eax, ecx + mov al, [esi] ; read data + rol eax, 8 + xor ax, 8080h ; 8 bit signed + movsx ebx, al + movsx eax, ah ; sign extension to 32 bit + + not dx + inc edx + imul ebx, edx + dec edx + not dx + imul eax, edx + add ebx, eax + + mov eax, ebx + imul ebx, [TheVolumeR] ; Right + imul eax, [TheVolumeL] ; Left + sar eax, 16 + mov bx, ax + + mov [edi], ebx ; store buffer content + add edi, 4 ; next location + add dx, bp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next0 ; if (not C) and (not Z) next + jnz short start0 ; if some left, read a new one + + mov ebx, dword ptr[save_3] + + pushf + + rol ecx, 8 + mov [ebx+LAST_SAMPLE], cl + + shl edx, 16 + mov ecx, edx + inc esi + + popf + + jmp short end16 +nofilter: + mov dword ptr[save_3], ebx + +start01: lodsb ; read new data + xor al, 80h ; 8 bit signed + movsx eax, al ; sign extension to 32 bit + mov ebx, eax ; copy into ebx + imul ax, dx ; ax = left + imul ebx, edx + mov bx, ax +next01: mov dword ptr[edi], ebx ; write data + add edi, 4 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next01 ; if (not C) and (not Z) next + jnz short start01 ; if some left, read a new one + + mov ebx, dword ptr[save_3] +end16: + else + +start0: lodsb ; read new data + xor al, 80h ; 8 bit signed + movsx ax, al ; sign extension to 16 bit + imul ax, dx ; ax = "volumed" sample +next0: mov word ptr[edi], ax ; write data + add edi, 2 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next0 ; if (not C) and (not Z) next + jnz short start0 ; if some left, read a new one + + endif +else + + ifdef STEREO + + mov dl, byte ptr[ebx+VOL_LEFT] + or dl, dl + jz short middle0 + dec dl + jz short left0 + + mov al, 80h ; "0" -> left +r_start0: mov ah, byte ptr[esi] ; read new data -> right + inc esi +r_next0: mov word ptr[edi], ax ; write data + add edi, 2 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short r_next0 ; if (not C) and (not Z) next + jnz short r_start0 ; if some left, read a new one + jmp short end0 + +left0: + + mov ah, 80h ; "0" -> right +l_start0: lodsb ; read new data -> left +l_next0: mov word ptr[edi], ax ; write data + add edi, 2 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short l_next0 ; if (not C) and (not Z) next + jnz short l_start0 ; if some left, read a new one + jmp short end0 + +middle0: + +m_start0: lodsb ; read new data -> left + mov ah, al ; data -> right +m_next0: mov word ptr[edi], ax ; write data + add edi, 2 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short m_next0 ; if (not C) and (not Z) next + jnz short m_start0 ; if some left, read a new one + +end0: + else + +start0: lodsb ; read new data +next0: mov byte ptr[edi], al ; write data + inc edi ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next0 ; if (not C) and (not Z) next + jnz short start0 ; if some left, read a new one + + endif +endif + + jc noadjust0 ; was a new data going to be read? + dec esi ; no, last data will be read again +noadjust0: + mov ax, word ptr[save_4] ; left to copy + or ax, ax + jz Finish ; 0 normal end + + dec ax ; readjust size + + dec word ptr[ebx+REPEAT] ; repeat again? + jnz Reset0 ; yes, then reset + + mov edx, dword ptr[ebx+SON] ; no, got a son? + or edx, edx + js short NoSon0 ; no, remove the sample + + lea esi, SonList ; yes, then find it +KeepLooking0: + cmp dword ptr[esi], 0 ; the end ? + je short NoSon0 ; yes, then no son + cmp edx, dword ptr[esi+HANDLE] ; this one? + je short FoundSon0 ; yes, found! + add esi, STRUCT_SIZE ; no, keep looking + jmp short KeepLooking0 +NoSon0: + xor ecx, ecx + mov cx, ax ; clear rest of the buffer + MIDPOINT +IFDEF SBYTE + mov edx, ecx + and ecx, 3 ; up to 3 by byte + rep stosb + mov ecx, edx + shr ecx, 2 ; the rest by dword +ELSEIFDEF SWORD + shr ecx, 1 + jnc short NoAdjustByOne + stosw +NoAdjustByOne: +ENDIF + rep stosd + + mov esi, ebx ; point where it is + mov edi, ebx ; idem + add esi, STRUCT_SIZE ; source one further + +LoopRemove0: cmp dword ptr[esi], 0 ; end ? + je short EndRemove0 ; yes, exit + mov ecx, STRUCT_SIZE / 4 ; trasnfert one struct + rep movsd ; transfer + jmp short LoopRemove0 +EndRemove0: + mov dword ptr[edi], 0 ; write 0 to mark the end + jmp NextSample +FoundSon0: + mov ebp, esi ; save esi + mov edx, edi ; save edi + + mov edi, ebx ; transfert at the location of the father + mov ecx, STRUCT_SIZE / 4 ; count in dword + rep movsd ; transfert + + mov esi, ebp ; remove son from SonList + mov edi, ebp ; so, point to it + add esi, STRUCT_SIZE ; source one further +LoopSon0: cmp dword ptr[esi], 0 + je short EndSon0 + mov ecx, STRUCT_SIZE / 4 + rep movsd ; transfer while not 0 + jmp short LoopSon0 +EndSon0: + mov dword ptr[edi], 0 ; write 0 to mark the end + + mov edi, edx ; restore edi in the buffer + mov esi, dword ptr[ebx+START] ; restore source, no need to write it + jmp FinishFill0 +Reset0: + mov esi, dword ptr[ebx+START] ; restore source, no need to write it + mov ebp, dword ptr[ebx+DLENGTH] ; restore length + mov dword ptr[ebx+LEFT], ebp + mov word ptr[ebx+FRACT], 0 + jmp FinishFill0 + +NextSample: + mov esi, dword ptr[ebx] ; Current Source + or esi, esi ; if 0 then end of the list + jz exit + +ifdef RAM_CARD + mov edi, dword ptr[BUFFER_DMA] ; Buffer +else + mov edi, dword ptr[CURRENT_BUFFER] ; Buffer +endif + mov ax, BUFFER_SIZE +FinishFill: + or ax, ax ; still some room in the buffer? + jz Finish2 + + mov cx, ax + shl eax, 16 + mov ax, cx ; eax = BUFFER_SIZE:BUFFER_SIZE + mov dx, word ptr[ebx+FRACT] ; fractionnal Source + mov bp, word ptr[ebx+INCR] ; fractionnal inc + mov ecx, dword ptr[ebx+LEFT] ; length left + + cmp ecx, 0FFFFh ; length left to fill after sample + ja Longer ; 64K or +, then more than the buffer + sub ax, cx + jae short NotLonger ; some left? +Longer: + shr eax, 16 ; no, restore buffer_size in ax + mov ecx, eax ; length = buffer_size + sub dword ptr[ebx+LEFT], ecx ; reduce length left + mov word ptr[save_4], 0 ; no room left + jmp short startMix00 +NotLonger: + inc ax ; length + 1 (in case left = 0) + mov word ptr[save_4], ax +StartMix00: + shl edx, 16 + or ecx, edx ; hecx = FRACT + shl ebp, 16 ; hebp = INCR + +ifdef SAMPLE16BIT + + mov edx, dword ptr[ebx+VOL_LEFT] + + ifdef STEREO + +comment @ + + mov dword ptr[save_3], ebx + + movsx eax, dx + mov [TheVolumeL], eax + sar edx, 16 + mov [TheVolumeR], edx + + shr ebp, 16 ; BP = fract inc + mov edx, ecx + shr edx, 16 ; DX = fract + + dec esi + +start00: inc esi +next00: mov ax, [esi] ; read data + xor ax, 8080h ; 8 bit signed + movsx ebx, al + movsx eax, ah ; sign extension to 32 bit + not dx + inc edx + imul ebx, edx + dec edx + not dx + imul eax, edx + add ebx, eax + + mov eax, ebx + imul ebx, [TheVolumeR] ; Right + imul eax, [TheVolumeL] ; Left + sar eax, 16 + mov bx, ax + + add [edi], ebx ; add with buffer content (one bit might jump from right to left, but oh well...) + add edi, 4 ; next location + add dx, bp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next00 ; if (not C) and (not Z) next + jnz short start00 ; if some left, read a new one + + pushf + + shl edx, 16 + mov ecx, edx + inc esi + + popf + + mov ebx, dword ptr[save_3] + + @ + + mov dword ptr[save_3], ebx + +start00: lodsb ; read new data + xor al, 80h ; 8 bit signed + movsx eax, al ; sign extension to 32 bit + mov ebx, eax ; copy into ebx + imul ax, dx ; ax = left + imul ebx, edx + mov bx, ax +next00: add dword ptr[edi], ebx ; add with buffer content (one bit might jump from right to left, but oh well...) + add edi, 4 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next00 ; if (not C) and (not Z) next + jnz short start00 ; if some left, read a new one + + mov ebx, dword ptr[save_3] + + else + +start00: lodsb ; read new data + xor al, 80h ; 8 bit signed + movsx ax, al ; sign extension to 16 bit + imul ax, dx ; ax = "volumed" sample +next00: add word ptr[edi], ax ; add with buffer content + add edi, 2 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next00 ; if (not C) and (not Z) next + jnz short start00 ; if some left, read a new one + + endif +else + + ifdef STEREO + + mov dl, byte ptr[ebx+VOL_LEFT] + or dl, dl + jz short middle00 + dec dl + jz short left00 + + inc edi ; go right +r_start00: lodsb ; read new data + mov ah, al ; save it in ah +r_next00: add al, byte ptr[edi] ; add with buffer content + rcr al, 1 ; average + adc al, 0 + mov byte ptr[edi], al ; write result back + add edi, 2 ; next location + mov al, ah ; restore data + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short r_next00 ; if (not C) and (not Z) next + jnz short r_start00 ; if some left, read a new one + dec edi ; go back left + jmp short end00 + +left00: + +l_start00: lodsb ; read new data + mov ah, al ; save it in ah +l_next00: add al, byte ptr[edi] ; add with buffer content + rcr al, 1 ; average + adc al, 0 + mov byte ptr[edi], al ; write result back + add edi, 2 ; next location + mov al, ah ; restore data + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short l_next00 ; if (not C) and (not Z) next + jnz short l_start00 ; if some left, read a new one + jmp short end00 + +middle00: + +m_start00: lodsb ; read new data +m_next00: mov dx, word ptr[edi] ; read buffer, left & right + add dl, al ; average with left + rcr dl, 1 + adc dl, 0 + add dh, al ; average with right + rcr dh, 1 + adc dl, 0 + mov word ptr[edi], dx ; write result back + add edi, 2 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short m_next00 ; if (not C) and (not Z) next + jnz short m_start00 ; if some left, read a new one + +end00: + + else + +start00: lodsb ; read new data + mov ah, al ; save it in ah +next00: add al, byte ptr[edi] ; add with buffer content + rcr al, 1 ; average + adc al, 0 + mov byte ptr[edi], al ; write result back + inc edi ; next location + mov al, ah ; restore data + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next00 ; if (not C) and (not Z) next + jnz short start00 ; if some left, read a new one + + endif +endif + jc noadjust ; was a new data going to be read? + dec esi ; no, last data will be read again +noadjust: + mov ax, word ptr[save_4] ; left to copy + or ax, ax + jz short Finish ; 0 normal end + + dec ax ; readjust size + + dec word ptr[ebx+REPEAT] ; repeat again? + jnz short Reset ; yes, then reset + + mov edx, dword ptr[ebx+SON] ; no, got a son? + or edx, edx + js short NoSon ; no, remove the sample + + lea esi, SonList ; yes, then find it +KeepLooking: + cmp dword ptr[esi], 0 ; the end ? + je short NoSon ; yes, then no son + cmp edx, dword ptr[esi+HANDLE] ; this one? + je short FoundSon ; yes, found! + add esi, STRUCT_SIZE ; no, keep looking + jmp short KeepLooking +NoSon: ; remove it + mov esi, ebx ; point where it is + mov edi, ebx ; idem + add esi, STRUCT_SIZE ; source one further + +LoopRemove: cmp dword ptr[esi], 0 ; end ? + je short EndRemove ; yes, exit + mov ecx, STRUCT_SIZE / 4 ; trasnfert one struct + rep movsd ; transfer + jmp short LoopRemove +EndRemove: + mov dword ptr[edi], 0 ; write 0 to mark the end + jmp NextSample +FoundSon: + mov ebp, esi ; save esi + mov edx, edi ; save edi + + mov edi, ebx ; transfert at the location of the father + mov ecx, STRUCT_SIZE / 4 ; count in dword + rep movsd ; transfert + + mov esi, ebp ; remove son from SonList + mov edi, ebp ; so, point to it + add esi, STRUCT_SIZE ; source one further +LoopSon: cmp dword ptr[esi], 0 + je short EndSon + mov ecx, STRUCT_SIZE / 4 + rep movsd ; transfer while not 0 + jmp short LoopSon +EndSon: + mov dword ptr[edi], 0 ; write 0 to mark the end + + mov edi, edx ; restore edi in the buffer + mov esi, dword ptr[ebx+START] ; restore source, no need to write it + jmp FinishFill +Finish: + mov dword ptr[ebx], esi ; save current address + shr ecx, 16 + mov word ptr[ebx+FRACT], cx ; save fractional part +Finish2: add ebx, STRUCT_SIZE ; point to next sample + jmp NextSample +Reset: + mov esi, dword ptr[ebx+START] ; restore source, no need to write it + mov ebp, dword ptr[ebx+DLENGTH] ; restore length + mov dword ptr[ebx+LEFT], ebp + mov word ptr[ebx+FRACT], 0 + jmp FinishFill + +UpdateBuffer ENDP + +;*--------------------------------------------------------------------------* + +StopSample PROC + + CRIT_SECT + + xor eax, eax + + mov dword ptr[CurrentList], eax + mov dword ptr[SonList], eax + mov byte ptr[FlagPause], al + dec eax + mov dword ptr[follow], eax ; -1 + + mov dword ptr[weirdcount], 10000h + + END_CRIT_SECT + + ret + +StopSample ENDP + +;*--------------------------------------------------------------------------* + +StopOneSample PROC USES EBX ESI EDI,\ + thehandle:DWORD + + + push -1 ; end of recursion + mov eax, thehandle + lea edx, CurrentList + mov ebx, edx + + CRIT_SECT + +keeplooking: cmp dword ptr[ebx], 0 + je short exit + cmp ax, word ptr[ebx+HANDLE] + je short found + add ebx, STRUCT_SIZE + jmp short keeplooking +exit: + lea ebx, SonList + cmp edx, ebx + mov edx, ebx + jne short keeplooking + + pop eax ; get "son" + or eax, eax + jns short keeplooking ; less than #2 billions samples ! + + END_CRIT_SECT + + ret +found: + mov ecx, dword ptr[ebx+SON] + or ecx, ecx + js short noson + + push ecx ; "son" to be removed +noson: + mov esi, ebx + mov edi, ebx + add esi, STRUCT_SIZE +LoopRemove: cmp dword ptr[esi], 0 + je short EndRemove + mov ecx, STRUCT_SIZE / 4 + rep movsd + jmp short LoopRemove +EndRemove: + mov dword ptr[edi], 0 + jmp short keeplooking + +StopOneSample ENDP + +;---------------------------------------------------------------------------- + +ShiftSamples PROC USES ESI EDI EBX,\ + DestAddr:DWORD, SrcAddr:DWORD, SizeByte:DWORD + + lea edx, CurrentList + + mov esi, SrcAddr ; Source + mov eax, esi ; save Source for comparison + mov edi, DestAddr ; Destination + mov ecx, SizeByte ; number of bytes to move + + mov bl, cl ; compute counters + shr ecx, 2 + and bl, 3 + + CRIT_SECT + + rep movsd ; move the data + mov cl, bl + rep movsb + + sub edi, esi ; shift (delta addr) + + mov ebx, edx + +keeplooking: cmp dword ptr[ebx], 0 + je short exit + cmp eax, [ebx+START] + ja short notfound + add [ebx+START], edi + add [ebx], edi +notfound: + add ebx, STRUCT_SIZE + jmp short keeplooking +exit: + lea ebx, SonList + cmp edx, ebx + mov edx, ebx + jne short keeplooking + + END_CRIT_SECT + + ret + +ShiftSamples ENDP + +;---------------------------------------------------------------------------- + +StopOneSampleLong PROC USES ESI EDI,\ + LongHandle:DWORD + + mov eax, LongHandle + + CRIT_SECT + + call SearchLongHandle + or edx, edx + jz short notfound + + mov esi, edx + mov edi, edx + add esi, STRUCT_SIZE +LoopRemove: cmp dword ptr[esi], 0 + je short EndRemove + mov ecx, STRUCT_SIZE / 4 + rep movsd + jmp short LoopRemove +EndRemove: + mov dword ptr[edi], 0 +notfound: + END_CRIT_SECT + + ret + +StopOneSampleLong ENDP + +;*--------------------------------------------------------------------------* + +SampleInList PROC USES EBX,\ + thehandle:DWORD + + CRIT_SECT + + mov edx, thehandle + mov eax, 1 ; True + + lea ecx, CurrentList + mov ebx, ecx + +keeplooking: cmp dword ptr[ebx], 0 + je short exit + cmp dx, word ptr[ebx+HANDLE] + je short found + add ebx, STRUCT_SIZE + jmp short keeplooking +exit: + lea ebx, SonList + cmp ecx, ebx + mov ecx, ebx + jne keeplooking + + xor eax, eax ; False +found: + END_CRIT_SECT + + ret + +SampleInList ENDP + + +;*--------------------------------------------------------------------------* + +SearchLongHandle PROC + + lea edx, CurrentList + lea ecx, SonList + +keeplooking: cmp dword ptr[edx], 0 + je short exit + cmp eax, dword ptr[edx+HANDLE] + je short found + add edx, STRUCT_SIZE + jmp short keeplooking +exit: + cmp edx, ecx + mov edx, ecx + jne keeplooking + + xor edx, edx +found: + ret + +SearchLongHandle ENDP + + +;*--------------------------------------------------------------------------* + +ChangeVolume PROC \ + LongHandle:DWORD, volleft:DWORD, volright:DWORD + +ifdef STEREO + ifdef SAMPLE16BIT + + mov eax, LongHandle + + CRIT_SECT + + call SearchLongHandle + or edx, edx + jz short notfound + + mov eax, volleft + shr eax, SHIFT_SAMPLE - 1 ; Preshift according to number of channels + mov word ptr[edx+VOL_LEFT], ax + mov eax, volright + shr eax, SHIFT_SAMPLE - 1 ; Preshift according to number of channels +ifdef SURROUND + neg eax +endif + mov word ptr[edx+VOL_RIGHT], ax + +notfound: + + END_CRIT_SECT + + else + + mov eax, LongHandle + + CRIT_SECT + + call SearchLongHandle + or edx, edx + jz short notfound + + push edi + mov edi, edx + + mov cx, word ptr[volleft] + or cx, cx + jnz short okleft + mov cx, 2 ; if volleft = 0 then right + jmp short storepos +okleft: mov ax, word ptr[volright] + shl ax, 7 ; * 128 + xor dx, dx + div cx + mov cx, 2 ; right + cmp ax, 222 ; 1.732 (= tan 60) * 128 + jae short storepos + dec cx ; left + cmp ax, 74 ; .577 (= tan 30) * 128 + jb short storepos + dec cx ; middle +storepos: mov word ptr[edi+VOL_LEFT], cx ; Store position (0:middle, 1:left, 2:right) + + pop edi +notfound: + + END_CRIT_SECT + + endif +else + ifdef SAMPLE16BIT + + mov eax, LongHandle + + CRIT_SECT + + call SearchLongHandle + or edx, edx + jz short notfound + + push edi + push ebx + mov edi, edx + + mov eax, volleft + imul eax, eax + mov ecx, volright + imul ecx, ecx + add eax, ecx + call sqr2 + shr eax, SHIFT_SAMPLE - 1 ; Preshift according to number of channels + mov word ptr[edi+VOL_LEFT], ax ; VOL_LEFT = sqr(volleft^2 + volright^2) + + pop ebx + pop esi + +notfound: + + END_CRIT_SECT + + endif +endif + + ret + +ChangeVolume ENDP + +ifdef SAMPLE16BIT +ifndef STEREO + +;*--------------------------------------------------------------------------* + +; EAX = Sqr(EAX) + +Sqr2 PROC + + cmp eax, 3 ; if eax <= 3 then + jbe short asqr_0_1 ; square root is 0 or 1 + + xor edx, edx ; clear edx + mov ebx, eax ; copy eax into ebx so that + ; edx:ebx are used "like" a 64 bit + ; register + + bsr eax, ebx ; position of last 1 of ebx in eax + + mov cl, 33 ; compute how many left shift + sub cl, al ; are needed in order to have the + and cl, 11111110b ; most significant 2 bit pair at the + ; leftmost position of edx + + shld edx, ebx, cl ; shift edx:ebx by the number + shl ebx, cl ; computed above + + mov ecx, eax ; compute in ecx how many pairs of + shr ecx, 1 ; 2 bit are left to be processed + + mov eax, 1 ; eax = 1 + dec edx ; edx = edx - 1 + +asqr_loop: shld edx, ebx, 2 ; edx:ebx << 2 + shl ebx, 2 ; + lve eax, eax*2 ; eax * 2 + cmp edx, eax ; compare edx and eax + jb short asqr_neg ; if edx> 1 + dec ecx ; one less pair to process + jnz short asqr_loop ; if there is some left then go asqr_loop + ret ; return to caller + +asqr_0_1: or eax, eax ; if eax = 0 + jz short asqr_00 ; then return to caller + mov eax, 1 ; else eax = 1 +asqr_00: ret ; return to caller + +Sqr2 ENDP + +endif +endif + +;*--------------------------------------------------------------------------* + +MixSample PROC USES ESI EDI EBX,\ + thehandle:DWORD, pitchbend:DWORD, therepeat:DWORD,\ + plug:DWORD, volleft:DWORD, volright:DWORD,\ + buffer:DWORD; buffer with .VOC + + mov esi, buffer + + xor eax, eax + mov al, [esi] + inc al + cmp al, 10 + jb okfilter + + xor eax, eax + +okfilter: push eax + + movzx eax, word ptr[esi+14h] + add esi, eax ; skip header + + cmp byte ptr[esi], 1 ; only 1 bloc type allowed + jne typeunknown + + cmp byte ptr[esi + 5], 0 ; pack method + jne typeunknown + + ; This crap should be removed by using a file format containing the + ; real sampling frequency instead of that stupid sr number in .VOC ! + ; :-( + + mov dx, 0Fh + mov ax, 4240h ; dx:ax = 1000000 + + xor ebx, ebx + mov bl, byte ptr[esi + 4] ; bl = sr + neg bl ; bl = 256 - sr + + div bx + + shl dx, 1 + adc ax, 0 ; round to nearest + + mov bx, ax + + ; ebx = real sampling rate + ; up to here ! and then avoid this ^ div ! + + + mov eax, dword ptr[esi + 1] ; size sample + and eax, 0FFFFFFh ; 24 significant bits + sub eax, 2 ; -2 header + + + add esi, 6 ; esi->data + mov dword ptr[save_1], esi ; save it + + mov edx, pitchbend + shl edx, 4 + + imul ebx, edx + shr ebx, 16 + adc bx, 0 ; ebx = scaled sampling rate + + xor edx, edx + xchg eax, ebx ; edx = 0, eax = sr, ebx = size + xchg edx, eax ; edx = sr, eax = 0, ebx = size + div word ptr[PlayRate] ; dx:ax / PlayRate; ax = INCR + + cmp eax, 0FFFFh + jbe okincr + mov eax, 0FFFFh +okincr: mov dword ptr[save_2], eax ; save_2 = INCR + + mov ecx, ebx ; ecx = size + mov esi, ebx + shr esi, 16 ; esi = hi(size) + + mov edx, esi + xchg eax, ebx ; eax = size, ebx = INCR + + dec eax ; A TRY !!!! (will make loop around next longer...) + + shl eax, 16 + div ebx ; div 64 bits !!! + sub eax, esi ; sub max roundoff error + mov esi, eax ; esi = eax = new size + + mul ebx ; remultiply + mov bx, ax ; FRACT in bx + shrd eax, edx, 16 ; size in eax + mov dx, word ptr[save_2] ; INCR in dx + + sub ecx, eax ; how much am I off? + jbe typeunknown ; security, should not happen! + +next: inc esi ; length + 1 + add bx, dx ; update fractional part of address + jnc short next ; if (not C) next + dec cx + jnz short next ; not right yet, loop + + mov eax, dword ptr[follow] + lea ebx, CurrentList + mov edi, ebx + + mov cx, word ptr[thehandle] + or ecx, dword ptr[weirdcount] ; why not ? + inc word ptr[weirdcount+2] + + CRIT_SECT + + cmp plug, 0 + je NoPlug + + lea edi, SonList + +keeplooking0: cmp dword ptr[ebx], 0 + je short SearchSonList + cmp eax, dword ptr[ebx+HANDLE] ; look for the "father" sample + je short found + add ebx, STRUCT_SIZE + jmp short keeplooking0 +SearchSonList: + lea ebx, SonList +keeplooking1: cmp dword ptr[ebx], 0 + je short Exit + cmp eax, dword ptr[ebx+HANDLE] ; look for the "father" sample + je short found + add ebx, STRUCT_SIZE + jmp short keeplooking1 +exit: + xor eax, eax + jmp endcritical +found: + mov dword ptr[ebx+SON], ecx ; connect it to ist "son" +NoPlug: + xor eax, eax + sub edi, STRUCT_SIZE + +SearchEnd: add edi, STRUCT_SIZE + cmp eax, dword ptr[edi] + jne short SearchEnd + + mov dword ptr[follow], ecx ; update follow + mov dword ptr[edi+HANDLE], ecx ; sample handle + mov cx, word ptr[therepeat] + mov word ptr[edi+REPEAT], cx ; Repeat + mov dword ptr[edi+LEFT], esi ; length + mov dword ptr[edi+DLENGTH], esi ; length + mov eax, dword ptr[save_1] + mov dword ptr[edi], eax ; Start + mov dword ptr[edi+START], eax ; Start + mov eax, dword ptr[save_2] + mov word ptr[edi+INCR], ax ; increment + mov dword ptr[edi+FRACT], 10000h ; fractional (with 1 above so != 0) + mov dword ptr[edi+SON], -1 ; son + mov dword ptr[edi+INFO0], -1 ; info0 + pop eax + mov [edi+INTERPOL], al ; filter on/off + mov [edi+LAST_SAMPLE], 80h ; 80h ( 0 ) +ifdef STEREO + ifdef SAMPLE16BIT + mov eax, volleft + shr eax, SHIFT_SAMPLE - 1 ; Preshift according to number of channels + mov word ptr[edi+VOL_LEFT], ax + mov eax, volright + shr eax, SHIFT_SAMPLE - 1 ; Preshift according to number of channels +ifdef SURROUND + neg eax +endif + mov word ptr[edi+VOL_RIGHT], ax + else + mov si, 2 ; right + mov cx, word ptr[volleft] + or cx, cx + jz short storepos +okleft: mov ax, word ptr[volright] + shl ax, 7 ; * 128 + xor dx, dx + div cx + cmp ax, 222 ; 1.732 (= tan 60) * 128 + jae short storepos + dec si ; left + cmp ax, 74 ; .577 (= tan 30) * 128 + jb short storepos + dec si ; middle +storepos: mov word ptr[edi+VOL_LEFT], si ; Store position (0:middle, 1:left, 2:right) + mov word ptr[edi+VOL_RIGHT], 1 ; to fill with non 0 + endif +else + ifdef SAMPLE16BIT + mov eax, volleft + imul eax, eax + mov ecx, volright + imul ecx, ecx + add eax, ecx + call sqr2 + shr eax, SHIFT_SAMPLE - 1 ; Preshift according to number of channels + mov word ptr[edi+VOL_LEFT], ax ; VOL_LEFT = sqr(volleft^2 + volright^2) + mov word ptr[edi+VOL_RIGHT], 1 ; to fill with non 0 + else + mov dword ptr[edi+VOL_LEFT], 1 ; to fill with non 0 + endif +endif + mov dword ptr[edi+STRUCT_SIZE], 0 ; mark end of List + + mov eax, dword ptr[follow] +endcritical: + END_CRIT_SECT + + ret +typeunknown: + pop eax + xor eax, eax + ret + +MixSample ENDP + +;*--------------------------------------------------------------------------* + +ifdef SINGLE_DMA + +BlockTransfert PROC + + push ebx + + mov ecx, BUFFER_SIZE * SSIZE + cmp word ptr[DMA_number], 3 + jbe noLengthAdj + shr ecx, 1 +NoLengthAdj: + dec ecx ; buffer size - 1 + + mov ebx, dword ptr[DMA] ; Point to DMAx + + mov dx, word ptr[ebx + MASK_REG] + mov al, byte ptr[ebx + MASK2] ; mask channel + out dx, al + + mov dx, word ptr[ebx + FF_REG] + out dx, al ; flip-flop + + + mov dx, word ptr[ebx + COUNT_REG] + mov al, cl ; buffer size - 1 + out dx, al + mov al, ch + out dx, al + + mov dx, word ptr[ebx + ADDX_REG] + mov eax, dword ptr[BufferHalf] + mov eax, dword ptr[BUFFER_DMA+eax] ; start offset + cmp word ptr[DMA_number], 3 + jbe noAddrAdj + shr eax, 1 +NoAddrAdj: + out dx, al + shr eax, 8 + out dx, al + + mov dx, word ptr[ebx + PAGE_REG] + shr eax, 8 ; page of DMA transfert + out dx, al + + mov dx, word ptr[ebx + MODE_REG] + mov al, byte ptr[ebx + VOICE_OUT] ; output sample + out dx, al + + mov dx, word ptr[ebx + MASK_REG] + mov al, byte ptr[ebx + MASK1] ; channel OK + out dx, al + + pop ebx + + jmp StartDMACard + +BlockTransfert ENDP + +endif + +;*--------------------------------------------------------------------------* + +PauseSample PROC + + CRIT_SECT + + mov al, byte ptr[FlagPause] + dec al + and al, 10b + or al, 01b ; 0->3, 1->1, 2->1, 3->3 + mov byte ptr[FlagPause], al + + END_CRIT_SECT + + ret + +PauseSample ENDP + +;*--------------------------------------------------------------------------* + +ContinueSample PROC + + CRIT_SECT + + mov al, byte ptr[FlagPause] + inc al + and al, 10b ; 0->0, 1->2, 2->2, 3->0 + mov byte ptr[FlagPause], al + + END_CRIT_SECT + + ret + +ContinueSample ENDP + +;---------------------------------------------------------------------------- + +ifndef NOIRQ + +InstallISR PROC + + push edx + + mov bl, byte ptr[INT_number] ; plug ISR on user INT + mov cx, cs + SET_PROT_VECT + + pop edx + + cmp dword ptr[IRQ_number], 7 ; if IRQ > 7 + jbe nobi + + mov bl, 18h ; plug as well on int 18h + mov cx, cs + SET_PROT_VECT + + mov bl, byte ptr[INT_number] ; plug into real usr INT + mov ecx, offset Redirector + mov dx, cx ; compute real-mode + xor cx, cx ; seg:ofs + shr ecx, 4 + SET_REAL_VECT +nobi: + ret + +InstallISR ENDP + +endif + +;---------------------------------------------------------------------------- + +InitCard PROC USES EBX EDI ESI EBP,\ + Buffer:DWORD + +ifndef NOIRQ + mov word ptr[local_DS], ds +endif + mov eax, Buffer + mov dword ptr[BUFFER_DMA], eax + +ifndef SBPRO + call ResetCard +endif + +ifndef NOIRQ + + xor eax, eax + mov ax, word ptr[DMA_number] + cmp ax, 7 + ja short ErrorDMA + mov eax, dword ptr[TAB_DMA+eax*4] + or eax, eax + jnz short DMAFound +ErrorDMA: + xor eax, eax + ret +DMAFound: + mov dword ptr[DMA], eax + + mov eax, dword ptr[IRQ_number] + cmp al, 7 + ja short Second + add al, 8 + jmp short gotvect +Second: + add al, 70h - 8 +gotvect: + mov dword ptr[INT_number], eax ; save user int + + mov bl, al + GET_PROT_VECT + mov word ptr[Old_PIRQ_Sel], cx + mov dword ptr[Old_PIRQ_Off], edx + + cmp dword ptr[IRQ_number], 7 + jbe nobi + + mov bl, byte ptr[INT_number] ; if IRQ>7 save real vect + GET_REAL_VECT + mov word ptr[Old_RIRQ_Seg], cx + mov word ptr[Old_RIRQ_Off], dx + + mov bl, 18h ; if IRQ>7 save int 18h + GET_PROT_VECT + mov word ptr[Old_18_Sel], cx + mov dword ptr[Old_18_Off], edx +nobi: + + mov dx, 21h ; IRQ mask reg + mov cx, word ptr[IRQ_number] + cmp cx, 7 + jbe short Ok21 + mov dx, 0A1h ; reg A1h, 2nd ctrl +Ok21: in al, dx + mov byte ptr[IRQ_mask], al ; save mask + and cl, 7 + mov bl, 1 + shl bl, cl + not bl + and al, bl ; unmask IRQ + out dx, al ; write new mask + +ifdef SBPRO + call ResetCard +endif + + mov edx, offset NewIRQ + call InstallISR +endif + call StopSample ; to reset everything + + xor eax, eax + mov dword ptr[BackCurrentList], eax + mov dword ptr[BackSonList], eax + + mov edi, dword ptr[BUFFER_DMA] + + mov eax, edi + add eax, BUFFER_SIZE * SSIZE + mov dword ptr[MID_BUFFER_DMA], eax ; init pointer + mov dword ptr[CURRENT_BUFFER], eax ; init pointer + + mov dword ptr[BufferHalf], 4 ; point on second half + + mov ecx, (BUFFER_SIZE * 2 * SSIZE) / 4; clear all buffer + MIDPOINT + rep stosd + +ifndef NOIRQ + +ifdef AUTO_DMA + + mov ecx, BUFFER_SIZE * 2 * SSIZE + cmp word ptr[DMA_number], 3 + jbe noLengthAdj + shr ecx, 1 +NoLengthAdj: + dec ecx + + mov ebx, dword ptr[DMA] ; Point to DMAx + + mov dx, word ptr[ebx + MASK_REG] + mov al, byte ptr[ebx + MASK2] ; mask channel + out dx, al + + mov dx, word ptr[ebx + FF_REG] + out dx, al ; flip-flop + + mov dx, word ptr[ebx + COUNT_REG] + mov al, cl ; buffer size - 1 + out dx, al + mov al, ch + out dx, al + + mov dx, word ptr[ebx + ADDX_REG] + mov eax, dword ptr[BUFFER_DMA] ; start offset + cmp word ptr[DMA_number], 3 + jbe noAddrAdj +; shr eax, 1 + shr eax, 1 + mov di, ax + xor ax, ax + shl eax, 1 + mov ax, di +NoAddrAdj: + out dx, al + shr eax, 8 + out dx, al + + mov dx, word ptr[ebx + PAGE_REG] + shr eax, 8 ; page of DMA transfert + out dx, al + + mov dx, word ptr[ebx + MODE_REG] + mov al, byte ptr[ebx + AUTO_OUT] ; output sample + out dx, al + + mov dx, word ptr[ebx + MASK_REG] + mov al, byte ptr[ebx + MASK1] ; channel OK + out dx, al +endif + +endif + +ifdef AUTO_DMA + call StartDMACard +elseifdef SINGLE_DMA + call BlockTransfert ; Start DMA transfert +endif + mov eax, 1 + ret + +InitCard ENDP + +;---------------------------------------------------------------------------- + +ClearCard PROC USES EBX ESI EDI EBP + + call StopSample ; just in case something was playing... + call CloseCard + +ifndef NOIRQ + mov dx, 21h ; read IRQ mask + cmp word ptr[IRQ_number], 7 + jbe short Ok21 + add dx, 80h ; reg 0A1h +Ok21: mov al, byte ptr[IRQ_mask] ; get old mask + out dx, al ; write old IRQ mask + + mov bl, byte ptr[INT_number] + mov cx, word ptr[Old_PIRQ_sel] + mov edx, dword ptr[Old_PIRQ_off] + SET_PROT_VECT + + cmp dword ptr[IRQ_number], 7 + jbe nobi + + mov bl, byte ptr[INT_number] + mov cx, word ptr[Old_RIRQ_seg] + mov dx, word ptr[Old_RIRQ_off] + SET_REAL_VECT + + mov bl, 18h + mov cx, word ptr[Old_18_sel] + mov edx, dword ptr[Old_18_off] + SET_PROT_VECT +nobi: + +endif + + ret + +ClearCard ENDP + +;---------------------------------------------------------------------------- + +AskVars PROC ,\ + pListNames:DWORD, pListVars:DWORD + + mov eax, offset ListNames + mov ecx, pListNames + mov dword ptr[ecx], eax + mov eax, offset ListVars + mov ecx, pListVars + mov dword ptr[ecx], eax + ret + +AskVars ENDP + + +;---------------------------------------------------------------------------- + +GetBufferSize PROC + + mov eax, BUFFER_SIZE * 2 * SSIZE + + ret + +GetBufferSize ENDP + +;---------------------------------------------------------------------------- + +GiveSampleInfo0 PROC \ + LongHandle:DWORD, Info:DWORD + + mov eax, LongHandle + + CRIT_SECT + + call SearchLongHandle + or edx, edx + jz short notfound + + mov eax, Info + mov dword ptr[edx+INFO0], eax +notfound: + END_CRIT_SECT + + ret + +GiveSampleInfo0 ENDP + +;---------------------------------------------------------------------------- + +GetSnapSample PROC USES EBX,\ + pList:DWORD + + lea eax, SnapList + mov edx, pList + mov dword ptr[edx], eax + + lea edx, CurrentList + lea ecx, SonList + + CRIT_SECT + +keeplooking: cmp dword ptr[edx], 0 + je short exit + + mov ebx, dword ptr[edx+HANDLE] + mov dword ptr[eax], ebx + mov ebx, dword ptr[edx+INFO0] + mov dword ptr[eax+4], ebx + mov ebx, dword ptr[edx] + sub ebx, dword ptr[edx+START] + mov dword ptr[eax+8], ebx + + add eax, 12 + add edx, STRUCT_SIZE + jmp short keeplooking +exit: + cmp ecx, edx + mov edx, ecx + jne keeplooking + + END_CRIT_SECT + + sub eax, offset SnapList + shr eax, 3 + + ret + +GetSnapSample ENDP + + +;---------------------------------------------------------------------------- + +CopyList PROC + +keepcopying: cmp dword ptr[esi], 0 + je short endcopy + mov ecx, STRUCT_SIZE / 4 + rep movsd + jmp short keepcopying +endcopy: mov dword ptr[edi], 0 + ret + +CopyList ENDP + +;---------------------------------------------------------------------------- + +SAveStateSample PROC USES ESI EDI + + call PauseSample + +waitpause: cmp byte ptr[FlagPause], 1 + jne short waitpause + + CRIT_SECT + + lea esi, CurrentList ; backup CurrentList + lea edi, BackCurrentList + call CopyList + lea esi, SonList ; backup SonList + lea edi, BackSonList + call CopyList + mov eax, dword ptr[follow] ; Backup follow + mov dword ptr[backfollow], eax + mov eax, dword ptr[weirdcount] ; Backup weirdcount + mov dword ptr[backweirdcount], eax + + xor eax, eax ; empty both lists + mov dword ptr[CurrentList], eax + mov dword ptr[SonList], eax + + END_CRIT_SECT + + mov byte ptr[FlagPause], 0 + + ret + +SAveStateSample ENDP + +;---------------------------------------------------------------------------- + +RestoreStateSample PROC USES ESI EDI + + call PauseSample + +waitpause: cmp byte ptr[FlagPause], 1 + jne short waitpause + + CRIT_SECT + + lea esi, BackCurrentList ; restore CurrentList + lea edi, CurrentList + call CopyList + lea edi, BackSonList ; restore SonList + lea edi, SonList + call CopyList + mov eax, dword ptr[backfollow] ; restore follow + mov dword ptr[follow], eax + mov eax, dword ptr[backweirdcount] ; restore weirdcount + mov eax, dword ptr[weirdcount] + + END_CRIT_SECT + + call ContinueSample + +waitcontinue: cmp byte ptr[FlagPause], 0 + jne short waitcontinue + + ret + +RestoreStateSample ENDP + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef MWSS + +ResetCard PROC USES EBX + + + mov ax, word ptr[PlayRate] + cmp ax, 44100 + jae short Freq44 + lea edx, MWSSFreq +SearchFreq: cmp ax, word ptr[edx] + jb short FoundFreq + add edx, 4 + jmp short SearchFreq +Freq44: + mov ax, 44100 + mov cl, 0Bh + jmp short WBack +FoundFreq: + mov ax, word ptr[edx] ; closest faster speed + mov cl, byte ptr[edx+2] ; clock select +WBack: + mov word ptr[PlayRate], ax + or cl, 01010000b ; 16 bit linear, Stereo + + mov edx, [IRQ_number] ; IRQ + mov al, [MWSSIrq+edx] + + mov edx, [DMA_number] ; DMA + or al, [MWSSDma+edx] + + mov dx, word ptr[BASE_ADDR] + + add dl, 3 ; offset 3 + out dx, al ; program IRQ & DMA + + inc dl ; offset 4 + mov al, 6 ; left vol + out dx, al + inc dl ; offset 5 + mov al, 80h ; mute + out dx, al + dec dl ; offset 4 + mov al, 7 ; right vol + out dx, al + inc dl ; offset 5 + mov al, 80h ; mute + out dx, al + + dec dl ; offset 4 + mov al, 13 ; digital mix + out dx, al + inc dl ; offset 5 + xor al, al ; mute + out dx, al + + dec dl ; offset 4 + mov al, 2 ; left aux1 + out dx, al + inc dl ; offset 5 + mov al, 80h ; mute + out dx, al + dec dl ; offset 4 + mov al, 3 ; right aux1 + out dx, al + inc dl ; offset 5 + mov al, 80h ; mute + out dx, al + + dec dl ; offset 4 + mov al, 4 ; left aux2 + out dx, al + inc dl ; offset 5 + mov al, 80h ; mute + out dx, al + dec dl ; offset 4 + mov al, 5 ; right aux2 + out dx, al + inc dl ; offset 5 + mov al, 80h ; mute + out dx, al + + dec dl ; offset 4 + mov al, 49h ; enter MCE, Interface Ctrl + out dx, al + inc dl ; offset 5 + mov al, 08h ; auto-calibrate + out dx, al + + dec dl ; offset 4 + mov al, 48h ; MCE, Interface Ctrl + out dx, al + inc dl ; offset 5 + mov al, cl ; 16 bit linear, stereo, speed + out dx, al + + dec dl ; offset 4 +wait_init: in al, dx + and al, 80h + jnz wait_init + + + xor al, al + out dx, al ; clear MCE + + xor bx, bx ; at least 6 millisec. +wait0: in al, dx + dec bx + jnz short wait0 + + +wait_cal: mov al, 0Bh ; Test & Init Reg + out dx, al + inc dl ; offset 5 + in al, dx + dec dl ; offset 4 + and al, 20h + jnz wait_cal + + mov al, 6 ; left vol + out dx, al + inc dl ; offset 5 + xor al, al ; max vol + out dx, al + dec dl ; offset 4 + mov al, 7 ; right vol + out dx, al + inc dl ; offset 5 + xor al, al ; max vol + out dx, al + + ret + +ResetCard ENDP + +;*--------------------------------------------------------------------------* + +CloseCard PROC + + mov dx, word ptr[BASE_ADDR] ; DSP + + add dl, 4 ; offset 4 + mov al, 0Ah ; Pin Ctrl reg + out dx, al + inc dx ; offset 5 + xor al, al ; turn off interrupts + out dx, al + + inc dx ; offset 6 + out dx, al ; Ack outstanding interrupts + + sub dl, 2 ; offset 4 + mov al, 9 ; Interface Config reg + out dx, al + inc dx ; offset 5 + xor al, al ; turn off codec DMA + out dx, al + + sub dl, 2 + out dx, al ; deselect IRQ and DMA + + ret + +CloseCard ENDP + +;---------------------------------------------------------------------------- + +AckIrq PROC + + mov dx, word ptr[BASE_ADDR] ; DSP + add dl, 6 + in al, dx + shr al, 1 ; get int flag in C + cmc ; complement C in order to return error if 0 + out dx, al ; Ack anyway + ret + +AckIrq ENDP + +;---------------------------------------------------------------------------- + +StartDMACard PROC + + mov cx, BUFFER_SIZE - 1 + + mov dx, word ptr[BASE_ADDR] ; DSP + + add dl, 6 + out dx, al ; clear any pending IRQ + + sub dl, 2 ; offset 4 + mov al, 15 ; DMA Count Lower + out dx, al + inc dl ; offset 5 + mov al, cl + out dx, al + dec dl ; offset 4 + mov al, 14 ; DMA Count Upper + out dx, al + inc dl ; offset 5 + mov al, ch + out dx, al + + dec dl ; offset 4 + mov al, 9 ; Interface config + out dx, al + inc dl ; offset 5 + mov al, 00000101b ; DMA Playback + out dx, al + dec dl ; offset 4 + mov al, 0Ah ; Pin Ctrl Reg + out dx, al + inc dx ; offset 5 + mov al, 00000010b ; Turn on Interrupts + out dx, al + + ret + +StartDMACard ENDP + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef SBLASTER + +WRITE_DSP MACRO VAL ; write to DSP whithout timeout + local wait_dsp + +wait_dsp: in al, dx + or al, al + js wait_dsp + + mov al, VAL + out dx, al + + ENDM + +WRITE_MIXER MACRO REG, VAL ; write to MIXER chip + + mov al, REG + out dx, al + inc dx + mov al, VAL + out dx, al + dec dx + + ENDM + +READ_MIXER MACRO REG ; read from MIXER chip + + mov al, REG + out dx, al + inc dx + in al, dx + dec dx + + ENDM + +ifdef SBPRO + +InitIRQ PROC + + pushad + push ds + + mov ax, cs:word ptr[local_DS] ; restore DS + mov ds, ax + + mov al, 20h ; allows for new int + cmp byte ptr[IRQ_number], 7 + jbe short NoSecondCtrl + out 0A0h, al +NoSecondCtrl: out 20h, al + + call AckIrq + jc short FinIRQ ; not a DMA IRQ + + mov byte ptr[OkIRQ], 1 +FinIRQ: + pop ds + popad + + iretd + +InitIRQ ENDP + +endif + + +ResetCard PROC + + cmp dword ptr[PlayRate], 12000 + jae OkRateLow + mov dword ptr[PlayRate], 12000 +OkRateLow: + + cmp dword ptr[PlayRate], 22000 + jbe OkRateHigh + mov dword ptr[PlayRate], 22000 +OkRateHigh: + +ifndef SB16 + ifdef SBPRO + mov dx, 07A1h + mov ax, 2000h ; dx:ax = 128000000 + else + mov dx, 0F42h + mov ax, 4000h ; dx:ax = 256000000 + endif + div word ptr[PlayRate] ; divide by PlayRate + neg ax + shr ax, 8 + mov cx, ax ; cl = "Magic" + + push ecx + + ifdef SBPRO + mov dx, 07h + mov ax, 0A120h ; dx:ax = 500000 + else + mov dx, 0Fh + mov ax, 4240h ; dx:ax = 1000000 + endif + neg cl + div cx ; divide by "-Magic" + mov word ptr[PlayRate], ax ; write back PlayRate +endif + + mov dx, word ptr[BASE_ADDR] + add dl, 6 ; reset port (offset 6) + mov al, 1 ; write 1 + out dx, al + + mov ah, 8 * 3 ; 4 * "in al, dx" = 1 microsec on std ISA bus (8 Mhz) +wait_io: in al, dx ; so 8 to be sure if 16 MHz ! + dec ah ; kill the cat ! + jnz short wait_io + + xor al, al + out dx, al ; write 0 + ; now reset should be done.. + add dl, 4 ; offset 0Ah + +Next: add dl, 4 ; offset 0Eh + +Wait_s: in al, dx + or al, al + jns Wait_s + + sub dl, 4 ; offset 0Ah + in al, dx ; read if reset terminated + + cmp al, RESET_TEST_CODE ; should be... + jne Next + +ifdef SB16 + sub dl, 6 ; offset 04h + mov al, 80h + out dx, al + inc dx ; offset 05h + xor eax, eax + in al, dx + and al, 0Fh ; mask reserved bit + bsf ax, ax + mov al, byte ptr[SB16_IRQ+eax] + mov dword ptr[IRQ_number], eax + dec dx ; offset 04h + mov al, 81h + out dx, al + inc dx ; offset 05h + in al, dx + and al, 11101011b ; mask reserved bit + ifdef SAMPLE16BIT + bsr ax, ax + else + bsf ax, ax + endif + mov dword ptr[DMA_number], eax + + add dl, 7 ; offset 0Ch + WRITE_DSP DSP_RATE_CMD ; rate + mov cx, word ptr[PlayRate] + WRITE_DSP ch ; + WRITE_DSP cl ; +else + add dl, 02h ; offset 0Ch + WRITE_DSP DSP_ONSPK_CMD ; Turn speaker on + + ifdef SBPRO + + mov edx, offset InitIRQ ; Temporary IRQ handler + call InstallISR + + mov dx, word ptr[BASE_ADDR] + + add dl, 4 ; offset 4 + mov al, 0Eh ; stereo switch & filter + out dx, al + inc dx ; offset 5 + in al, dx + or al, 2 ; enable stereo + out dx, al + + mov ecx, dword ptr[DMA] ; Point to DMAx + + mov dx, word ptr[ecx + MASK_REG] + mov al, byte ptr[ecx + MASK2] ; mask channel + out dx, al + + mov dx, word ptr[ecx + FF_REG] + out dx, al ; flip-flop + + + mov dx, word ptr[ecx + COUNT_REG] + xor al, al + out dx, al + out dx, al + + mov eax, dword ptr[BUFFER_DMA] ; start offset + mov byte ptr[eax], 80h ; write a "0" into the buffer + + mov dx, word ptr[ecx + ADDX_REG] + out dx, al + shr eax, 8 + out dx, al + + mov dx, word ptr[ecx + PAGE_REG] + shr eax, 8 ; page of DMA transfert + out dx, al + + mov dx, word ptr[ecx + MODE_REG] + mov al, byte ptr[ecx + VOICE_OUT] ; output sample + out dx, al + + mov dx, word ptr[ecx + MASK_REG] + mov al, byte ptr[ecx + MASK1] ; channel OK + out dx, al + + mov dx, word ptr[BASE_ADDR] + add dl, 0Ch ; offset 0Ch + + mov byte ptr[OkIRQ], 0 + + WRITE_DSP DSP_VO8S_CMD + WRITE_DSP 0 + WRITE_DSP 0 + +WaitIRQ: cmp byte ptr[OkIRQ], 1 + jne short WaitIRQ + + sub dl, 8 ; offset 4 + mov al, 0Eh ; stereo switch & filter + out dx, al + inc dx ; offset 5 + in al, dx + mov byte ptr[Filter], al + or al, 20h ; disable filter + out dx, al + add dl, 7 ; offset 0Ch + endif + + pop ecx + + WRITE_DSP DSP_TIME_CMD ; "rate" + WRITE_DSP cl ; magic number ! + +endif + ret + +ResetCard ENDP + +;*--------------------------------------------------------------------------* + +CloseCard PROC + + mov dx, word ptr[BASE_ADDR] ; point to DSP + +ifdef SB16 + add dl, 0CH +ifdef SAMPLE16BIT + WRITE_DSP DSP_VO16S_CMD ; single-cycle 16 bit DMA + ifdef STEREO + WRITE_DSP DSP_16STEREO_MODE ; 16 bit stereo + else + WRITE_DSP DSP_16MONO_MODE ; 16 bit mono + endif +else + WRITE_DSP DSP_VO8S_4_CMD ; single-cycle 8 bit DMA + ifdef STEREO + WRITE_DSP DSP_8STEREO_MODE ; 8 bit stereo + else + WRITE_DSP DSP_8MONO_MODE ; 8 bit mono + endif +endif + WRITE_DSP 0 ; length of 1 to finish + WRITE_DSP 0 +else + ifdef SBPRO + add dl, 6 ; reset port (offset 6) + mov al, 1 ; write 1 + out dx, al + + mov ah, 8 * 3 ; 4 * "in al, dx" = 1 microsec on std ISA bus (8 Mhz) +wait_io: in al, dx ; so 8 to be sure if 16 MHz ! + dec ah ; kill the cat ! + jnz wait_io + + xor al, al + out dx, al ; write 0 + ; now reset should be done.. + add dl, 4 ; offset 0Ah + +Next: add dl, 4 ; offset 0Eh + +Wait_s: in al, dx + or al, al + jns Wait_s + + sub dl, 4 ; offset 0Ah + in al, dx ; read if reset terminated + + cmp al, RESET_TEST_CODE ; should be... + jne Next + + sub dl, 6 ; offset 4 + mov al, 0Eh + out dx, al + inc dx ; offset 5 + mov al, byte ptr[Filter] ; restore filter + out dx, al + + dec dx + mov al, 0Eh + out dx, al + inc dx ; offset 5 + in al, dx + and al, 11111101b ; turn off stereo + out dx, al + + add dl, 7 ; offset 0Ch + WRITE_DSP DSP_OFFSPK_CMD ; Turn speaker off + + else + + add dl, 0CH + WRITE_DSP DSP_OFFSPK_CMD ; Turn speaker off + WRITE_DSP DSP_VO8S_CMD ; single-cycle 8 bit DMA + WRITE_DSP 0 ; length of 1 to finish + WRITE_DSP 0 + + endif +endif + + ret + +CloseCard ENDP + +;---------------------------------------------------------------------------- + +AckIrq PROC + + mov dx, word ptr[BASE_ADDR] ; DSP IRQ ACK +ifdef SB16 + add dl, 4 ; offset 4 + mov al, 82h + out dx, al + inc dx ; offset 5 + in al, dx + ifdef SAMPLE16BIT + and al, 2 + jz NoDMAIRQ + add dl, 10 ; offset Fh + else + and al, 1 + jz NoDMAIRQ + add dl, 9 ; offset Eh + endif + in al, dx + ret +NoDMAIRQ: + stc + ret +else + add dl, 0Eh ; 8 bit Samples ACK + in al, dx + ret +endif + +AckIrq ENDP + +;---------------------------------------------------------------------------- + +StartDMACard PROC + + mov dx, word ptr[BASE_ADDR] ; DSP + add dl, 0Ch + +ifdef STEREO + mov cx, BUFFER_SIZE * 2 - 1 ; half-buffer size - 1 for DMA +else + mov cx, BUFFER_SIZE - 1 ; half-buffer size - 1 for DMA +endif + +ifdef SB16 + + +ifdef SAMPLE16BIT + WRITE_DSP DSP_VO16_CMD ; auto-init 16 bit DMA + ifdef STEREO + WRITE_DSP DSP_16STEREO_MODE ; 16 bit stereo + else + WRITE_DSP DSP_16MONO_MODE ; 16 bit mono + endif +else + WRITE_DSP DSP_VO8_4_CMD ; auto-init 8 bit DMA + ifdef STEREO + WRITE_DSP DSP_8STEREO_MODE ; 8 bit stereo + else + WRITE_DSP DSP_8MONO_MODE ; 8 bit mono + endif +endif + WRITE_DSP cl + WRITE_DSP ch + +elseifdef SBLASTER1 + + WRITE_DSP DSP_VO8S_CMD ; single-cycle 8 bit DMA + WRITE_DSP cl + WRITE_DSP ch + +else + + WRITE_DSP DSP_BSIZE_CMD ; Set block size + WRITE_DSP cl + WRITE_DSP ch + + ifdef SBPRO + WRITE_DSP DSP_VO8H_CMD ; auto-init 8 bit high-speed DMA + else + WRITE_DSP DSP_VO8_CMD ; auto-init 8 bit DMA + endif +endif + ret + +StartDMACard ENDP + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef GOLD + +SELECT_MIXER MACRO + local wait + + mov al, 0FFh + out dx, al + out dx, al +wait: in al, dx + and al, 11000000b + jnz wait + + ENDM + +LEAVE_MIXER MACRO + local wait + +wait: in al, dx + and al, 11000000b + jnz wait + mov al, 0FEh + out dx, al + out dx, al + + ENDM + +WRITE_MIXER MACRO PORT, VAL + local wait1, wait2 + + mov al, PORT + out dx, al +wait1: in al, dx + and al, 11000000b + jnz wait1 + inc dx + mov al, VAL + out dx, al + dec dx +wait2: in al, dx + and al, 11000000b + jnz wait2 + + ENDM + +READ_MIXER MACRO PORT + local wait1, wait2 + + mov al, PORT + out dx, al +wait1: in al, dx + and al, 11000000b + jnz wait1 + inc dx + in al, dx + dec dx + mov ah, al +wait2: in al, dx + and al, 11000000b + jnz wait2 + mov al, ah + + ENDM + +WRITE_MMA0 MACRO PORT, VAL + + mov al, PORT + out dx, al + inc dx + mov al, VAL + out dx, al + dec dx + in al, dx + in al, dx + + ENDM + +READ_MMA0 MACRO PORT + + mov al, PORT + out dx, al + inc dx + in al, dx + dec dx + mov ah, al + in al, dx + in al, dx + mov al, ah + + ENDM + +WRITE_MMA1 MACRO PORT, VAL + + mov al, PORT + out dx, al + add dx, 3 + mov al, VAL + out dx, al + sub dx, 3 + in al, dx + in al, dx + + ENDM + +READ_MMA1 MACRO PORT + + mov al, PORT + out dx, al + add dx, 3 + in al, dx + sub dx, 3 + mov ah, al + in al, dx + in al, dx + mov al, ah + + ENDM + + +;*--------------------------------------------------------------------------* + +ResetCard PROC + + mov dx, word ptr[BASE_ADDR] + add dx, 2 ; MIXER + + SELECT_MIXER + + WRITE_MIXER 8h, 11001110b ; STEREO mode + WRITE_MIXER 11h, 00001000b ; filter on output, no mic input, no PC-speaker input + + READ_MIXER 13h + + mov byte ptr[Mixer_13], al + + mov cl, al + + and eax, 3 + lea ebx, Gold_IRQ + mov al, byte ptr[ebx+eax] + mov dword ptr[IRQ_number], eax + + mov al, cl + shr al, 4 + and al, 3 + mov dword ptr[DMA_number], eax + + or cl, 10001000b ; enable DMA0, enable IRQ + WRITE_MIXER 13h, cl + + READ_MIXER 14h + + mov byte ptr[Mixer_14], al + + mov cl, al + and cl, 01111111b + WRITE_MIXER 14h, cl + + LEAVE_MIXER + + add dx, 2 ; MMA + + WRITE_MMA0 9, 80h ; reset channel 0 + WRITE_MMA1 9, 80h ; reset channel 1 + + mov cx, 4 +fillFIFO0: WRITE_MMA0 0Bh, 0 + dec cx + jnz FillFIFO0 + + mov cx, 4 +fillFIFO1: WRITE_MMA1 0Bh, 0 + dec cx + jnz FillFIFO1 + + WRITE_MMA0 9, 00101110b ; 22.05 Khz, PCM, L, Play + WRITE_MMA1 9, 01001110b ; 22.05 Khz, PCM, R, Play + + mov word ptr[PlayRate], 22050 ; 22.05 Khz + + WRITE_MMA0 0Ch, 11000101b ; Interleave, 16 bit, 96 byte FIFO, DMA + WRITE_MMA1 0Ch, 01000011b ; 16 bit, no FIFO (use other channel), DMA + + + WRITE_MMA0 0Ah, 0FFh ; Maximum volume (volume will be controlled by mixer) + WRITE_MMA1 0Ah, 0FFh + + mov cx, 100 +fillFIFO: WRITE_MMA0 0Bh, 0 + dec cx + jnz FillFIFO + + ret + +ResetCard ENDP + +;*--------------------------------------------------------------------------* + +CloseCard PROC + + mov dx, word ptr[BASE_ADDR] + add dx, 4 ; MMA + + WRITE_MMA1 0Ch, 01000010b ; 16 bit, no FIFO, no DMA + WRITE_MMA0 0Ch, 01000010b ; 16 bit, no FIFO, no DMA + + WRITE_MMA0 9, 80h ; reset channel 0 + WRITE_MMA1 9, 80h ; reset channel 1 + + sub dx, 2 ; MIXER + + SELECT_MIXER + + WRITE_MIXER 13h, Mixer_13 + WRITE_MIXER 14h, Mixer_14 + + LEAVE_MIXER + + ret + +CloseCard ENDP + +;---------------------------------------------------------------------------- + +AckIrq PROC + + mov dx, word ptr[BASE_ADDR] + add dx, 4 ; MMA + + in al, dx + and al, 1 + jz short noDMA + + mov ebx, dword ptr[DMA] ; Point to DMAx + + mov dx, word ptr[ebx + FF_REG] + out dx, al ; flip-flop + + mov dx, word ptr[ebx + COUNT_REG] + in al, dx + mov ah, al + in al, dx + xchg al, ah + + or ax, ax + jz short OkDMA + inc ax + jnz short noDMA +OkDMA: + clc + ret +NoDMA: + stc + ret + +AckIrq ENDP + +;---------------------------------------------------------------------------- + +StartDMACard PROC + + mov dx, word ptr[BASE_ADDR] + add dx, 4 ; MMA + + WRITE_MMA0 9, 00101111b ; 22.05 Khz, PCM, L, Play, GO + + ret + +StartDMACard ENDP + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef GUS + +extrn Nolanguage resetcard:PROC + +;*--------------------------------------------------------------------------* + +extrn Nolanguage CloseCard:PROC + +;*--------------------------------------------------------------------------* + +extrn Nolanguage StartDMACard:PROC + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + + END diff --git a/LIB386/LIB_SAMP/PATCH.INC b/LIB386/LIB_SAMP/PATCH.INC new file mode 100644 index 0000000..a870dc1 --- /dev/null +++ b/LIB386/LIB_SAMP/PATCH.INC @@ -0,0 +1,141 @@ +ENVELOPES equ 6 + +HEADER_SIZE equ 12 +ID_SIZE equ 10 +DESC_SIZE equ 60 +RESERVED_SIZE equ 40 +PATCH_HEADER_RESERVED_SIZE equ 36 +LAYER_RESERVED_SIZE equ 40 +PATCH_DATA_RESERVED_SIZE equ 36 + + +PatchHeader STRUC + +;PatchHeader + +header db HEADER_SIZE dup (?) +gravis_id db ID_SIZE dup (?) +description db DESC_SIZE dup (?) +instruments db ? +voices db ? +channels db ? +wave_forms dw ? +master_volume dw ? +data_size dd ? +reserved_h db PATCH_HEADER_RESERVED_SIZE dup (?) + +;InstrumentData + +instrument dw ? +instrument_name db 16 dup (?) +instrument_size dd ? +layers db ? +reserved_i db RESERVED_SIZE dup (?) + +;LayerData + +layer_duplicate db ? +layer db ? +layer_size dd ? +samples db ? +reserved_l db LAYER_RESERVED_SIZE dup (?) + +PatchHeader ENDS + + +PatchData STRUC + +wave_name db 7 dup (?) +fractions db ? +wave_size dd ? +start_loop dd ? +end_loop dd ? +sample_rate dw ? +low_frequency dd ? +high_frequency dd ? +root_frequency dd ? +tune dw ? +balance db ? +envelope_rate db ENVELOPES dup (?) +envelope_offset db ENVELOPES dup (?) +tremolo_sweep db ? +tremolo_rate db ? +tremolo_depth db ? +vibrato_sweep db ? +vibrato_rate db ? +vibrato_depth db ? +modes db ? +scale_frequency dw ? +scale_factor dw ? +reserved_w db PATCH_DATA_RESERVED_SIZE dup (?) + +PatchData ENDS + + +CommonData STRUC + +Control db ? +NumbSamples db ? +DataOffset dw ? + +CommonData ENDS + + +;SampleData STRUC +; +;_wave_start dd ? +;_wave_end dd ? +;_start_loop dd ? +;_end_loop dd ? +;_sample_rate dw ? +;_low_frequency dd ? +;_high_frequency dd ? +;_root_frequency dd ? +;_balance db ? +;_envelope_rate db ENVELOPES dup (?) +;_envelope_offset db ENVELOPES dup (?) +;_tremolo_sweep db ? +;_tremolo_rate db ? +;_tremolo_depth db ? +;_vibrato_sweep db ? +;_vibrato_rate db ? +;_vibrato_depth db ? +;_modes db ? +;_scale_frequency dw ? +;_scale_factor dw ? +; +;SampleData ENDS + +wave_struct STRUC + _start_loop dd ? + _end_loop dd ? + _low_frequency dd ? + _high_frequency dd ? + _root_frequency dd ? + _mem dd ? + _scale_frequency dw ? + _sample_rate dw ? + _scale_factor dw ? + _start_acc_low dw ? + _start_acc_high dw ? + _start_low dw ? + _start_high dw ? + _end_low dw ? + _end_high dw ? + _end_acc_low dw ? + _end_acc_high dw ? + _sample_ratio dw ? + _wave_size dd ? + _fractions db ? + _balance db ? + _envelope_rate db ENVELOPES dup (?) + _envelope_offset db ENVELOPES dup (?) + _tremolo_sweep db ? + _tremolo_rate db ? + _tremolo_depth db ? + _vibrato_sweep db ? + _vibrato_rate db ? + _vibrato_depth db ? + _modes db ? +wave_struct ENDS + diff --git a/LIB386/LIB_SAMP/README.md b/LIB386/LIB_SAMP/README.md new file mode 100644 index 0000000..2055973 --- /dev/null +++ b/LIB386/LIB_SAMP/README.md @@ -0,0 +1,30 @@ +# LIB_SAMP + +In order to build LIB_SAMP, following third party SDK is required: + - Miles Sound System AIL32 v1.0 + - Gravis Ultra Sound SDK v2.1 (gussdk21) + +AIL32 v1.0 is licensed under "Copyright (C) 1991, 1992 Miles Design, Inc." +terms and is not delivered in this package. + +Gravis Ultra Sound SDK is licensed under +"Copyright (C): 1993,1994 by Advanced Gravis Computer Technology" terms and is +not delivered in this package. It's included in the AIL32 SDK. + +Following files from AIL32 SDK are expected to be in LIB_SAMP folder: + +``` ++---LIB_SAMP +| 386.MAC +| AIL32.INC +| AIL32PAT.EXE +| GF1NEW.INC +| GF1PROTO.INC +| GF1_OSPM.LIB +| GUS.BAT +| GUS.MAK +| GUSDIG32.ASM +| GUSMID32.INC +| PMINIT.ASM +| PMINIT.INC +``` \ No newline at end of file diff --git a/LIB386/LIB_SAMP/REAL.ASM b/LIB386/LIB_SAMP/REAL.ASM new file mode 100644 index 0000000..f7922bb --- /dev/null +++ b/LIB386/LIB_SAMP/REAL.ASM @@ -0,0 +1,26 @@ + + .386 + +;----------------------------------------------------------------------------- +_TEXT16 SEGMENT BYTE PUBLIC USE16 'CODE' + + ASSUME CS:_TEXT16 + ASSUME DS:_TEXT16 + + PUBLIC RealInt + +;----------------------------------------------------------------------------- + +RealInt: + db 0EAh, 78h, 56h, 34h, 12h ; jmp far 1234h:5678h + + +;----------------------------------------------------------------------------- +_TEXT16 ENDS +;----------------------------------------------------------------------------- +; +; The + End + + + diff --git a/LIB386/LIB_SAMP/TEST.C b/LIB386/LIB_SAMP/TEST.C new file mode 100644 index 0000000..25e8ec7 --- /dev/null +++ b/LIB386/LIB_SAMP/TEST.C @@ -0,0 +1,10 @@ +//#include + +void InitWave() +{ + int i; + void *bad_handle[10]; + + for(i=0; i<10; i++) + bad_handle[i]=NULL; +} diff --git a/LIB386/LIB_SAMP/VOL.INC b/LIB386/LIB_SAMP/VOL.INC new file mode 100644 index 0000000..f2effdc --- /dev/null +++ b/LIB386/LIB_SAMP/VOL.INC @@ -0,0 +1,26 @@ +gf1_volumes dw 00000h, 009ffh, 00a80h, 00affh + dw 00b40h, 00b80h, 00bc0h, 00bffh, 00c20h + dw 00c40h, 00c60h, 00c80h, 00ca0h, 00cc0h + dw 00ce0h, 00cffh, 00d10h, 00d20h, 00d30h + dw 00d40h, 00d50h, 00d60h, 00d70h, 00d80h + dw 00d90h, 00da0h, 00db0h, 00dc0h, 00dd0h + dw 00de0h, 00df0h, 00dffh, 00e08h, 00e10h + dw 00e18h, 00e20h, 00e28h, 00e30h, 00e38h + dw 00e40h, 00e48h, 00e50h, 00e58h, 00e60h + dw 00e68h, 00e70h, 00e78h, 00e80h, 00e88h + dw 00e90h, 00e98h, 00ea0h, 00ea8h, 00eb0h + dw 00eb8h, 00ec0h, 00ec8h, 00ed0h, 00ed8h + dw 00ee0h, 00ee8h, 00ef0h, 00ef8h, 00effh + dw 00f04h, 00f08h, 00f0ch, 00f10h, 00f14h + dw 00f18h, 00f1ch, 00f20h, 00f24h, 00f28h + dw 00f2ch, 00f30h, 00f34h, 00f38h, 00f3ch + dw 00f40h, 00f44h, 00f48h, 00f4ch, 00f50h + dw 00f54h, 00f58h, 00f5ch, 00f60h, 00f64h + dw 00f68h, 00f6ch, 00f70h, 00f74h, 00f78h + dw 00f7ch, 00f80h, 00f84h, 00f88h, 00f8ch + dw 00f90h, 00f94h, 00f98h, 00f9ch, 00fa0h + dw 00fa4h, 00fa8h, 00fach, 00fb0h, 00fb4h + dw 00fb8h, 00fbch, 00fc0h, 00fc4h, 00fc8h + dw 00fcch, 00fd0h, 00fd4h, 00fd8h, 00fdch + dw 00fe0h, 00fe4h, 00fe8h, 00fech, 00ff0h + dw 00ff4h, 00ff8h, 00ffch, 00fffh diff --git a/LIB386/LIB_SAMP/WAVE.C b/LIB386/LIB_SAMP/WAVE.C new file mode 100644 index 0000000..62451f3 --- /dev/null +++ b/LIB386/LIB_SAMP/WAVE.C @@ -0,0 +1,123 @@ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + SAMP.C 386 + (c) Adeline 1993 + *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_samp\lib_wave.h" +#include +#include +#include +#include + +char *WaveError = "Error WaveDriver:"; + +extern void *Wave_listfcts; + +extern LONG Wave_Driver_Enable; + +ULONG _InitCard( void *Buffer ); +void _ClearCard( void ); +ULONG _GetBufferSize( void ); + + void *BUFFER_DMA; + void *END_BUFFER_DMA; + +/*-------------------------------------------------------------------------*/ +LONG WaveInitDLL(char *driverpathname) +{ + char *dll, *drvr; + + // + // Load driver file + // + + dll = FILE_read( driverpathname, NULL); + if (dll==NULL) + { + printf("%s Could not load driver '%s'.\n", WaveError, driverpathname ); + return FALSE ; + } + + drvr=DLL_load(dll,DLLMEM_ALLOC | DLLSRC_MEM,NULL); + if (drvr==NULL) + { + printf("%s Invalid DLL image.\n", WaveError ); + return FALSE ; + } + + Free(dll); + + Wave_listfcts = *(void **)drvr; + printf("%s", drvr+4); + + return (Wave_Driver_Enable = TRUE); +} + +/*-------------------------------------------------------------------------*/ +ULONG InitWave() +{ + union REGS r; + struct SREGS sr; + void far *fh; + int i; + int IRQ_number; + int kilo_buffer; + ULONG bad_handle[10]; + + kilo_buffer = _GetBufferSize(); + +/*- Reserve some space for a sound buffer that doesn't cross a 64K page -*/ + +// for(i=0; i<10; i++) +// bad_handle[i]=NULL; + i = 0; + do + { + if (!(BUFFER_DMA = DosMalloc( kilo_buffer, &bad_handle[i] ))) + { + BUFFER_DMA = NULL; + i+=2; + break; + } + END_BUFFER_DMA = (void *)((ULONG)BUFFER_DMA + kilo_buffer - 1); + if (((LONG)BUFFER_DMA & 0xFFFF0000) != ((LONG)END_BUFFER_DMA & 0xFFFF0000)) + { + BUFFER_DMA = NULL; + } + i++; + } while ((BUFFER_DMA == NULL) && (i<=10)); + +// for(i-=2; i>=0; i--) +// DosFree( bad_handle[i] ); + + if (BUFFER_DMA == NULL) + { + printf("%s Couldn't allocate a contiguous buffer in DOS memory.\n", WaveError); + return 0; + } + +/*----- Init Sound Card (and IRQ controller) ---*/ + Wave_Driver_Enable = _InitCard(BUFFER_DMA); + + if (!Wave_Driver_Enable) + { + printf("%s Sound card not found.\n", WaveError); + } + + return Wave_Driver_Enable; +} + +void ClearWave() +{ + union REGS r; + struct SREGS sr; + + if (!Wave_Driver_Enable) + return; + +/*----- Reset Sound Card (and IRQ controller) ---*/ + _ClearCard(); +} +/*-------------------------------------------------------------------------*/ diff --git a/LIB386/LIB_SAMP/WAVE.INC b/LIB386/LIB_SAMP/WAVE.INC new file mode 100644 index 0000000..8a304c8 --- /dev/null +++ b/LIB386/LIB_SAMP/WAVE.INC @@ -0,0 +1,114 @@ +;*--------------------------------------------------------------------------* + +;DEBUG equ 1 + +VOICE_HANDLE equ 1234h + +IFDEF SB16 + + SBLASTER equ 1 ; it is also a SBLASTER ! + +ENDIF + +IFDEF SBPRO + + SBLASTER equ 1 ; it is also a SBLASTER ! + STEREO equ 1 + +ENDIF + +IFDEF SBLASTER1 + + SBLASTER equ 1 ; it is also a SBLASTER ! + SINGLE_DMA equ 1 ; use DMA (no auto-reinit on the SB ver 1.00-1.99) + +ELSEIFDEF SBLASTER + + AUTO_DMA equ 1 ; use auto_reinit DMA (faster and cleaner) + +ENDIF + +IFDEF MWSS + + SAMPLE16BIT equ 1 + STEREO equ 1 + AUTO_DMA equ 1 ; use auto_reinit DMA (faster and cleaner) + +ENDIF + +IFDEF GOLD + + SAMPLE16BIT equ 1 + STEREO equ 1 + SINGLE_DMA equ 1 ; use DMA (no counter on the card) + +ENDIF + +IFDEF GUS + + AUTO_DMA equ 1 ; use auto_reinit DMA (faster and cleaner) + SAMPLE16BIT equ 1 + STEREO equ 1 + NOIRQ equ 1 + +ENDIF + +IFDEF PAS16 + + PAS equ 1 + SAMPLE16BIT equ 1 + +ENDIF + +IFDEF PAS + + STEREO equ 1 + AUTO_DMA equ 1 ; use auto_reinit DMA (faster and cleaner) + + BI_OUTPUTMIXER equ 00h ; PAS equates + BI_L_PCM equ 06h + BI_R_PCM equ 0dh + INTRCTLRST equ 0b89h + AUDIOFILT equ 0b8ah + INTRCTLR equ 0b8bh + PCMDATA equ 0f88h + CROSSCHANNEL equ 0f8ah + TMRCTLR equ 138bh + SAMPLERATE equ 1388h + SAMPLECNT equ 1389h + SYSCONF equ 8389h + +ENDIF + +;*--------------------------------------------------------------------------* + +IFDEF SAMPLE16BIT + IFDEF STEREO + SLONG equ 1 + SSIZE equ 4 + ELSE + SUWORD equ 1 + SSIZE equ 2 + ENDIF +ELSE + IFDEF STEREO + SUWORD equ 1 + SSIZE equ 2 + ELSE + SCHAR equ 1 + SSIZE equ 1 + ENDIF +ENDIF + +;*--------------------------------------------------------------------------* + +BUFFER_SIZE equ 1024 ; number of samples + ; in half-buffer +LIST_SIZE equ 50 +STRUCT_SIZE equ 44 +SNAP_SIZE equ 8 + +SHIFT_SAMPLE equ 3 ; max number of + ; samples mixed + +;*--------------------------------------------------------------------------* diff --git a/LIB386/LIB_SAMP/WAVE_A.ASM b/LIB386/LIB_SAMP/WAVE_A.ASM new file mode 100644 index 0000000..5e9ed27 --- /dev/null +++ b/LIB386/LIB_SAMP/WAVE_A.ASM @@ -0,0 +1,3769 @@ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; SAMP_A.ASM 386 +; (c) Adeline 1993 +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*--------------------------------------------------------------------------* + +include wave.inc + +;*--------------------------------------------------------------------------* + +MIDPOINT MACRO + +IFDEF SAMPLE16BIT + xor eax, eax +ELSE + mov eax, 80808080h +ENDIF + + ENDM + +;*--------------------------------------------------------------------------* + + .386 + jumps + + .model FLAT, SYSCALL + + .CODE + + +;*--------------------------------------------------------------------------* + + PUBLIC driver_start + +driver_start dd OFFSET ListFuncs + +IFDEF SB16 + db 'Sound Blaster 16 (DSP 4.XX)' + +ELSEIFDEF SBPRO + db 'Sound Blaster Pro (DSP 3.XX)' + +ELSEIFDEF SBLASTER1 + db 'Sound Blaster 2 (DSP 2.01+)' + +ELSEIFDEF SBLASTER + db 'Sound Blaster (DSP 1.00-2.00)' + +ELSEIFDEF MWSS + db 'Microsoft Windows Sound System (AD1848 SoundPort)' + +ELSEIFDEF GOLD + db 'Adlib Gold (Yamaha GOLD)' + +ELSEIFDEF GUS + db 'Advanced Gravis UltraSound' + +ELSEIFDEF PAS16 + db 'Media Vision Pro Audio Spectrum 16' + +ELSEIFDEF PAS + db 'Media Vision Pro Audio Spectrum/Spectrum Plus' +ENDIF + + db ' Wave Driver,', 13, 10 + +IFDEF SAMPLE16BIT + db '16 bit' +ELSE + db '8 bit' +ENDIF +IFDEF STEREO + db ' Stereo' +ELSE + db ' Mono' +ENDIF +IFDEF SURROUND + db ' Surround' +ENDIF + + db ' playback, Version 1.00.', 13, 10 +IFDEF GUS + db 'Copyright (C) 1991,1992 Miles Design, Inc.', 0Dh, 0Ah + db 'Copyright (C) 1993,1994 Advanced Gravis Computer ' + db 'Technology Ltd. All rights reserved.', 0Dh, 0Ah + db 'Copyright (C) 1992,1993,1994 Forte Technologies.', 0Dh, 0Ah + db 'Copyright (C) 1994 Adeline Software International.', 0Dh, 0Ah + db 'All rights reserved.', 0Dh, 0Ah + db 'UltraSound conversion by Jayeson Lee-Steere.', 0Dh, 0Ah + db 'Adeline Software conversion by Serge Plagnol.', 0Dh, 0Ah + db 'MIDI and Digital sound library by Forte.', 0Dh, 0Ah, 0Ah, 0 +ELSE + db 'Copyright (c) Adeline Software International 1994, All Rights Reserved.', 13, 10, 10, 0 +ENDIF + +ListFuncs dd offset InitCard + dd offset ClearCard + + dd offset AskVars + + dd offset MixSample + dd offset GiveSampleInfo0 + + dd offset StopSample + dd offset StopOneSample + + dd offset SampleInList + dd offset GetSnapSample + + dd offset PauseSample + dd offset ContinueSample + + dd offset SaveStateSample + dd offset RestoreStateSample + + dd offset GetDMAAddr + + dd offset GetBufferSize + + dd offset ChangeVolume + + dd offset ShiftSamples + + dd offset StopOneSampleLong + +;*--------------------------------------------------------------------------* + +ADDRESS equ 0 +FRACT equ 4 +LEFT equ 8 +C_REPEAT equ 12 +INCR equ 14 +SON equ 16 +HANDLE equ 20 +START equ 24 +DLENGTH equ 28 +VOL_LEFT equ 32 +VOL_RIGHT equ 34 +INFO0 equ 36 +INTERPOL equ 40 +LAST_SAMPLE equ 41 + +;*--------------------------------------------------------------------------* + +DSP_VO8S_CMD equ 14h +DSP_VO8_CMD equ 1Ch +DSP_TIME_CMD equ 40h +DSP_RATE_CMD equ 41h +DSP_BSIZE_CMD equ 48h +DSP_VO8H_CMD equ 90h +DSP_VO16S_CMD equ 0B0h +DSP_VO16_CMD equ 0B6h +DSP_VO8S_4_CMD equ 0C0h +DSP_VO8_4_CMD equ 0C6h +DSP_ONSPK_CMD equ 0D1h +DSP_OFFSPK_CMD equ 0D3h + +DSP_16MONO_MODE equ 10h +DSP_16STEREO_MODE equ 30h +DSP_8MONO_MODE equ 00h +DSP_8STEREO_MODE equ 20h + +RESET_TEST_CODE equ 0AAh + + +;*--------------------------------------------------------------------------* + +ifndef NOIRQ + +VOICE_OUT equ 0 ; equ to access the 2 arrays below +AUTO_OUT equ 1 +MASK1 equ 2 +MASK2 equ 3 + +ADDX_REG equ 4 +COUNT_REG equ 6 +MASK_REG equ 8 +MODE_REG equ 10 +FF_REG equ 12 +PAGE_REG equ 14 + + +DMA0 equ $ ; Ports for DMA0 + +DMA0_VOICE_OUT db 48H +DMA0_AUTO_OUT db 58H +DMA0_MASK1 db 00H +DMA0_MASK2 db 04H + +DMA0_ADDX_REG dw 00H +DMA0_COUNT_REG dw 01H +DMA0_MASK_REG dw 0AH +DMA0_MODE_REG dw 0BH +DMA0_FF_REG dw 0CH +DMA0_PAGE_REG dw 87H + + +DMA1 equ $ ; Ports for DMA1 + +DMA1_VOICE_OUT db 49H +DMA1_AUTO_OUT db 59H +DMA1_MASK1 db 01H +DMA1_MASK2 db 05H + +DMA1_ADDX_REG dw 02H +DMA1_COUNT_REG dw 03H +DMA1_MASK_REG dw 0AH +DMA1_MODE_REG dw 0BH +DMA1_FF_REG dw 0CH +DMA1_PAGE_REG dw 83H + + +DMA3 equ $ ; Ports for DMA3 + +DMA3_VOICE_OUT db 4BH +DMA3_AUTO_OUT db 5BH +DMA3_MASK1 db 03H +DMA3_MASK2 db 07H + +DMA3_ADDX_REG dw 06H +DMA3_COUNT_REG dw 07H +DMA3_MASK_REG dw 0AH +DMA3_MODE_REG dw 0BH +DMA3_FF_REG dw 0CH +DMA3_PAGE_REG dw 82H + + +DMA5 equ $ ; Ports for DMA5 + +DMA5_VOICE_OUT db 49H +DMA5_AUTO_OUT db 59H +DMA5_MASK1 db 01H +DMA5_MASK2 db 05H + +DMA5_ADDX_REG dw 0C4H +DMA5_COUNT_REG dw 0C6H +DMA5_MASK_REG dw 0D4H +DMA5_MODE_REG dw 0D6H +DMA5_FF_REG dw 0D8H +DMA5_PAGE_REG dw 08BH + +DMA6 equ $ ; Ports for DMA6 + +DMA6_VOICE_OUT db 4AH +DMA6_AUTO_OUT db 5AH +DMA6_MASK1 db 02H +DMA6_MASK2 db 06H + +DMA6_ADDX_REG dw 0C8H +DMA6_COUNT_REG dw 0CAH +DMA6_MASK_REG dw 0D4H +DMA6_MODE_REG dw 0D6H +DMA6_FF_REG dw 0D8H +DMA6_PAGE_REG dw 089H + +DMA7 equ $ ; Ports for DMA7 + +DMA7_VOICE_OUT db 4BH +DMA7_AUTO_OUT db 5BH +DMA7_MASK1 db 03H +DMA7_MASK2 db 07H + +DMA7_ADDX_REG dw 0CCH +DMA7_COUNT_REG dw 0CEH +DMA7_MASK_REG dw 0D4H +DMA7_MODE_REG dw 0D6H +DMA7_FF_REG dw 0D8H +DMA7_PAGE_REG dw 08AH + +ALIGN 4 + +TAB_DMA dd offset DMA0 + dd offset DMA1 + dd 0 + dd offset DMA3 + dd 0 + dd offset DMA5 + dd offset DMA6 + dd offset DMA7 + +endif + +;*--------------------------------------------------------------------------* + +CurrentList db STRUCT_SIZE*LIST_SIZE+4 dup (?) +SonList db STRUCT_SIZE*LIST_SIZE+4 dup (?) + +BackCurrentList db STRUCT_SIZE*LIST_SIZE+4 dup (?) +BackSonList db STRUCT_SIZE*LIST_SIZE+4 dup (?) + +SnapList db SNAP_SIZE*LIST_SIZE dup (?) + +IRQ_mask db ? + +FlagPause db 0 + +WaveBase db 'WaveBase',0 +WaveIRQ db 'WaveIRQ',0 +WaveDMA db 'WaveDMA',0 +WaveRate db 'WaveRate' +Empty db 0 + +ifdef SBPRO + + OkIRQ db 0 + Filter db ? + +endif + +ifdef GOLD + + Mixer_13 db ? + Mixer_14 db ? + Gold_IRQ db 3, 4, 5, 7, 10, 11, 12, 15 +endif + +ifdef SB16 + SB16_IRQ db 2, 5, 7, 10 +endif + +EVEN + +ifdef MWSS + +MWSSFreq dw 11025, 3, 16000, 2, 18900, 5, 22050, 7 + dw 27429, 4, 32000, 6, 33075, 0dh, 37800, 9 + dw 44100, 0Bh + +MWSSIrq db 0, 0, 010000b, 0, 0, 0, 0, 001000b, 0, 010000b + db 011000b, 100000b, 0, 0, 0, 0 + +MWSSDma db 01b, 10b, 0, 11b, 0, 0, 0, 0 + +endif + +Critical dw ? +DoUpdate dw ? + +Old_RIRQ_Seg dw ? +Old_PIRQ_Sel dw ? +Old_18_Sel dw ? +Old_RIRQ_Off dw ? + +ALIGN 4 + +Old_PIRQ_Off dd ? +Old_18_Off dd ? + +ifdef GOLD + + ListNames dd offset WaveBase + dd offset Empty + +elseifdef SB16 + + ListNames dd offset WaveBase + dd offset WaveRate + dd offset Empty + +elseifdef GUS + + ListNames dd offset WaveRate + dd offset Empty + +elseifdef PAS + + ListNames dd offset WaveRate + dd offset Empty + +else + + ListNames dd offset WaveBase + dd offset WaveRate + dd offset WaveIRQ + dd offset WaveDMA + dd offset Empty + +endif + +public Nolanguage PlayRate + +ListVars equ $ + +ifdef GOLD + + BASE_ADDR dd 388h ; By default 388h + PlayRate dd 22000 ; By default 22 Khz + IRQ_number dd ? ; no default (read card) + DMA_number dd ? ; no default (read card) + + +elseifdef SBLASTER + + BASE_ADDR dd 220h ; By default 220h + PlayRate dd 22000 ; By default 22 Khz + IRQ_number dd 5 ; By default 5 + DMA_number dd 1 ; By default 1 + +elseifdef MWSS + + BASE_ADDR dd 540h ; By default 540h + PlayRate dd 22000 ; By default 22 Khz + IRQ_number dd 9 ; By default 9 + DMA_number dd 1 ; By default 1 + +elseifdef GUS + + PlayRate dd 22000 ; By default 22 Khz + +elseifdef PAS + + PlayRate dd 22000 ; By default 22 Khz + IRQ_number dd 0 ; no default + DMA_number dd 0 ; no default + +else + + BASE_ADDR dd 0 ; no default + PlayRate dd 22000 ; By default 22 Khz + IRQ_number dd 0 ; no default + DMA_number dd 0 ; no default + +endif + +INT_number dd 0Dh ; By default 0Dh + +public Nolanguage BufferHalf + +BufferHalf dd ? + +follow dd -1 + +backfollow dd -1 + +ifndef NOIRQ + +DMA dd offset DMA1 ; By default DMA1 + +endif + +weirdcount dd ? +backweirdcount dd ? + +TheVolumeR dd ? +TheVolumeL dd ? + +save_1 dd ? +save_2 dd ? +save_3 dd ? +save_4 dd ? + + +public Nolanguage BUFFER_DMA +public Nolanguage CURRENT_BUFFER + + +ifdef RAM_CARD + + BUFFER_DMA dd ? ; adress of the buffer + + R_BUFFER_CARD dd ? ; adress of the buffer on the card for Right channel + MID_R_BUFFER_CARD dd ? ; adress of the mid buffer for Right channel + + CURRENT_R_BUFFER_CARD dd ? ; current half for Right channel + + L_BUFFER_CARD dd ? ; adress of the buffer on the card for Left channel + MID_L_BUFFER_CARD dd ? ; adress of the mid buffer for Left channel + + CURRENT_L_BUFFER_CARD dd ? ; current half for Left channel +else + + BUFFER_DMA dd ? ; adress of the buffer + MID_BUFFER_DMA dd ? ; adress of the mid buffer + + CURRENT_BUFFER dd ? ; current half +endif + +ifdef INTERRRUPT + + DMA_COUNT dd ? + DMA_PTR dd ? + +endif + + +;---------------------------------------------------------------------------- + +IFDEF PAS + + MV_filter dd ? + MV_xchannel dd ? + + DPMI_real_int LABEL BYTE ;DPMI real-mode interrupt structure + + int_DI dw ? ;*** MUST REMAIN CONTIGUOUS *** + dw 0 + int_SI dw ? + dw 0 + int_BP dw ? + dw 0 + dd 0 + int_BX dw ? + dw 0 + int_DX dw ? + dw 0 + int_CX dw ? + dw 0 + int_AX dw ? + dw 0 + int_flags dw ? + int_ES dw ? + int_DS dw ? + dw 0 + dw 0 + dw 0 + dw 0 + dw 0 + dw 0 + +ENDIF + +;*--------------------------------------------------------------------------* + +Redirector PROC + + int 18h + iretd + +Redirector ENDP + +;*--------------------------------------------------------------------------* + +setalc MACRO + + db 0D6h + + ENDM + + +lve MACRO Reg, Exp + + lea Reg, [Exp] + + ENDM + + +;*--------------------------------------------------------------------------* + +GET_REAL_VECT MACRO + + mov ax, 0200h + int 31h + + ENDM + + +SET_REAL_VECT MACRO + + mov ax, 0201h + int 31h + + ENDM + +GET_PROT_VECT MACRO + + mov ax, 0204h + int 31h + + ENDM + + +SET_PROT_VECT MACRO + + mov ax, 0205h + int 31h + + ENDM + +CRIT_SECT MACRO ; Enter Critical Section ;-) + + mov word ptr[Critical], 1 ; tell the IRQ not to update the buffer + ; we'll take care of it if nescessary O:-) + ENDM + + +END_CRIT_SECT MACRO ; Exit Critical Section O:-) + local NoUpdate ; Update buffer if necessary + + ; Dealing with the critical section flags................ + ; DO NOT TOUCH !!!! + + mov word ptr[Critical], 0 ; exit crit. sect. + ; this way DoUpdate can't change to 1 anymore + cmp word ptr[DoUpdate], 0 ; IRQ happened ? + je NoUpdate ; if DopUpdate change to 0 now, we are in deep + ; shit anyway because we missed one round! + ; The program won't crash but we'll ear the old + ; content of half a buffer and also miss half a buffer + ; of new data... :-( + mov word ptr[Critical], 1 ; yes, crit. again, so we don't update twice + ; because UpdateBuffer is not reentrant + ; and we don't want to take a chance on crashing! + pushad ; if DoUpdate change to 1 HERE + ; it means again that we missed one round! + ; So we play the buffer we are updating! (funny noise :-( ) + ; and then will ear half buffer of old data! + call UpdateBuffer ; do the update + popad + mov word ptr[Critical], 0 ; exit crit. sect + ; this way DoUpdate can't change to 1 anymore + mov word ptr[DoUpdate], 0 ; Update done, so DoUpdate = 0 +NoUpDate: + + ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !!!! + ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE BUFFER + ; TAKES MORE THAN 46000 microsec! + ; (at 33 Mhz one cycle = .03 microsec so 4600 microsec = 1.5 million cycle) + ENDM + + +;*--------------------------------------------------------------------------* + +GetDMAAddr PROC USES EBX + + xor eax, eax + +ifndef NOIRQ + + mov ebx, dword ptr[DMA] + + cli + + mov dx, word ptr[ebx + PAGE_REG] + in al, dx + shl eax, 16 + + mov dx, word ptr[ebx + FF_REG] + out dx, al ; Flip-Flop + + mov dx, word ptr[ebx + ADDX_REG] ; to get offset + + in al, dx + mov ah, al + in al, dx + + sti + + xchg al, ah + + cmp word ptr[DMA_number], 3 + jbe noadjust + lve eax, eax*2 + +noadjust: +endif + ret + +GetDMAAddr ENDP + +;*--------------------------------------------------------------------------* + +ifndef NOIRQ + +NewIRQ PROC + + pushad + push ds + push es + cld ; DAMN IT !! :-o + +local_DS equ $+2 + mov ax, 1234h + mov ds, ax ; restore DS + mov es, ax ; and ES !!! + + call AckIrq + pushf + +ifdef SINGLE_DMA + jc notransfert + call BlockTransfert +; call Ackirq ; security +notransfert: +endif + mov al, 20h ; allows for new int + cmp byte ptr[IRQ_number], 7 + jbe short NoSecondCtrl + out 0A0h, al +NoSecondCtrl: out 20h, al + + popf + jc short FinIRQ ; not a DMA IRQ + + mov eax, dword ptr[BufferHalf] + xor al, 4 ; switch half + mov byte ptr[BufferHalf], al + +ifdef RAM_CARD + mov eax, dword ptr[R_BUFFER_CARD+eax]; get current card buffer address + mov dword ptr[CURRENT_R_BUFFER_CARD], eax; update CURRENT_BUFFER_CARD +else + mov eax, dword ptr[BUFFER_DMA+eax] ; get current buffer address + mov dword ptr[CURRENT_BUFFER], eax ; update CURRENT_BUFFER +endif + + mov word ptr[DoUpdate], 1 ; Time to do the update + + cmp word ptr[Critical], 0 ; crit. sect ? + jne FinIRQ ; yes, don't update yet! + + mov word ptr[Critical], 1 ; just to make jure it case the interrupt + call UpdateBuffer ; happen again before its finished + mov word ptr[Critical], 0 + + mov word ptr[DoUpdate], 0 ; Update done +FinIRQ: + pop es + pop ds + popad + + iretd + +NewIRQ ENDP + +endif + +;*--------------------------------------------------------------------------* + +ifdef GUS + PUBLIC Nolanguage UpdateBuffer + PUBLIC Nolanguage DoUpdate + PUBLIC Nolanguage Critical +endif + +;*--------------------------------------------------------------------------* + +UpdateBuffer PROC + +ifdef GUS + push es + pushf + + cld + mov ax, ds + mov es, ax +endif + + mov eax, BUFFER_SIZE +ifdef RAM_CARD + mov edi, dword ptr[BUFFER_DMA] ; Buffer +else + mov edi, dword ptr[CURRENT_BUFFER] ; Buffer +endif + cmp byte ptr[FlagPause], 1 + je short dopause + + lea ebx, CurrentList ; Point to List of samples + + mov esi, dword ptr[ebx] ; Current Source + or esi, esi ; if 0 then empty list + jnz process_1st +dopause: + mov ecx, (BUFFER_SIZE * SSIZE) / 4 + MIDPOINT + rep stosd + + mov al, byte ptr[FlagPause] + and al, 1 + mov byte ptr[FlagPause], al +ifdef GUS + popf + pop es +endif + ret +exit: + mov al, byte ptr[FlagPause] + dec al + js reallyexit + +ifdef RAM_CARD + mov edi, dword ptr[BUFFER_DMA] ; Buffer +else + mov edi, dword ptr[CURRENT_BUFFER] ; Buffer +endif + + mov esi, ( BUFFER_SIZE * SSIZE ) / 4 + bsr cx, si + + dec si ; no need to fade first/last sample + ; since it will be multiplied by 1 + dec al + jnz short fadeout + + mov ebx, 1 ; skip 0 + +ifdef SAMPLE16BIT + +loopfadein: mov edx, dword ptr[edi] + movsx eax, dx + imul eax, ebx + sar eax, cl + sar edx, 16 + imul edx, ebx + sar edx, cl + shl edx, 16 + mov dx, ax + mov dword ptr[edi], edx + add edi, 4 + inc bx + dec si + jnz short loopfadein + +else + +loopfadein: mov edx, dword ptr[edi] + xor edx, 80808080h ; convert to signed + REPT 2 + movsx eax, dl + imul eax, ebx + sar eax, cl + mov dl, al + movsx eax, dh + imul eax, ebx + sar eax, cl + mov dh, al + rol edx, 16 + ENDM + xor edx, 80808080h ; back to unsigned + mov dword ptr[edi], edx + add edi, 4 + inc bx + dec si + jnz short loopfadein + +endif + xor al, al + jmp short endfade + +fadeout: + add edi, 4 ; skip first + +ifdef SAMPLE16BIT + +loopfadeout: mov edx, dword ptr[edi] + movsx eax, dx + imul eax, esi + sar eax, cl + sar edx, 16 + imul edx, esi + sar edx, cl + shl edx, 16 + mov dx, ax + mov dword ptr[edi], edx + add edi, 4 + dec si + jnz short loopfadeout + +else + +loopfadeout: mov edx, dword ptr[edi] + xor edx, 80808080h ; convert to signed + REPT 2 + movsx eax, dl + imul eax, esi + sar eax, cl + mov dl, al + movsx eax, dh + imul eax, esi + sar eax, cl + mov dh, al + rol edx, 16 + ENDM + xor edx, 80808080h ; back to unsigned + mov dword ptr[edi], edx + add edi, 4 + dec si + jnz short loopfadeout +endif + mov al, 1 +endfade: + mov byte ptr[FlagPause], al +reallyexit: +ifdef GUS + popf + pop es +endif + ret + +FinishFill0: + or ax, ax ; still some room in the buffer? + jz Finish2 +process_1st: + mov cx, ax + shl eax, 16 + mov ax, cx ; eax = BUFFER_SIZE:BUFFER_SIZE + mov dx, word ptr[ebx+FRACT] ; fractionnal Source + mov bp, word ptr[ebx+INCR] ; fractionnal inc + mov ecx, dword ptr[ebx+LEFT] ; length left + + cmp ecx, 0FFFFh ; length left to fill after sample + ja Longer0 ; 64K or +, then more than the buffer + sub ax, cx + jae short NotLonger0 ; some left? +Longer0: + shr eax, 16 + mov ecx, eax ; length = buffer_size + sub dword ptr[ebx+LEFT], ecx ; reduce length left + mov word ptr[save_4], 0 ; no room left + jmp short StartMix0 +NotLonger0: + inc ax ; length + 1 (in case left = 0) + mov word ptr[save_4], ax +StartMix0: + shl edx, 16 + or ecx, edx ; hecx = FRACT + shl ebp, 16 ; hebp = INCR + +ifdef SAMPLE16BIT + + mov edx, dword ptr[ebx+VOL_LEFT] ; read left & right volume + + ifdef STEREO + + cmp byte ptr[ebx+INTERPOL], 0 + je nofilter + + mov dword ptr[save_3], ebx + + movsx eax, dx + mov [TheVolumeL], eax + sar edx, 16 + mov [TheVolumeR], edx + + shr ebp, 16 ; BP = fract inc + mov edx, ecx + shr edx, 16 ; DX = fract + + rol ecx, 8 + mov cl, [ebx+LAST_SAMPLE] + ror ecx, 8 + + jmp short next0 + +start0: rol ecx, 8 + mov cl, [esi] + inc esi + ror ecx, 8 +next0: mov eax, ecx + mov al, [esi] ; read data + rol eax, 8 + xor ax, 8080h ; 8 bit signed + movsx ebx, al + movsx eax, ah ; sign extension to 32 bit + + not dx + inc edx + imul ebx, edx + dec edx + not dx + imul eax, edx + add ebx, eax + + mov eax, ebx + imul ebx, [TheVolumeR] ; Right + imul eax, [TheVolumeL] ; Left + sar eax, 16 + mov bx, ax + + mov [edi], ebx ; store buffer content + add edi, 4 ; next location + add dx, bp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next0 ; if (not C) and (not Z) next + jnz short start0 ; if some left, read a new one + + mov ebx, dword ptr[save_3] + + pushf + + rol ecx, 8 + mov [ebx+LAST_SAMPLE], cl + + shl edx, 16 + mov ecx, edx + inc esi + + popf + + jmp short end16 +nofilter: + mov dword ptr[save_3], ebx + +start01: lodsb ; read new data + xor al, 80h ; 8 bit signed + movsx eax, al ; sign extension to 32 bit + mov ebx, eax ; copy into ebx + imul ax, dx ; ax = left + imul ebx, edx + mov bx, ax +next01: mov dword ptr[edi], ebx ; write data + add edi, 4 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next01 ; if (not C) and (not Z) next + jnz short start01 ; if some left, read a new one + + mov ebx, dword ptr[save_3] +end16: + else + +start0: lodsb ; read new data + xor al, 80h ; 8 bit signed + movsx ax, al ; sign extension to 16 bit + imul ax, dx ; ax = "volumed" sample +next0: mov word ptr[edi], ax ; write data + add edi, 2 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next0 ; if (not C) and (not Z) next + jnz short start0 ; if some left, read a new one + + endif +else + + ifdef STEREO + + mov dl, byte ptr[ebx+VOL_LEFT] + or dl, dl + jz short middle0 + dec dl + jz short left0 + + mov al, 80h ; "0" -> left +r_start0: mov ah, byte ptr[esi] ; read new data -> right + inc esi +r_next0: mov word ptr[edi], ax ; write data + add edi, 2 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short r_next0 ; if (not C) and (not Z) next + jnz short r_start0 ; if some left, read a new one + jmp short end0 + +left0: + + mov ah, 80h ; "0" -> right +l_start0: lodsb ; read new data -> left +l_next0: mov word ptr[edi], ax ; write data + add edi, 2 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short l_next0 ; if (not C) and (not Z) next + jnz short l_start0 ; if some left, read a new one + jmp short end0 + +middle0: + +m_start0: lodsb ; read new data -> left + mov ah, al ; data -> right +m_next0: mov word ptr[edi], ax ; write data + add edi, 2 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short m_next0 ; if (not C) and (not Z) next + jnz short m_start0 ; if some left, read a new one + +end0: + else + +start0: lodsb ; read new data +next0: mov byte ptr[edi], al ; write data + inc edi ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next0 ; if (not C) and (not Z) next + jnz short start0 ; if some left, read a new one + + endif +endif + + jc noadjust0 ; was a new data going to be read? + dec esi ; no, last data will be read again +noadjust0: + mov ax, word ptr[save_4] ; left to copy + or ax, ax + jz Finish ; 0 normal end + + dec ax ; readjust size + + dec word ptr[ebx+C_REPEAT] ; repeat again? + jnz Reset0 ; yes, then reset + + mov edx, dword ptr[ebx+SON] ; no, got a son? + or edx, edx + js short NoSon0 ; no, remove the sample + + lea esi, SonList ; yes, then find it +KeepLooking0: + cmp dword ptr[esi], 0 ; the end ? + je short NoSon0 ; yes, then no son + cmp edx, dword ptr[esi+HANDLE] ; this one? + je short FoundSon0 ; yes, found! + add esi, STRUCT_SIZE ; no, keep looking + jmp short KeepLooking0 +NoSon0: + or ax, ax + jz noclear + + xor ecx, ecx + mov cx, ax ; clear rest of the buffer + MIDPOINT +IFDEF SCHAR + mov edx, ecx + and ecx, 3 ; up to 3 by byte + rep stosb + mov ecx, edx + shr ecx, 2 ; the rest by dword +ELSEIFDEF SUWORD + shr ecx, 1 + jnc short NoAdjustByOne + stosw +NoAdjustByOne: +ENDIF + rep stosd +noclear: + mov esi, ebx ; point where it is + mov edi, ebx ; idem + add esi, STRUCT_SIZE ; source one further + +LoopRemove0: cmp dword ptr[esi], 0 ; end ? + je short EndRemove0 ; yes, exit + mov ecx, STRUCT_SIZE / 4 ; trasnfert one struct + rep movsd ; transfer + jmp short LoopRemove0 +EndRemove0: + mov dword ptr[edi], 0 ; write 0 to mark the end + jmp NextSample +FoundSon0: + mov ebp, esi ; save esi + mov edx, edi ; save edi + + mov edi, ebx ; transfert at the location of the father + mov ecx, STRUCT_SIZE / 4 ; count in dword + rep movsd ; transfert + + mov esi, ebp ; remove son from SonList + mov edi, ebp ; so, point to it + add esi, STRUCT_SIZE ; source one further +LoopSon0: cmp dword ptr[esi], 0 + je short EndSon0 + mov ecx, STRUCT_SIZE / 4 + rep movsd ; transfer while not 0 + jmp short LoopSon0 +EndSon0: + mov dword ptr[edi], 0 ; write 0 to mark the end + + mov edi, edx ; restore edi in the buffer + mov esi, dword ptr[ebx+START] ; restore source, no need to write it + jmp FinishFill0 +Reset0: + mov esi, dword ptr[ebx+START] ; restore source, no need to write it + mov ebp, dword ptr[ebx+DLENGTH] ; restore length + mov dword ptr[ebx+LEFT], ebp + mov word ptr[ebx+FRACT], 0 + jmp FinishFill0 + +NextSample: + mov esi, dword ptr[ebx] ; Current Source + or esi, esi ; if 0 then end of the list + jz exit + +ifdef RAM_CARD + mov edi, dword ptr[BUFFER_DMA] ; Buffer +else + mov edi, dword ptr[CURRENT_BUFFER] ; Buffer +endif + mov ax, BUFFER_SIZE +FinishFill: + or ax, ax ; still some room in the buffer? + jz Finish2 + + mov cx, ax + shl eax, 16 + mov ax, cx ; eax = BUFFER_SIZE:BUFFER_SIZE + mov dx, word ptr[ebx+FRACT] ; fractionnal Source + mov bp, word ptr[ebx+INCR] ; fractionnal inc + mov ecx, dword ptr[ebx+LEFT] ; length left + + cmp ecx, 0FFFFh ; length left to fill after sample + ja Longer ; 64K or +, then more than the buffer + sub ax, cx + jae short NotLonger ; some left? +Longer: + shr eax, 16 ; no, restore buffer_size in ax + mov ecx, eax ; length = buffer_size + sub dword ptr[ebx+LEFT], ecx ; reduce length left + mov word ptr[save_4], 0 ; no room left + jmp short startMix00 +NotLonger: + inc ax ; length + 1 (in case left = 0) + mov word ptr[save_4], ax +StartMix00: + shl edx, 16 + or ecx, edx ; hecx = FRACT + shl ebp, 16 ; hebp = INCR + +ifdef SAMPLE16BIT + + mov edx, dword ptr[ebx+VOL_LEFT] + + ifdef STEREO + + cmp byte ptr[ebx+INTERPOL], 0 + je nofilter00 + + mov dword ptr[save_3], ebx + + movsx eax, dx + mov [TheVolumeL], eax + sar edx, 16 + mov [TheVolumeR], edx + + shr ebp, 16 ; BP = fract inc + mov edx, ecx + shr edx, 16 ; DX = fract + + rol ecx, 8 + mov cl, [ebx+LAST_SAMPLE] + ror ecx, 8 + + jmp short next00 + +start00: rol ecx, 8 + mov cl, [esi] + inc esi + ror ecx, 8 +next00: mov eax, ecx + mov al, [esi] ; read data + rol eax, 8 + xor ax, 8080h ; 8 bit signed + movsx ebx, al + movsx eax, ah ; sign extension to 32 bit + + not dx + inc edx + imul ebx, edx + dec edx + not dx + imul eax, edx + add ebx, eax + + mov eax, ebx + imul ebx, [TheVolumeR] ; Right + imul eax, [TheVolumeL] ; Left + sar eax, 16 + mov bx, ax + + add [edi], ebx ; store buffer content + add edi, 4 ; next location + add dx, bp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next00 ; if (not C) and (not Z) next + jnz short start00 ; if some left, read a new one + + mov ebx, dword ptr[save_3] + + pushf + + rol ecx, 8 + mov [ebx+LAST_SAMPLE], cl + + shl edx, 16 + mov ecx, edx + inc esi + + popf + + jmp short end016 +nofilter00: + mov dword ptr[save_3], ebx + +start001: lodsb ; read new data + xor al, 80h ; 8 bit signed + movsx eax, al ; sign extension to 32 bit + mov ebx, eax ; copy into ebx + imul ax, dx ; ax = left + imul ebx, edx + mov bx, ax +next001: add dword ptr[edi], ebx ; write data + add edi, 4 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next001 ; if (not C) and (not Z) next + jnz short start001 ; if some left, read a new one + + mov ebx, dword ptr[save_3] +end016: + + else + +start00: lodsb ; read new data + xor al, 80h ; 8 bit signed + movsx ax, al ; sign extension to 16 bit + imul ax, dx ; ax = "volumed" sample +next00: add word ptr[edi], ax ; add with buffer content + add edi, 2 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next00 ; if (not C) and (not Z) next + jnz short start00 ; if some left, read a new one + + endif +else + + ifdef STEREO + + mov dl, byte ptr[ebx+VOL_LEFT] + or dl, dl + jz short middle00 + dec dl + jz short left00 + + inc edi ; go right +r_start00: lodsb ; read new data + mov ah, al ; save it in ah +r_next00: add al, byte ptr[edi] ; add with buffer content + rcr al, 1 ; average + mov byte ptr[edi], al ; write result back + add edi, 2 ; next location + mov al, ah ; restore data + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short r_next00 ; if (not C) and (not Z) next + jnz short r_start00 ; if some left, read a new one + dec edi ; go back left + jmp short end00 + +left00: + +l_start00: lodsb ; read new data + mov ah, al ; save it in ah +l_next00: add al, byte ptr[edi] ; add with buffer content + rcr al, 1 ; average + mov byte ptr[edi], al ; write result back + add edi, 2 ; next location + mov al, ah ; restore data + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short l_next00 ; if (not C) and (not Z) next + jnz short l_start00 ; if some left, read a new one + jmp short end00 + +middle00: + +m_start00: lodsb ; read new data +m_next00: mov dx, word ptr[edi] ; read buffer, left & right + add dl, al ; average with left + rcr dl, 1 + add dh, al ; average with right + rcr dh, 1 + mov word ptr[edi], dx ; write result back + add edi, 2 ; next location + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short m_next00 ; if (not C) and (not Z) next + jnz short m_start00 ; if some left, read a new one + +end00: + + else + +start00: lodsb ; read new data + mov ah, al ; save it in ah +next00: add al, byte ptr[edi] ; add with buffer content + rcr al, 1 ; average + adc al, 0 + mov byte ptr[edi], al ; write result back + inc edi ; next location + mov al, ah ; restore data + add ecx, ebp ; update fractional part of address + dec cx ; length-1, doesn't touch C but set Z ;-) + ja short next00 ; if (not C) and (not Z) next + jnz short start00 ; if some left, read a new one + + endif +endif + jc noadjust ; was a new data going to be read? + dec esi ; no, last data will be read again +noadjust: + mov ax, word ptr[save_4] ; left to copy + or ax, ax + jz short Finish ; 0 normal end + + dec ax ; readjust size + + dec word ptr[ebx+C_REPEAT] ; repeat again? + jnz short Reset ; yes, then reset + + mov edx, dword ptr[ebx+SON] ; no, got a son? + or edx, edx + js short NoSon ; no, remove the sample + + lea esi, SonList ; yes, then find it +KeepLooking: + cmp dword ptr[esi], 0 ; the end ? + je short NoSon ; yes, then no son + cmp edx, dword ptr[esi+HANDLE] ; this one? + je short FoundSon ; yes, found! + add esi, STRUCT_SIZE ; no, keep looking + jmp short KeepLooking +NoSon: ; remove it + mov esi, ebx ; point where it is + mov edi, ebx ; idem + add esi, STRUCT_SIZE ; source one further + +LoopRemove: cmp dword ptr[esi], 0 ; end ? + je short EndRemove ; yes, exit + mov ecx, STRUCT_SIZE / 4 ; trasnfert one struct + rep movsd ; transfer + jmp short LoopRemove +EndRemove: + mov dword ptr[edi], 0 ; write 0 to mark the end + jmp NextSample +FoundSon: + mov ebp, esi ; save esi + mov edx, edi ; save edi + + mov edi, ebx ; transfert at the location of the father + mov ecx, STRUCT_SIZE / 4 ; count in dword + rep movsd ; transfert + + mov esi, ebp ; remove son from SonList + mov edi, ebp ; so, point to it + add esi, STRUCT_SIZE ; source one further +LoopSon: cmp dword ptr[esi], 0 + je short EndSon + mov ecx, STRUCT_SIZE / 4 + rep movsd ; transfer while not 0 + jmp short LoopSon +EndSon: + mov dword ptr[edi], 0 ; write 0 to mark the end + + mov edi, edx ; restore edi in the buffer + mov esi, dword ptr[ebx+START] ; restore source, no need to write it + jmp FinishFill +Finish: + shr ecx, 16 + mov word ptr[ebx+FRACT], cx ; save fractional part +Finish2: mov dword ptr[ebx], esi ; save current address + add ebx, STRUCT_SIZE ; point to next sample + jmp NextSample +Reset: + mov esi, dword ptr[ebx+START] ; restore source, no need to write it + mov ebp, dword ptr[ebx+DLENGTH] ; restore length + mov dword ptr[ebx+LEFT], ebp + mov word ptr[ebx+FRACT], 0 + jmp FinishFill + +UpdateBuffer ENDP + +;*--------------------------------------------------------------------------* + +StopSample PROC + + CRIT_SECT + + xor eax, eax + + mov dword ptr[CurrentList], eax + mov dword ptr[SonList], eax + mov byte ptr[FlagPause], al + dec eax + mov dword ptr[follow], eax ; -1 + + mov dword ptr[weirdcount], 10000h + + END_CRIT_SECT + + ret + +StopSample ENDP + +;*--------------------------------------------------------------------------* + +StopOneSample PROC USES EBX ESI EDI,\ + thehandle:DWORD + + + push -1 ; end of recursion + mov eax, thehandle + lea edx, CurrentList + mov ebx, edx + + CRIT_SECT + +keeplooking: cmp dword ptr[ebx], 0 + je short exit + cmp ax, word ptr[ebx+HANDLE] + je short found + add ebx, STRUCT_SIZE + jmp short keeplooking +exit: + lea ebx, SonList + cmp edx, ebx + mov edx, ebx + jne short keeplooking + + pop eax ; get "son" + or eax, eax + jns short keeplooking ; less than #2 billions samples ! + + END_CRIT_SECT + + ret +found: + mov ecx, dword ptr[ebx+SON] + or ecx, ecx + js short noson + + push ecx ; "son" to be removed +noson: + mov esi, ebx + mov edi, ebx + add esi, STRUCT_SIZE +LoopRemove: cmp dword ptr[esi], 0 + je short EndRemove + mov ecx, STRUCT_SIZE / 4 + rep movsd + jmp short LoopRemove +EndRemove: + mov dword ptr[edi], 0 + jmp short keeplooking + +StopOneSample ENDP + +;---------------------------------------------------------------------------- + +ShiftSamples PROC USES ESI EDI EBX,\ + DestAddr:DWORD, SrcAddr:DWORD, SizeByte:DWORD + + lea edx, CurrentList + + mov esi, SrcAddr ; Source + mov eax, esi ; save Source for comparison + mov edi, DestAddr ; Destination + mov ecx, SizeByte ; number of bytes to move + + mov bl, cl ; compute counters + shr ecx, 2 + and bl, 3 + + CRIT_SECT + + rep movsd ; move the data + mov cl, bl + rep movsb + + sub edi, esi ; shift (delta addr) + + mov ebx, edx + +keeplooking: cmp dword ptr[ebx], 0 + je short exit + cmp eax, [ebx+START] + ja short notfound + add [ebx+START], edi + add [ebx], edi +notfound: + add ebx, STRUCT_SIZE + jmp short keeplooking +exit: + lea ebx, SonList + cmp edx, ebx + mov edx, ebx + jne short keeplooking + + END_CRIT_SECT + + ret + +ShiftSamples ENDP + +;---------------------------------------------------------------------------- + +StopOneSampleLong PROC USES ESI EDI,\ + LongHandle:DWORD + + mov eax, LongHandle + + CRIT_SECT + + call SearchLongHandle + or edx, edx + jz short notfound + + mov esi, edx + mov edi, edx + add esi, STRUCT_SIZE +LoopRemove: cmp dword ptr[esi], 0 + je short EndRemove + mov ecx, STRUCT_SIZE / 4 + rep movsd + jmp short LoopRemove +EndRemove: + mov dword ptr[edi], 0 +notfound: + END_CRIT_SECT + + ret + +StopOneSampleLong ENDP + +;*--------------------------------------------------------------------------* + +SampleInList PROC USES EBX,\ + thehandle:DWORD + + CRIT_SECT + + mov edx, thehandle + mov eax, 1 ; True + + lea ecx, CurrentList + mov ebx, ecx + +keeplooking: cmp dword ptr[ebx], 0 + je short exit + cmp dx, word ptr[ebx+HANDLE] + je short found + add ebx, STRUCT_SIZE + jmp short keeplooking +exit: + lea ebx, SonList + cmp ecx, ebx + mov ecx, ebx + jne keeplooking + + xor eax, eax ; False +found: + END_CRIT_SECT + + ret + +SampleInList ENDP + + +;*--------------------------------------------------------------------------* + +SearchLongHandle PROC + + lea edx, CurrentList + lea ecx, SonList + +keeplooking: cmp dword ptr[edx], 0 + je short exit + cmp eax, dword ptr[edx+HANDLE] + je short found + add edx, STRUCT_SIZE + jmp short keeplooking +exit: + cmp edx, ecx + mov edx, ecx + jne keeplooking + + xor edx, edx +found: + ret + +SearchLongHandle ENDP + + +;*--------------------------------------------------------------------------* + +ChangeVolume PROC \ + LongHandle:DWORD, volleft:DWORD, volright:DWORD + +ifdef STEREO + ifdef SAMPLE16BIT + + mov eax, LongHandle + + CRIT_SECT + + call SearchLongHandle + or edx, edx + jz short notfound + + mov eax, volleft + shr eax, SHIFT_SAMPLE - 1 ; Preshift according to number of channels + mov word ptr[edx+VOL_LEFT], ax + mov eax, volright + shr eax, SHIFT_SAMPLE - 1 ; Preshift according to number of channels +ifdef SURROUND + neg eax +endif + mov word ptr[edx+VOL_RIGHT], ax + +notfound: + + END_CRIT_SECT + + else + + mov eax, LongHandle + + CRIT_SECT + + call SearchLongHandle + or edx, edx + jz short notfound + + push edi + mov edi, edx + + mov cx, word ptr[volleft] + or cx, cx + jnz short okleft + mov cx, 2 ; if volleft = 0 then right + jmp short storepos +okleft: mov ax, word ptr[volright] + shl ax, 7 ; * 128 + xor dx, dx + div cx + mov cx, 2 ; right + cmp ax, 74 ; .577 (= tan 30) * 128 + jb short storepos + dec cx ; left + cmp ax, 222 ; 1.732 (= tan 60) * 128 + jae short storepos + dec cx ; middle +storepos: mov word ptr[edi+VOL_LEFT], cx ; Store position (0:middle, 1:left, 2:right) + + pop edi +notfound: + + END_CRIT_SECT + + endif +else + ifdef SAMPLE16BIT + + mov eax, LongHandle + + CRIT_SECT + + call SearchLongHandle + or edx, edx + jz short notfound + + push edi + push ebx + mov edi, edx + + mov eax, volleft + imul eax, eax + mov ecx, volright + imul ecx, ecx + add eax, ecx + call sqr2 + shr eax, SHIFT_SAMPLE - 1 ; Preshift according to number of channels + mov word ptr[edi+VOL_LEFT], ax ; VOL_LEFT = sqr(volleft^2 + volright^2) + + pop ebx + pop esi + +notfound: + + END_CRIT_SECT + + endif +endif + + ret + +ChangeVolume ENDP + +ifdef SAMPLE16BIT +ifndef STEREO + +;*--------------------------------------------------------------------------* + +; EAX = Sqr(EAX) + +Sqr2 PROC + + cmp eax, 3 ; if eax <= 3 then + jbe short asqr_0_1 ; square root is 0 or 1 + + xor edx, edx ; clear edx + mov ebx, eax ; copy eax into ebx so that + ; edx:ebx are used "like" a 64 bit + ; register + + bsr eax, ebx ; position of last 1 of ebx in eax + + mov cl, 33 ; compute how many left shift + sub cl, al ; are needed in order to have the + and cl, 11111110b ; most significant 2 bit pair at the + ; leftmost position of edx + + shld edx, ebx, cl ; shift edx:ebx by the number + shl ebx, cl ; computed above + + mov ecx, eax ; compute in ecx how many pairs of + shr ecx, 1 ; 2 bit are left to be processed + + mov eax, 1 ; eax = 1 + dec edx ; edx = edx - 1 + +asqr_loop: shld edx, ebx, 2 ; edx:ebx << 2 + shl ebx, 2 ; + lve eax, eax*2 ; eax * 2 + cmp edx, eax ; compare edx and eax + jb short asqr_neg ; if edx> 1 + dec ecx ; one less pair to process + jnz short asqr_loop ; if there is some left then go asqr_loop + ret ; return to caller + +asqr_0_1: or eax, eax ; if eax = 0 + jz short asqr_00 ; then return to caller + mov eax, 1 ; else eax = 1 +asqr_00: ret ; return to caller + +Sqr2 ENDP + +endif +endif + +;*--------------------------------------------------------------------------* + +MixSample PROC USES ESI EDI EBX,\ + thehandle:DWORD, pitchbend:DWORD, therepeat:DWORD,\ + plug:DWORD, volleft:DWORD, volright:DWORD,\ + buffer:DWORD; buffer with .VOC + + mov esi, buffer + + xor eax, eax + mov al, [esi] + inc al + cmp al, 10 + jb okfilter + + xor eax, eax + +okfilter: push eax + + movzx eax, word ptr[esi+14h] + add esi, eax ; skip header + + cmp byte ptr[esi], 1 ; only 1 bloc type allowed + jne typeunknown + + cmp byte ptr[esi + 5], 0 ; pack method + jne typeunknown + + ; This crap should be removed by using a file format containing the + ; real sampling frequency instead of that stupid sr number in .VOC ! + ; :-( + + mov dx, 0Fh + mov ax, 4240h ; dx:ax = 1000000 + + xor ebx, ebx + mov bl, byte ptr[esi + 4] ; bl = sr + neg bl ; bl = 256 - sr + + div bx + + shl dx, 1 + adc ax, 0 ; round to nearest + + mov bx, ax + + ; ebx = real sampling rate + ; up to here ! and then avoid this ^ div ! + + + mov eax, dword ptr[esi + 1] ; size sample + and eax, 0FFFFFFh ; 24 significant bits + sub eax, 2 ; -2 header + + + add esi, 6 ; esi->data + mov dword ptr[save_1], esi ; save it + + mov edx, pitchbend + shl edx, 4 + + imul ebx, edx + shr ebx, 16 + adc bx, 0 ; ebx = scaled sampling rate + + xor edx, edx + xchg eax, ebx ; edx = 0, eax = sr, ebx = size + xchg edx, eax ; edx = sr, eax = 0, ebx = size + div word ptr[PlayRate] ; dx:ax / PlayRate; ax = INCR + + cmp eax, 0FFFFh + jbe okincr + mov eax, 0FFFFh +okincr: mov dword ptr[save_2], eax ; save_2 = INCR + + mov ecx, ebx ; ecx = size + mov esi, ebx + shr esi, 16 ; esi = hi(size) + + mov edx, esi + xchg eax, ebx ; eax = size, ebx = INCR + + dec eax ; A TRY !!!! (will make loop around next longer...) + + shl eax, 16 + div ebx ; div 64 bits !!! + sub eax, esi ; sub max roundoff error + mov esi, eax ; esi = eax = new size + + mul ebx ; remultiply + mov bx, ax ; FRACT in bx + shrd eax, edx, 16 ; size in eax + mov dx, word ptr[save_2] ; INCR in dx + + sub ecx, eax ; how much am I off? + jbe typeunknown ; security, should not happen! + +next: inc esi ; length + 1 + add bx, dx ; update fractional part of address + jnc short next ; if (not C) next + dec cx + jnz short next ; not right yet, loop + + mov eax, dword ptr[follow] + lea ebx, CurrentList + mov edi, ebx + + mov cx, word ptr[thehandle] + +IFNDEF SAMPLE16BIT + + cmp cx, VOICE_HANDLE + jne ok_handle + + push eax + push ecx + push edx + call StopSample + pop edx + pop ecx + pop eax +ok_handle: + +ENDIF + or ecx, dword ptr[weirdcount] ; why not ? + inc word ptr[weirdcount+2] + + CRIT_SECT + + cmp plug, 0 + je NoPlug + + lea edi, SonList + +keeplooking0: cmp dword ptr[ebx], 0 + je short SearchSonList + cmp eax, dword ptr[ebx+HANDLE] ; look for the "father" sample + je short found + add ebx, STRUCT_SIZE + jmp short keeplooking0 +SearchSonList: + lea ebx, SonList +keeplooking1: cmp dword ptr[ebx], 0 + je short Exit + cmp eax, dword ptr[ebx+HANDLE] ; look for the "father" sample + je short found + add ebx, STRUCT_SIZE + jmp short keeplooking1 +exit: + xor eax, eax + jmp endcritical +found: + mov dword ptr[ebx+SON], ecx ; connect it to ist "son" +NoPlug: + lea ebx, [edi+STRUCT_SIZE*LIST_SIZE] + + xor eax, eax + sub edi, STRUCT_SIZE + +SearchEnd: add edi, STRUCT_SIZE + cmp eax, dword ptr[edi] + jne short SearchEnd + + cmp edi, ebx + jae typeunknown + + mov dword ptr[follow], ecx ; update follow + mov dword ptr[edi+HANDLE], ecx ; sample handle + mov cx, word ptr[therepeat] + mov word ptr[edi+C_REPEAT], cx ; Repeat + mov dword ptr[edi+LEFT], esi ; length + mov dword ptr[edi+DLENGTH], esi ; length + mov eax, dword ptr[save_1] + mov dword ptr[edi], eax ; Start + mov dword ptr[edi+START], eax ; Start + mov eax, dword ptr[save_2] + mov word ptr[edi+INCR], ax ; increment + mov dword ptr[edi+FRACT], 10000h ; fractional (with 1 above so != 0) + mov dword ptr[edi+SON], -1 ; son + mov dword ptr[edi+INFO0], -1 ; info0 + pop eax + mov [edi+INTERPOL], al ; filter on/off + mov byte ptr[edi+LAST_SAMPLE], 80h ; 80h ( 0 ) +ifdef STEREO + ifdef SAMPLE16BIT + mov eax, volleft + shr eax, SHIFT_SAMPLE - 1 ; Preshift according to number of channels + mov word ptr[edi+VOL_LEFT], ax + mov eax, volright + shr eax, SHIFT_SAMPLE - 1 ; Preshift according to number of channels + + ifdef SURROUND + neg eax + endif + + mov word ptr[edi+VOL_RIGHT], ax + else + mov si, 2 ; right + mov ecx, volleft + or ecx, ecx + jz short storepos +okleft: mov eax, volright + shl eax, 7 ; * 128 + xor edx, edx + div ecx + cmp eax, 74 ; 1.732 (= tan 60) * 128 + jb short storepos + dec si ; left + cmp eax, 222 ; .577 (= tan 30) * 128 + jae short storepos + dec si ; middle +storepos: mov word ptr[edi+VOL_LEFT], si ; Store position (0:middle, 1:left, 2:right) + mov word ptr[edi+VOL_RIGHT], 1 ; to fill with non 0 + endif +else + ifdef SAMPLE16BIT + mov eax, volleft + imul eax, eax + mov ecx, volright + imul ecx, ecx + add eax, ecx + call sqr2 + shr eax, SHIFT_SAMPLE - 1 ; Preshift according to number of channels + mov word ptr[edi+VOL_LEFT], ax ; VOL_LEFT = sqr(volleft^2 + volright^2) + mov word ptr[edi+VOL_RIGHT], 1 ; to fill with non 0 + else + mov dword ptr[edi+VOL_LEFT], 1 ; to fill with non 0 + endif +endif + mov dword ptr[edi+STRUCT_SIZE], 0 ; mark end of List + + mov eax, dword ptr[follow] +endcritical: + END_CRIT_SECT + + ret +typeunknown: + pop eax + xor eax, eax + ret + +MixSample ENDP + +;*--------------------------------------------------------------------------* + +ifdef SINGLE_DMA + +BlockTransfert PROC + + push ebx + + mov ecx, BUFFER_SIZE * SSIZE + cmp word ptr[DMA_number], 3 + jbe noLengthAdj + shr ecx, 1 +NoLengthAdj: + dec ecx ; buffer size - 1 + + mov ebx, dword ptr[DMA] ; Point to DMAx + + mov dx, word ptr[ebx + MASK_REG] + mov al, byte ptr[ebx + MASK2] ; mask channel + out dx, al + + mov dx, word ptr[ebx + FF_REG] + out dx, al ; flip-flop + + + mov dx, word ptr[ebx + COUNT_REG] + mov al, cl ; buffer size - 1 + out dx, al + mov al, ch + out dx, al + + mov dx, word ptr[ebx + ADDX_REG] + mov eax, dword ptr[BufferHalf] + mov eax, dword ptr[BUFFER_DMA+eax] ; start offset + cmp word ptr[DMA_number], 3 + jbe noAddrAdj + shr eax, 1 +NoAddrAdj: + out dx, al + shr eax, 8 + out dx, al + + mov dx, word ptr[ebx + PAGE_REG] + shr eax, 8 ; page of DMA transfert + out dx, al + + mov dx, word ptr[ebx + MODE_REG] + mov al, byte ptr[ebx + VOICE_OUT] ; output sample + out dx, al + + mov dx, word ptr[ebx + MASK_REG] + mov al, byte ptr[ebx + MASK1] ; channel OK + out dx, al + + pop ebx + + jmp StartDMACard + +BlockTransfert ENDP + +endif + +;*--------------------------------------------------------------------------* + +PauseSample PROC + + xor eax, eax + + CRIT_SECT + + mov al, byte ptr[FlagPause] + dec al + and al, 10b + or al, 01b ; 0->3, 1->1, 2->1, 3->3 + mov byte ptr[FlagPause], al + shr eax, 1 + xor al, 1 + + END_CRIT_SECT + + ret + +PauseSample ENDP + +;*--------------------------------------------------------------------------* + +ContinueSample PROC + + xor eax, eax + + CRIT_SECT + + mov al, byte ptr[FlagPause] + inc al + and al, 10b ; 0->0, 1->2, 2->2, 3->0 + mov byte ptr[FlagPause], al + shr eax, 1 + xor al, 1 + + END_CRIT_SECT + + ret + +ContinueSample ENDP + +;---------------------------------------------------------------------------- + +ifndef NOIRQ + +InstallISR PROC + + push edx + + mov bl, byte ptr[INT_number] ; plug ISR on user INT + mov cx, cs + SET_PROT_VECT + + pop edx + + cmp dword ptr[IRQ_number], 7 ; if IRQ > 7 + jbe nobi + + mov bl, 18h ; plug as well on int 18h + mov cx, cs + SET_PROT_VECT + + mov bl, byte ptr[INT_number] ; plug into real usr INT + mov ecx, offset Redirector + mov dx, cx ; compute real-mode + xor cx, cx ; seg:ofs + shr ecx, 4 + SET_REAL_VECT +nobi: + ret + +InstallISR ENDP + +endif + +;---------------------------------------------------------------------------- + +InitCard PROC USES EBX EDI ESI EBP,\ + Buffer:DWORD + +ifndef NOIRQ + mov word ptr[local_DS], ds +endif + mov eax, Buffer + mov dword ptr[BUFFER_DMA], eax + +ifndef SBPRO + call ResetCard +endif + +ifndef NOIRQ + + xor eax, eax + mov ax, word ptr[DMA_number] + cmp ax, 7 + ja short ErrorDMA + mov eax, dword ptr[TAB_DMA+eax*4] + or eax, eax + jnz short DMAFound +ErrorDMA: + xor eax, eax + ret +DMAFound: + mov dword ptr[DMA], eax + + mov eax, dword ptr[IRQ_number] + cmp al, 7 + ja short Second + add al, 8 + jmp short gotvect +Second: + add al, 70h - 8 +gotvect: + mov dword ptr[INT_number], eax ; save user int + + mov bl, al + GET_PROT_VECT + mov word ptr[Old_PIRQ_Sel], cx + mov dword ptr[Old_PIRQ_Off], edx + + cmp dword ptr[IRQ_number], 7 + jbe nobi + + mov bl, byte ptr[INT_number] ; if IRQ>7 save real vect + GET_REAL_VECT + mov word ptr[Old_RIRQ_Seg], cx + mov word ptr[Old_RIRQ_Off], dx + + mov bl, 18h ; if IRQ>7 save int 18h + GET_PROT_VECT + mov word ptr[Old_18_Sel], cx + mov dword ptr[Old_18_Off], edx +nobi: + + mov dx, 21h ; IRQ mask reg + mov cx, word ptr[IRQ_number] + cmp cx, 7 + jbe short Ok21 + mov dx, 0A1h ; reg A1h, 2nd ctrl +Ok21: in al, dx + mov byte ptr[IRQ_mask], al ; save mask + and cl, 7 + mov bl, 1 + shl bl, cl + not bl + and al, bl ; unmask IRQ + out dx, al ; write new mask + +ifdef SBPRO + call ResetCard +endif + + mov edx, offset NewIRQ + call InstallISR +endif + call StopSample ; to reset everything + + xor eax, eax + mov dword ptr[BackCurrentList], eax + mov dword ptr[BackSonList], eax + + mov edi, dword ptr[BUFFER_DMA] + + mov eax, edi + add eax, BUFFER_SIZE * SSIZE + mov dword ptr[MID_BUFFER_DMA], eax ; init pointer + mov dword ptr[CURRENT_BUFFER], eax ; init pointer + + mov dword ptr[BufferHalf], 4 ; point on second half + + mov ecx, (BUFFER_SIZE * 2 * SSIZE) / 4; clear all buffer + MIDPOINT + rep stosd + +ifndef NOIRQ + +ifdef AUTO_DMA + + mov ecx, BUFFER_SIZE * 2 * SSIZE + cmp word ptr[DMA_number], 3 + jbe noLengthAdj + shr ecx, 1 +NoLengthAdj: + dec ecx + + mov ebx, dword ptr[DMA] ; Point to DMAx + + mov dx, word ptr[ebx + MASK_REG] + mov al, byte ptr[ebx + MASK2] ; mask channel + out dx, al + + mov dx, word ptr[ebx + FF_REG] + out dx, al ; flip-flop + + mov dx, word ptr[ebx + COUNT_REG] + mov al, cl ; buffer size - 1 + out dx, al + mov al, ch + out dx, al + + mov dx, word ptr[ebx + ADDX_REG] + mov eax, dword ptr[BUFFER_DMA] ; start offset + cmp word ptr[DMA_number], 3 + jbe noAddrAdj + shr eax, 1 + mov di, ax + xor ax, ax + shl eax, 1 + mov ax, di +NoAddrAdj: + out dx, al + shr eax, 8 + out dx, al + + mov dx, word ptr[ebx + PAGE_REG] + shr eax, 8 ; page of DMA transfert + out dx, al + + mov dx, word ptr[ebx + MODE_REG] + mov al, byte ptr[ebx + AUTO_OUT] ; output sample + out dx, al + + mov dx, word ptr[ebx + MASK_REG] + mov al, byte ptr[ebx + MASK1] ; channel OK + out dx, al +endif + +endif + +ifdef AUTO_DMA + call StartDMACard +elseifdef SINGLE_DMA + call BlockTransfert ; Start DMA transfert +endif + mov eax, 1 + ret + +InitCard ENDP + +;---------------------------------------------------------------------------- + +ClearCard PROC USES EBX ESI EDI EBP + + call StopSample ; just in case something was playing... + call CloseCard + +ifndef NOIRQ + mov dx, 21h ; read IRQ mask + cmp word ptr[IRQ_number], 7 + jbe short Ok21 + add dx, 80h ; reg 0A1h +Ok21: mov al, byte ptr[IRQ_mask] ; get old mask + out dx, al ; write old IRQ mask + + mov bl, byte ptr[INT_number] + mov cx, word ptr[Old_PIRQ_sel] + mov edx, dword ptr[Old_PIRQ_off] + SET_PROT_VECT + + cmp dword ptr[IRQ_number], 7 + jbe nobi + + mov bl, byte ptr[INT_number] + mov cx, word ptr[Old_RIRQ_seg] + mov dx, word ptr[Old_RIRQ_off] + SET_REAL_VECT + + mov bl, 18h + mov cx, word ptr[Old_18_sel] + mov edx, dword ptr[Old_18_off] + SET_PROT_VECT +nobi: + +endif + + ret + +ClearCard ENDP + +;---------------------------------------------------------------------------- + +AskVars PROC ,\ + pListNames:DWORD, pListVars:DWORD + + mov eax, offset ListNames + mov ecx, pListNames + mov dword ptr[ecx], eax + mov eax, offset ListVars + mov ecx, pListVars + mov dword ptr[ecx], eax + ret + +AskVars ENDP + + +;---------------------------------------------------------------------------- + +GetBufferSize PROC + + mov eax, BUFFER_SIZE * 2 * SSIZE + + ret + +GetBufferSize ENDP + +;---------------------------------------------------------------------------- + +GiveSampleInfo0 PROC \ + LongHandle:DWORD, Info:DWORD + + mov eax, LongHandle + + CRIT_SECT + + call SearchLongHandle + or edx, edx + jz short notfound + + mov eax, Info + mov dword ptr[edx+INFO0], eax +notfound: + END_CRIT_SECT + + ret + +GiveSampleInfo0 ENDP + +;---------------------------------------------------------------------------- + +GetSnapSample PROC USES EBX,\ + pList:DWORD + + lea eax, SnapList + mov edx, pList + mov dword ptr[edx], eax + + lea edx, CurrentList + lea ecx, SonList + + CRIT_SECT + +keeplooking: cmp dword ptr[edx], 0 + je short exit + + mov ebx, dword ptr[edx+HANDLE] + mov dword ptr[eax], ebx + mov ebx, dword ptr[edx+INFO0] + mov dword ptr[eax+4], ebx + mov ebx, dword ptr[edx] + sub ebx, dword ptr[edx+START] + mov dword ptr[eax+8], ebx + + add eax, 12 + add edx, STRUCT_SIZE + jmp short keeplooking +exit: + cmp ecx, edx + mov edx, ecx + jne keeplooking + + END_CRIT_SECT + + sub eax, offset SnapList + shr eax, 3 + + ret + +GetSnapSample ENDP + + +;---------------------------------------------------------------------------- + +CopyList PROC + +keepcopying: cmp dword ptr[esi], 0 + je short endcopy + mov ecx, STRUCT_SIZE / 4 + rep movsd + jmp short keepcopying +endcopy: mov dword ptr[edi], 0 + ret + +CopyList ENDP + +;---------------------------------------------------------------------------- + +SAveStateSample PROC USES ESI EDI + + call PauseSample + +waitpause: cmp byte ptr[FlagPause], 1 + jne short waitpause + + CRIT_SECT + + lea esi, CurrentList ; backup CurrentList + lea edi, BackCurrentList + call CopyList + lea esi, SonList ; backup SonList + lea edi, BackSonList + call CopyList + mov eax, dword ptr[follow] ; Backup follow + mov dword ptr[backfollow], eax + mov eax, dword ptr[weirdcount] ; Backup weirdcount + mov dword ptr[backweirdcount], eax + + xor eax, eax ; empty both lists + mov dword ptr[CurrentList], eax + mov dword ptr[SonList], eax + + mov byte ptr[FlagPause], 0 + + END_CRIT_SECT + + ret + +SAveStateSample ENDP + +;---------------------------------------------------------------------------- + +RestoreStateSample PROC USES ESI EDI + + call PauseSample + +waitpause: cmp byte ptr[FlagPause], 1 + jne short waitpause + + CRIT_SECT + + lea esi, BackCurrentList ; restore CurrentList + lea edi, CurrentList + call CopyList + lea edi, BackSonList ; restore SonList + lea edi, SonList + call CopyList + mov eax, dword ptr[backfollow] ; restore follow + mov dword ptr[follow], eax + mov eax, dword ptr[backweirdcount] ; restore weirdcount + mov eax, dword ptr[weirdcount] + + END_CRIT_SECT + + call ContinueSample + +waitcontinue: cmp byte ptr[FlagPause], 0 + jne short waitcontinue + + ret + +RestoreStateSample ENDP + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef PAS + +INT2F PROC\ ;Perform DPMI call to real-mode INT 2F + USES esi edi\ ;for Pro Audio Spectrum driver access + ,regAX,regBX + + mov ax,WORD PTR [regAX] + mov int_AX,ax + + mov ax,WORD PTR [regBX] + mov int_BX,ax + + mov int_DS,0 + mov int_ES,0 + + pushf + pop ax + mov int_flags,ax + + mov eax,0300h + mov ebx,002fh + mov ecx,0 + mov edi,OFFSET DPMI_real_int + int 31h + + mov ax,int_AX + mov bx,int_BX + mov cx,int_CX + mov dx,int_DX + ret + +INT2F ENDP + +;---------------------------------------------------------------------------- + +ResetCard PROC USES EBX + + mov eax,0bc04h ;get current DMA and IRQ settings + invoke INT2F,eax,eax + and ebx,0ffh + and ecx,0ffh + mov [DMA_number],ebx + mov [IRQ_number],ecx + + mov eax,0bc07h ;get state table entries + invoke INT2F,eax,eax + + xor eax,eax ;update local state table + mov al,bh + mov MV_xchannel,eax + mov al,ch + mov MV_filter,eax + + mov eax, MV_xchannel + mov edx, CROSSCHANNEL ;disable DRQs from PAS +IFDEF SAMPLE16BIT + and eax, 00110000b ;and disable PCM state machine + or eax, 00001001b +ELSE + and eax, 00110000b ;and disable PCM state machine + or eax, 00000110b +ENDIF + out dx, al + mov MV_xchannel, eax + + mov edx, PCMDATA ;silence PCM output + mov al, 80h + out dx, al + + + mov edx, SYSCONF + in al, dx + +IFDEF SAMPLE16BIT + or al, 100b +ELSE + and al, 11111011b +ENDIF + + out dx, al + + + mov ecx, [PlayRate] + shl ecx, 1 + xor edx, edx + mov eax, 1193180 + div ecx + mov ecx, eax + + mov al, 00110110b ;timer 0, square wave, binary mode + mov edx, TMRCTLR + out dx, al + mov edx, SAMPLERATE + mov al, cl + out dx, al + jmp $+2 + mov al, ch + out dx, al + + mov edx,INTRCTLRST ;enable IRQs on sample buffer empty + out dx,al + jmp $+2 + in al,dx + mov edx,INTRCTLR + in al,dx + or eax,00001000b + out dx,al + + ret + +ResetCard ENDP + +;---------------------------------------------------------------------------- + +CloseCard PROC + + mov eax,MV_xchannel + mov edx,CROSSCHANNEL ;disable DRQs from PAS + and eax,00111111b ;and disable PCM state machine + out dx,al + mov MV_xchannel,eax + + ret + +CloseCard ENDP + +;---------------------------------------------------------------------------- + +StartDMACard PROC + + mov eax,MV_xchannel + mov edx,CROSSCHANNEL + or eax,10000000b ;secure the DMA channel + out dx,al + mov MV_xchannel,eax + + mov cx, BUFFER_SIZE * SSIZE + + mov eax,01110100b ;program sample buffer counter + mov edx,TMRCTLR + out dx,al + mov edx,SAMPLECNT + mov al,cl + out dx,al + jmp $+2 + mov al,ch + out dx,al + + mov al,BYTE PTR MV_xchannel + and al,00001111b ;reset PCM state machine + or al,10010000b + mov edx,CROSSCHANNEL + out dx,al + jmp $+2 + or al,01000000b + out dx,al + mov BYTE PTR MV_xchannel,al + +; mov eax,MV_filter +; or eax,11000000b + mov eax,11100000b + mov edx,AUDIOFILT + out dx,al ;start the transfer + mov MV_filter,eax + + ret + +StartDMACard ENDP + +;---------------------------------------------------------------------------- + +AckIrq PROC + + mov edx,INTRCTLRST + in al,dx ;acknowledge the interrupt + test eax,00001000b + jz error ;it wasn't caused by our board, exit + out dx,al + clc + ret +error: + stc + ret + +AckIrq ENDP + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef MWSS + +ResetCard PROC USES EBX + + + mov ax, word ptr[PlayRate] + cmp ax, 44100 + jae short Freq44 + lea edx, MWSSFreq +SearchFreq: cmp ax, word ptr[edx] + jb short FoundFreq + add edx, 4 + jmp short SearchFreq +Freq44: + mov ax, 44100 + mov cl, 0Bh + jmp short WBack +FoundFreq: + mov ax, word ptr[edx] ; closest faster speed + mov cl, byte ptr[edx+2] ; clock select +WBack: + mov word ptr[PlayRate], ax + or cl, 01010000b ; 16 bit linear, Stereo + + mov edx, [IRQ_number] ; IRQ + mov al, [MWSSIrq+edx] + + mov edx, [DMA_number] ; DMA + or al, [MWSSDma+edx] + + mov dx, word ptr[BASE_ADDR] + + add dl, 3 ; offset 3 + out dx, al ; program IRQ & DMA + + inc dl ; offset 4 + mov al, 6 ; left vol + out dx, al + inc dl ; offset 5 + mov al, 80h ; mute + out dx, al + dec dl ; offset 4 + mov al, 7 ; right vol + out dx, al + inc dl ; offset 5 + mov al, 80h ; mute + out dx, al + + dec dl ; offset 4 + mov al, 13 ; digital mix + out dx, al + inc dl ; offset 5 + xor al, al ; mute + out dx, al + + dec dl ; offset 4 + mov al, 2 ; left aux1 + out dx, al + inc dl ; offset 5 + mov al, 80h ; mute + out dx, al + dec dl ; offset 4 + mov al, 3 ; right aux1 + out dx, al + inc dl ; offset 5 + mov al, 80h ; mute + out dx, al + + dec dl ; offset 4 + mov al, 4 ; left aux2 + out dx, al + inc dl ; offset 5 + mov al, 80h ; mute + out dx, al + dec dl ; offset 4 + mov al, 5 ; right aux2 + out dx, al + inc dl ; offset 5 + mov al, 80h ; mute + out dx, al + + dec dl ; offset 4 + mov al, 49h ; enter MCE, Interface Ctrl + out dx, al + inc dl ; offset 5 + mov al, 08h ; auto-calibrate + out dx, al + + dec dl ; offset 4 + mov al, 48h ; MCE, Interface Ctrl + out dx, al + inc dl ; offset 5 + mov al, cl ; 16 bit linear, stereo, speed + out dx, al + + dec dl ; offset 4 +wait_init: in al, dx + and al, 80h + jnz wait_init + + + xor al, al + out dx, al ; clear MCE + + xor bx, bx ; at least 6 millisec. +wait0: in al, dx + dec bx + jnz short wait0 + + +wait_cal: mov al, 0Bh ; Test & Init Reg + out dx, al + inc dl ; offset 5 + in al, dx + dec dl ; offset 4 + and al, 20h + jnz wait_cal + + mov al, 6 ; left vol + out dx, al + inc dl ; offset 5 + xor al, al ; max vol + out dx, al + dec dl ; offset 4 + mov al, 7 ; right vol + out dx, al + inc dl ; offset 5 + xor al, al ; max vol + out dx, al + + ret + +ResetCard ENDP + +;*--------------------------------------------------------------------------* + +CloseCard PROC + + mov dx, word ptr[BASE_ADDR] ; DSP + + add dl, 4 ; offset 4 + mov al, 0Ah ; Pin Ctrl reg + out dx, al + inc dx ; offset 5 + xor al, al ; turn off interrupts + out dx, al + + inc dx ; offset 6 + out dx, al ; Ack outstanding interrupts + + sub dl, 2 ; offset 4 + mov al, 9 ; Interface Config reg + out dx, al + inc dx ; offset 5 + xor al, al ; turn off codec DMA + out dx, al + + sub dl, 2 + out dx, al ; deselect IRQ and DMA + + ret + +CloseCard ENDP + +;---------------------------------------------------------------------------- + +AckIrq PROC + + mov dx, word ptr[BASE_ADDR] ; DSP + add dl, 6 + in al, dx + shr al, 1 ; get int flag in C + cmc ; complement C in order to return error if 0 + out dx, al ; Ack anyway + ret + +AckIrq ENDP + +;---------------------------------------------------------------------------- + +StartDMACard PROC + + mov cx, BUFFER_SIZE - 1 + + mov dx, word ptr[BASE_ADDR] ; DSP + + add dl, 6 + out dx, al ; clear any pending IRQ + + sub dl, 2 ; offset 4 + mov al, 15 ; DMA Count Lower + out dx, al + inc dl ; offset 5 + mov al, cl + out dx, al + dec dl ; offset 4 + mov al, 14 ; DMA Count Upper + out dx, al + inc dl ; offset 5 + mov al, ch + out dx, al + + dec dl ; offset 4 + mov al, 9 ; Interface config + out dx, al + inc dl ; offset 5 + mov al, 00000101b ; DMA Playback + out dx, al + dec dl ; offset 4 + mov al, 0Ah ; Pin Ctrl Reg + out dx, al + inc dx ; offset 5 + mov al, 00000010b ; Turn on Interrupts + out dx, al + + ret + +StartDMACard ENDP + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef SBLASTER + +WRITE_DSP MACRO VAL ; write to DSP whithout timeout + local wait_dsp + +wait_dsp: in al, dx + or al, al + js wait_dsp + + mov al, VAL + out dx, al + + ENDM + +WRITE_MIXER MACRO REG, VAL ; write to MIXER chip + + mov al, REG + out dx, al + inc dx + mov al, VAL + out dx, al + dec dx + + ENDM + +READ_MIXER MACRO REG ; read from MIXER chip + + mov al, REG + out dx, al + inc dx + in al, dx + dec dx + + ENDM + +ifdef SBPRO + +InitIRQ PROC + + pushad + push ds + + mov ax, cs:word ptr[local_DS] ; restore DS + mov ds, ax + + mov al, 20h ; allows for new int + cmp byte ptr[IRQ_number], 7 + jbe short NoSecondCtrl + out 0A0h, al +NoSecondCtrl: out 20h, al + + call AckIrq + jc short FinIRQ ; not a DMA IRQ + + mov byte ptr[OkIRQ], 1 +FinIRQ: + pop ds + popad + + iretd + +InitIRQ ENDP + +endif + + +ResetCard PROC + + cmp dword ptr[PlayRate], 12000 + jae OkRateLow + mov dword ptr[PlayRate], 12000 +OkRateLow: + + cmp dword ptr[PlayRate], 22000 + jbe OkRateHigh + mov dword ptr[PlayRate], 22000 +OkRateHigh: + +ifndef SB16 + ifdef SBPRO + mov dx, 07A1h + mov ax, 2000h ; dx:ax = 128000000 + else + mov dx, 0F42h + mov ax, 4000h ; dx:ax = 256000000 + endif + div word ptr[PlayRate] ; divide by PlayRate + neg ax + shr ax, 8 + mov cx, ax ; cl = "Magic" + + push ecx + + ifdef SBPRO + mov dx, 07h + mov ax, 0A120h ; dx:ax = 500000 + else + mov dx, 0Fh + mov ax, 4240h ; dx:ax = 1000000 + endif + neg cl + div cx ; divide by "-Magic" + mov word ptr[PlayRate], ax ; write back PlayRate +endif + + mov dx, word ptr[BASE_ADDR] + add dl, 6 ; reset port (offset 6) + mov al, 1 ; write 1 + out dx, al + + mov ah, 8 * 3 ; 4 * "in al, dx" = 1 microsec on std ISA bus (8 Mhz) +wait_io: in al, dx ; so 8 to be sure if 16 MHz ! + dec ah ; kill the cat ! + jnz short wait_io + + xor al, al + out dx, al ; write 0 + ; now reset should be done.. + add dl, 4 ; offset 0Ah + +Next: add dl, 4 ; offset 0Eh + +Wait_s: in al, dx + or al, al + jns Wait_s + + sub dl, 4 ; offset 0Ah + in al, dx ; read if reset terminated + + cmp al, RESET_TEST_CODE ; should be... + jne Next + +ifdef SB16 + sub dl, 6 ; offset 04h + mov al, 80h + out dx, al + inc dx ; offset 05h + xor eax, eax + in al, dx + and al, 0Fh ; mask reserved bit + bsf ax, ax + mov al, byte ptr[SB16_IRQ+eax] + mov dword ptr[IRQ_number], eax + dec dx ; offset 04h + mov al, 81h + out dx, al + inc dx ; offset 05h + in al, dx + and al, 11101011b ; mask reserved bit + ifdef SAMPLE16BIT + bsr ax, ax + else + bsf ax, ax + endif + mov dword ptr[DMA_number], eax + + add dl, 7 ; offset 0Ch + WRITE_DSP DSP_RATE_CMD ; rate + mov cx, word ptr[PlayRate] + WRITE_DSP ch ; + WRITE_DSP cl ; +else + add dl, 02h ; offset 0Ch + WRITE_DSP DSP_ONSPK_CMD ; Turn speaker on + + ifdef SBPRO + + mov edx, offset InitIRQ ; Temporary IRQ handler + call InstallISR + + mov dx, word ptr[BASE_ADDR] + + add dl, 4 ; offset 4 + mov al, 0Eh ; stereo switch & filter + out dx, al + inc dx ; offset 5 + in al, dx + or al, 2 ; enable stereo + out dx, al + + mov ecx, dword ptr[DMA] ; Point to DMAx + + mov dx, word ptr[ecx + MASK_REG] + mov al, byte ptr[ecx + MASK2] ; mask channel + out dx, al + + mov dx, word ptr[ecx + FF_REG] + out dx, al ; flip-flop + + + mov dx, word ptr[ecx + COUNT_REG] + xor al, al + out dx, al + out dx, al + + mov eax, dword ptr[BUFFER_DMA] ; start offset + mov byte ptr[eax], 80h ; write a "0" into the buffer + + mov dx, word ptr[ecx + ADDX_REG] + out dx, al + shr eax, 8 + out dx, al + + mov dx, word ptr[ecx + PAGE_REG] + shr eax, 8 ; page of DMA transfert + out dx, al + + mov dx, word ptr[ecx + MODE_REG] + mov al, byte ptr[ecx + VOICE_OUT] ; output sample + out dx, al + + mov dx, word ptr[ecx + MASK_REG] + mov al, byte ptr[ecx + MASK1] ; channel OK + out dx, al + + mov dx, word ptr[BASE_ADDR] + add dl, 0Ch ; offset 0Ch + + mov byte ptr[OkIRQ], 0 + + WRITE_DSP DSP_VO8S_CMD + WRITE_DSP 0 + WRITE_DSP 0 + +WaitIRQ: cmp byte ptr[OkIRQ], 1 + jne short WaitIRQ + + sub dl, 8 ; offset 4 + mov al, 0Eh ; stereo switch & filter + out dx, al + inc dx ; offset 5 + in al, dx + mov byte ptr[Filter], al + or al, 20h ; disable filter + out dx, al + add dl, 7 ; offset 0Ch + endif + + pop ecx + + WRITE_DSP DSP_TIME_CMD ; "rate" + WRITE_DSP cl ; magic number ! + +endif + ret + +ResetCard ENDP + +;*--------------------------------------------------------------------------* + +CloseCard PROC + + mov dx, word ptr[BASE_ADDR] ; point to DSP + +ifdef SB16 + add dl, 0CH +ifdef SAMPLE16BIT + WRITE_DSP DSP_VO16S_CMD ; single-cycle 16 bit DMA + ifdef STEREO + WRITE_DSP DSP_16STEREO_MODE ; 16 bit stereo + else + WRITE_DSP DSP_16MONO_MODE ; 16 bit mono + endif +else + WRITE_DSP DSP_VO8S_4_CMD ; single-cycle 8 bit DMA + ifdef STEREO + WRITE_DSP DSP_8STEREO_MODE ; 8 bit stereo + else + WRITE_DSP DSP_8MONO_MODE ; 8 bit mono + endif +endif + WRITE_DSP 0 ; length of 1 to finish + WRITE_DSP 0 +else + ifdef SBPRO + add dl, 6 ; reset port (offset 6) + mov al, 1 ; write 1 + out dx, al + + mov ah, 8 * 3 ; 4 * "in al, dx" = 1 microsec on std ISA bus (8 Mhz) +wait_io: in al, dx ; so 8 to be sure if 16 MHz ! + dec ah ; kill the cat ! + jnz wait_io + + xor al, al + out dx, al ; write 0 + ; now reset should be done.. + add dl, 4 ; offset 0Ah + +Next: add dl, 4 ; offset 0Eh + +Wait_s: in al, dx + or al, al + jns Wait_s + + sub dl, 4 ; offset 0Ah + in al, dx ; read if reset terminated + + cmp al, RESET_TEST_CODE ; should be... + jne Next + + sub dl, 6 ; offset 4 + mov al, 0Eh + out dx, al + inc dx ; offset 5 + mov al, byte ptr[Filter] ; restore filter + out dx, al + + dec dx + mov al, 0Eh + out dx, al + inc dx ; offset 5 + in al, dx + and al, 11111101b ; turn off stereo + out dx, al + + add dl, 7 ; offset 0Ch + WRITE_DSP DSP_OFFSPK_CMD ; Turn speaker off + + else + + add dl, 0CH + WRITE_DSP DSP_OFFSPK_CMD ; Turn speaker off + WRITE_DSP DSP_VO8S_CMD ; single-cycle 8 bit DMA + WRITE_DSP 0 ; length of 1 to finish + WRITE_DSP 0 + + endif +endif + + ret + +CloseCard ENDP + +;---------------------------------------------------------------------------- + +AckIrq PROC + + mov dx, word ptr[BASE_ADDR] ; DSP IRQ ACK +ifdef SB16 + add dl, 4 ; offset 4 + mov al, 82h + out dx, al + inc dx ; offset 5 + in al, dx + ifdef SAMPLE16BIT + and al, 2 + jz NoDMAIRQ + add dl, 10 ; offset Fh + else + and al, 1 + jz NoDMAIRQ + add dl, 9 ; offset Eh + endif + in al, dx + ret +NoDMAIRQ: + stc + ret +else + +irq_ok: add dl, 0Eh ; 8 bit Samples ACK + in al, dx +not_real: + ret +endif + +AckIrq ENDP + +;---------------------------------------------------------------------------- + +StartDMACard PROC + + mov dx, word ptr[BASE_ADDR] ; DSP + add dl, 0Ch + +ifdef STEREO + mov cx, BUFFER_SIZE * 2 - 1 ; half-buffer size - 1 for DMA +else + mov cx, BUFFER_SIZE - 1 ; half-buffer size - 1 for DMA +endif + +ifdef SB16 + + +ifdef SAMPLE16BIT + WRITE_DSP DSP_VO16_CMD ; auto-init 16 bit DMA + ifdef STEREO + WRITE_DSP DSP_16STEREO_MODE ; 16 bit stereo + else + WRITE_DSP DSP_16MONO_MODE ; 16 bit mono + endif +else + WRITE_DSP DSP_VO8_4_CMD ; auto-init 8 bit DMA + ifdef STEREO + WRITE_DSP DSP_8STEREO_MODE ; 8 bit stereo + else + WRITE_DSP DSP_8MONO_MODE ; 8 bit mono + endif +endif + WRITE_DSP cl + WRITE_DSP ch + +elseifdef SBLASTER1 + + WRITE_DSP DSP_VO8S_CMD ; single-cycle 8 bit DMA + WRITE_DSP cl + WRITE_DSP ch + +else + + WRITE_DSP DSP_BSIZE_CMD ; Set block size + WRITE_DSP cl + WRITE_DSP ch + + ifdef SBPRO + WRITE_DSP DSP_VO8H_CMD ; auto-init 8 bit high-speed DMA + else + WRITE_DSP DSP_VO8_CMD ; auto-init 8 bit DMA + endif +endif + ret + +StartDMACard ENDP + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef GOLD + +SELECT_MIXER MACRO + local wait + + cli + + mov al, 0FFh + out dx, al + out dx, al +wait: in al, dx + and al, 11000000b + jnz wait + + ENDM + +LEAVE_MIXER MACRO + local wait + +wait: in al, dx + and al, 11000000b + jnz wait + mov al, 0FEh + out dx, al + out dx, al + + sti + + ENDM + +WRITE_MIXER MACRO PORT, VAL + local wait1, wait2 + + cli + + mov al, PORT + out dx, al +wait1: in al, dx + and al, 11000000b + jnz wait1 + inc dx + mov al, VAL + out dx, al + dec dx +wait2: in al, dx + and al, 11000000b + jnz wait2 + + sti + + ENDM + +READ_MIXER MACRO PORT + local wait1, wait2 + + cli + + mov al, PORT + out dx, al +wait1: in al, dx + and al, 11000000b + jnz wait1 + inc dx + in al, dx + dec dx + mov ah, al +wait2: in al, dx + and al, 11000000b + jnz wait2 + mov al, ah + + sti + + ENDM + +WRITE_MMA0 MACRO PORT, VAL + + cli + + mov al, PORT + out dx, al + inc dx + mov al, VAL + out dx, al + dec dx + in al, dx + in al, dx + + sti + + ENDM + +READ_MMA0 MACRO PORT + + cli + + mov al, PORT + out dx, al + inc dx + in al, dx + dec dx + mov ah, al + in al, dx + in al, dx + mov al, ah + + sti + + ENDM + +WRITE_MMA1 MACRO PORT, VAL + + cli + + mov al, PORT + out dx, al + add dx, 3 + mov al, VAL + out dx, al + sub dx, 3 + in al, dx + in al, dx + + sti + + ENDM + +READ_MMA1 MACRO PORT + + cli + + mov al, PORT + out dx, al + add dx, 3 + in al, dx + sub dx, 3 + mov ah, al + in al, dx + in al, dx + mov al, ah + + sti + + ENDM + + +;*--------------------------------------------------------------------------* + +ResetCard PROC + + mov dx, word ptr[BASE_ADDR] + add dx, 2 ; MIXER + + SELECT_MIXER + + WRITE_MIXER 8h, 11001110b ; STEREO mode + WRITE_MIXER 11h, 00001000b ; filter on output, no mic input, no PC-speaker input + + READ_MIXER 13h + + mov byte ptr[Mixer_13], al + + mov cl, al + + and eax, 3 + lea ebx, Gold_IRQ + mov al, byte ptr[ebx+eax] + mov dword ptr[IRQ_number], eax + + mov al, cl + shr al, 4 + and al, 3 + mov dword ptr[DMA_number], eax + + or cl, 10001000b ; enable DMA0, enable IRQ + WRITE_MIXER 13h, cl + + READ_MIXER 14h + + mov byte ptr[Mixer_14], al + + mov cl, al + and cl, 01111111b + WRITE_MIXER 14h, cl + + LEAVE_MIXER + + add dx, 2 ; MMA + + WRITE_MMA0 9, 80h ; reset channel 0 + WRITE_MMA1 9, 80h ; reset channel 1 + + mov cx, 4 +fillFIFO0: WRITE_MMA0 0Bh, 0 + dec cx + jnz FillFIFO0 + + mov cx, 4 +fillFIFO1: WRITE_MMA1 0Bh, 0 + dec cx + jnz FillFIFO1 + + WRITE_MMA0 9, 00101110b ; 22.05 Khz, PCM, L, Play + WRITE_MMA1 9, 01001110b ; 22.05 Khz, PCM, R, Play + + mov word ptr[PlayRate], 22050 ; 22.05 Khz + + WRITE_MMA0 0Ch, 11000101b ; Interleave, 16 bit, 96 byte FIFO, DMA + WRITE_MMA1 0Ch, 01000011b ; 16 bit, no FIFO (use other channel), DMA + + + WRITE_MMA0 0Ah, 0FFh ; Maximum volume (volume will be controlled by mixer) + WRITE_MMA1 0Ah, 0FFh + + mov cx, 100 +fillFIFO: WRITE_MMA0 0Bh, 0 + dec cx + jnz FillFIFO + + ret + +ResetCard ENDP + +;*--------------------------------------------------------------------------* + +CloseCard PROC + + mov dx, word ptr[BASE_ADDR] + add dx, 4 ; MMA + + WRITE_MMA1 0Ch, 01000010b ; 16 bit, no FIFO, no DMA + WRITE_MMA0 0Ch, 01000010b ; 16 bit, no FIFO, no DMA + + WRITE_MMA0 9, 80h ; reset channel 0 + WRITE_MMA1 9, 80h ; reset channel 1 + + sub dx, 2 ; MIXER + + SELECT_MIXER + + WRITE_MIXER 13h, Mixer_13 + WRITE_MIXER 14h, Mixer_14 + + LEAVE_MIXER + + ret + +CloseCard ENDP + +;---------------------------------------------------------------------------- + +AckIrq PROC + + mov dx, word ptr[BASE_ADDR] + add dx, 4 ; MMA + + in al, dx + and al, 1 + jz short noDMA + + mov ebx, dword ptr[DMA] ; Point to DMAx + + mov dx, word ptr[ebx + FF_REG] + out dx, al ; flip-flop + + mov dx, word ptr[ebx + COUNT_REG] + in al, dx + mov ah, al + in al, dx + xchg al, ah + + or ax, ax + jz short OkDMA + inc ax + jnz short noDMA +OkDMA: + clc + ret +NoDMA: + stc +not_real: + ret + +AckIrq ENDP + +;---------------------------------------------------------------------------- + +StartDMACard PROC + + mov dx, word ptr[BASE_ADDR] + add dx, 4 ; MMA + + WRITE_MMA0 9, 00101111b ; 22.05 Khz, PCM, L, Play, GO + + ret + +StartDMACard ENDP + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef GUS + +extrn Nolanguage resetcard:PROC + +;*--------------------------------------------------------------------------* + +extrn Nolanguage CloseCard:PROC + +;*--------------------------------------------------------------------------* + +extrn Nolanguage StartDMACard:PROC + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + + END diff --git a/LIB386/LIB_SAMP/WAVE_A.LST b/LIB386/LIB_SAMP/WAVE_A.LST new file mode 100644 index 0000000..4d6969b --- /dev/null +++ b/LIB386/LIB_SAMP/WAVE_A.LST @@ -0,0 +1,6190 @@ +Microsoft (R) Macro Assembler Version 6.1a 09/22/94 16:09:36 +wave_a.asm Page 1 - 1 + + + ;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + ; SAMP_A.ASM 386 + ; (c) Adeline 1993 + ;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + + ;*---------------------------------------------- + ----------------------------* + + include wave.inc + C ;*---------------------------------------------- + C ----------------------------* + C + C ;DEBUG equ 1 + C + = 1234 C VOICE_HANDLE equ 1234h + C + C IFDEF SB16 + C + = 0001 C SBLASTER equ 1 + C ; it is also a SBLASTER ! + C + C ENDIF + C + C IFDEF SBPRO + C + C SBLASTER equ 1 + C ; it is also a SBLASTER ! + C STEREO equ 1 + C + C ENDIF + C + C IFDEF SBLASTER1 + C + C SBLASTER equ 1 + C ; it is also a SBLASTER ! + C SINGLE_DMA equ 1 + C ; use DMA (no auto-reinit on the SB ver + C 1.00-1.99) + C + C ELSEIFDEF SBLASTER + C + = 0001 C AUTO_DMA equ 1 + C ; use auto_reinit DMA (faster and cleane + C r) + C + C ENDIF + C + C IFDEF MWSS + C + C SAMPLE16BIT equ 1 + C STEREO equ 1 + C AUTO_DMA equ 1 + C ; use auto_reinit DMA (faster and cleane + C r) + C + C ENDIF + C + C IFDEF GOLD + C + C SAMPLE16BIT equ 1 + C STEREO equ 1 + C SINGLE_DMA equ 1 + C ; use DMA (no counter on the card) + C + C ENDIF + C + C IFDEF GUS + C + C AUTO_DMA equ 1 + C ; use auto_reinit DMA (faster and cleane + C r) + C SAMPLE16BIT equ 1 + C STEREO equ 1 + C NOIRQ equ 1 + C + C ENDIF + C + C ;*---------------------------------------------- + C ----------------------------* + C + C IFDEF SAMPLE16BIT + C IFDEF STEREO + = 0001 C SLONG equ 1 + = 0004 C SSIZE equ 4 + C ELSE + C SUWORD equ 1 + C SSIZE equ 2 + C ENDIF + C ELSE + C IFDEF STEREO + C SUWORD equ 1 + C SSIZE equ 2 + C ELSE + C SCHAR equ 1 + C SSIZE equ 1 + C ENDIF + C ENDIF + C + C ;*---------------------------------------------- + C ----------------------------* + C + = 0400 C BUFFER_SIZE equ 1024 + C ; number of samples + C + C ; in half-buffer + = 0032 C LIST_SIZE equ 50 + = 002C C STRUCT_SIZE equ 44 + = 0008 C SNAP_SIZE equ 8 + C + = 0003 C SHIFT_SAMPLE equ 3 + C ; max number of + C + C ; samples mixed + C + C ;*---------------------------------------------- + C ----------------------------* + C + + ;*---------------------------------------------- + ----------------------------* + + MIDPOINT MACRO + + IFDEF SAMPLE16BIT + xor eax, eax + ELSE + mov eax, 80808080h + ENDIF + + ENDM + + ;*---------------------------------------------- + ----------------------------* + + .386 + jumps + + .model FLAT, SYSCALL + + 0000 .CODE + + + ;*---------------------------------------------- + ----------------------------* + + PUBLIC driver_start + + 0000 000000A0 R driver_start dd OFFSET ListFuncs + + IFDEF SB16 + 0004 53 6F 75 6E 64 20 db 'Sound Blaster 16 (DSP 4 + 42 6C 61 73 74 .XX)' + 65 72 20 31 36 + 20 28 44 53 50 + 20 34 2E 58 58 + 29 + + ELSEIFDEF SBPRO + db 'Sound Blaster Pro (DSP + 3.XX)' + + ELSEIFDEF SBLASTER1 + db 'Sound Blaster 2 (DSP 2. + 01+)' + + ELSEIFDEF SBLASTER + db 'Sound Blaster (DSP 1.00 + -2.00)' + + ELSEIFDEF MWSS + db 'Microsoft Windows Sound + System (AD1848 SoundPort)' + + ELSEIFDEF GOLD + db 'Adlib Gold (Yamaha GOLD + )' + + ELSEIFDEF GUS + db 'Advanced Gravis UltraSo + und' + ENDIF + + 001F 20 57 61 76 65 20 db ' Wave Driver,', 13, 10 + 44 72 69 76 65 + 72 2C 0D 0A + + IFDEF SAMPLE16BIT + 002E 31 36 20 62 69 74 db '16 bit' + ELSE + db '8 bit' + ENDIF + IFDEF STEREO + 0034 20 53 74 65 72 65 db ' Stereo' + 6F + ELSE + db ' Mono' + ENDIF + IFDEF SURROUND + db ' Surround' + ENDIF + + 003B 20 70 6C 61 79 62 db ' playback, Version 1.00 + 61 63 6B 2C 20 .', 13, 10 + 56 65 72 73 69 + 6F 6E 20 31 2E + 30 30 2E 0D 0A + IFDEF GUS + db 'Copyright (C) 1991,1992 + Miles Design, Inc.', 0Dh, 0Ah + db 'Copyright (C) 1993,1994 + Advanced Gravis Computer ' + db 'Technology Ltd. All rig + hts reserved.', 0Dh, 0Ah + db 'Copyright (C) 1992,1993 + ,1994 Forte Technologies.', 0Dh, 0Ah + db 'Copyright (C) 1994 Adel + ine Software International.', 0Dh, 0Ah + db 'All rights reserved.', + 0Dh, 0Ah + db 'UltraSound conversion b + y Jayeson Lee-Steere.', 0Dh, 0Ah + db 'Adeline Software conver + sion by Serge Plagnol.', 0Dh, 0Ah + db 'MIDI and Digital sound + library by Forte.', 0Dh, 0Ah, 0Ah, 0 + ELSE + 0055 43 6F 70 79 72 69 db 'Copyright (c) Adeline S + 67 68 74 20 28 oftware International 1994, All Rights Reserved. + 63 29 20 41 64 ', 13, 10, 10, 0 + 65 6C 69 6E 65 + 20 53 6F 66 74 + 77 61 72 65 20 + 49 6E 74 65 72 + 6E 61 74 69 6F + 6E 61 6C 20 31 + 39 39 34 2C 20 + 41 6C 6C 20 52 + 69 67 68 74 73 + 20 52 65 73 65 + 72 76 65 64 2E + 0D 0A 0A 00 + ENDIF + + 00A0 00002FED R ListFuncs dd offset InitCard + 00A4 00003177 R dd offset ClearCard + + 00A8 000031F4 R dd offset AskVars + + 00AC 00002D21 R dd offset MixSample + 00B0 00003213 R dd offset GiveSampleInfo0 + + 00B4 00002A31 R dd offset StopSample + 00B8 00002A91 R dd offset StopOneSample + + 00BC 00002C27 R dd offset SampleInList + 00C0 00003268 R dd offset GetSnapSample + + 00C4 00002F07 R dd offset PauseSample + 00C8 00002F5C R dd offset ContinueSample + + 00CC 00003307 R dd offset SaveStateSample + 00D0 000033A1 R dd offset RestoreStateSamp + le + + 00D4 000025F3 R dd offset GetDMAAddr + + 00D8 0000320D R dd offset GetBufferSize + + 00DC 00002CBE R dd offset ChangeVolume + + 00E0 00002B2D R dd offset ShiftSamples + + 00E4 00002BB9 R dd offset StopOneSampleLon + g + + ;*---------------------------------------------- + ----------------------------* + + = 0000 ADDRESS equ 0 + = 0004 FRACT equ 4 + = 0008 LEFT equ 8 + = 000C C_REPEAT equ 12 + = 000E INCR equ 14 + = 0010 SON equ 16 + = 0014 HANDLE equ 20 + = 0018 START equ 24 + = 001C DLENGTH equ 28 + = 0020 VOL_LEFT equ 32 + = 0022 VOL_RIGHT equ 34 + = 0024 INFO0 equ 36 + = 0028 INTERPOL equ 40 + = 0029 LAST_SAMPLE equ 41 + + ;*---------------------------------------------- + ----------------------------* + + = 0014 DSP_VO8S_CMD equ 14h + = 001C DSP_VO8_CMD equ 1Ch + = 0040 DSP_TIME_CMD equ 40h + = 0041 DSP_RATE_CMD equ 41h + = 0048 DSP_BSIZE_CMD equ 48h + = 0090 DSP_VO8H_CMD equ 90h + = 00B0 DSP_VO16S_CMD equ 0B0h + = 00B6 DSP_VO16_CMD equ 0B6h + = 00C0 DSP_VO8S_4_CMD equ 0C0h + = 00C6 DSP_VO8_4_CMD equ 0C6h + = 00D1 DSP_ONSPK_CMD equ 0D1h + = 00D3 DSP_OFFSPK_CMD equ 0D3h + + = 0010 DSP_16MONO_MODE equ 10h + = 0030 DSP_16STEREO_MODE equ 30h + = 0000 DSP_8MONO_MODE equ 00h + = 0020 DSP_8STEREO_MODE equ 20h + + = 00AA RESET_TEST_CODE equ 0AAh + + + ;*---------------------------------------------- + ----------------------------* + + ifndef NOIRQ + + = 0000 VOICE_OUT equ 0 ; equ to + access the 2 arrays below + = 0001 AUTO_OUT equ 1 + = 0002 MASK1 equ 2 + = 0003 MASK2 equ 3 + + = 0004 ADDX_REG equ 4 + = 0006 COUNT_REG equ 6 + = 0008 MASK_REG equ 8 + = 000A MODE_REG equ 10 + = 000C FF_REG equ 12 + = 000E PAGE_REG equ 14 + + + 00E8 = 00E8 DMA0 equ $ ; Ports + for DMA0 + + 00E8 48 DMA0_VOICE_OUT db 48H + 00E9 58 DMA0_AUTO_OUT db 58H + 00EA 00 DMA0_MASK1 db 00H + 00EB 04 DMA0_MASK2 db 04H + + 00EC 0000 DMA0_ADDX_REG dw 00H + 00EE 0001 DMA0_COUNT_REG dw 01H + 00F0 000A DMA0_MASK_REG dw 0AH + 00F2 000B DMA0_MODE_REG dw 0BH + 00F4 000C DMA0_FF_REG dw 0CH + 00F6 0087 DMA0_PAGE_REG dw 87H + + + 00F8 = 00F8 DMA1 equ $ ; Ports + for DMA1 + + 00F8 49 DMA1_VOICE_OUT db 49H + 00F9 59 DMA1_AUTO_OUT db 59H + 00FA 01 DMA1_MASK1 db 01H + 00FB 05 DMA1_MASK2 db 05H + + 00FC 0002 DMA1_ADDX_REG dw 02H + 00FE 0003 DMA1_COUNT_REG dw 03H + 0100 000A DMA1_MASK_REG dw 0AH + 0102 000B DMA1_MODE_REG dw 0BH + 0104 000C DMA1_FF_REG dw 0CH + 0106 0083 DMA1_PAGE_REG dw 83H + + + 0108 = 0108 DMA3 equ $ ; Ports + for DMA3 + + 0108 4B DMA3_VOICE_OUT db 4BH + 0109 5B DMA3_AUTO_OUT db 5BH + 010A 03 DMA3_MASK1 db 03H + 010B 07 DMA3_MASK2 db 07H + + 010C 0006 DMA3_ADDX_REG dw 06H + 010E 0007 DMA3_COUNT_REG dw 07H + 0110 000A DMA3_MASK_REG dw 0AH + 0112 000B DMA3_MODE_REG dw 0BH + 0114 000C DMA3_FF_REG dw 0CH + 0116 0082 DMA3_PAGE_REG dw 82H + + + 0118 = 0118 DMA5 equ $ ; Ports + for DMA5 + + 0118 49 DMA5_VOICE_OUT db 49H + 0119 59 DMA5_AUTO_OUT db 59H + 011A 01 DMA5_MASK1 db 01H + 011B 05 DMA5_MASK2 db 05H + + 011C 00C4 DMA5_ADDX_REG dw 0C4H + 011E 00C6 DMA5_COUNT_REG dw 0C6H + 0120 00D4 DMA5_MASK_REG dw 0D4H + 0122 00D6 DMA5_MODE_REG dw 0D6H + 0124 00D8 DMA5_FF_REG dw 0D8H + 0126 008B DMA5_PAGE_REG dw 08BH + + 0128 = 0128 DMA6 equ $ ; Ports + for DMA6 + + 0128 4A DMA6_VOICE_OUT db 4AH + 0129 5A DMA6_AUTO_OUT db 5AH + 012A 02 DMA6_MASK1 db 02H + 012B 06 DMA6_MASK2 db 06H + + 012C 00C8 DMA6_ADDX_REG dw 0C8H + 012E 00CA DMA6_COUNT_REG dw 0CAH + 0130 00D4 DMA6_MASK_REG dw 0D4H + 0132 00D6 DMA6_MODE_REG dw 0D6H + 0134 00D8 DMA6_FF_REG dw 0D8H + 0136 0089 DMA6_PAGE_REG dw 089H + + 0138 = 0138 DMA7 equ $ ; Ports + for DMA7 + + 0138 4B DMA7_VOICE_OUT db 4BH + 0139 5B DMA7_AUTO_OUT db 5BH + 013A 03 DMA7_MASK1 db 03H + 013B 07 DMA7_MASK2 db 07H + + 013C 00CC DMA7_ADDX_REG dw 0CCH + 013E 00CE DMA7_COUNT_REG dw 0CEH + 0140 00D4 DMA7_MASK_REG dw 0D4H + 0142 00D6 DMA7_MODE_REG dw 0D6H + 0144 00D8 DMA7_FF_REG dw 0D8H + 0146 008A DMA7_PAGE_REG dw 08AH + + ALIGN 4 + + 0148 000000E8 R TAB_DMA dd offset DMA0 + 014C 000000F8 R dd offset DMA1 + 0150 00000000 dd 0 + 0154 00000108 R dd offset DMA3 + 0158 00000000 dd 0 + 015C 00000118 R dd offset DMA5 + 0160 00000128 R dd offset DMA6 + 0164 00000138 R dd offset DMA7 + + endif + + ;*---------------------------------------------- + ----------------------------* + + 0168 0898 [ CurrentList db STRUCT_SIZE*LIST + 00 _SIZE dup (?) + ] + 0A00 0898 [ SonList db STRUCT_SIZE*LIST + 00 _SIZE dup (?) + ] + + 1298 0898 [ BackCurrentList db STRUCT_SIZE*LIST + 00 _SIZE dup (?) + ] + 1B30 0898 [ BackSonList db STRUCT_SIZE*LIST + 00 _SIZE dup (?) + ] + + 23C8 0190 [ SnapList db SNAP_SIZE*LIST_S + 00 IZE dup (?) + ] + + 2558 00 IRQ_mask db ? + + 2559 00 FlagPause db 0 + + 255A 57 61 76 65 42 61 WaveBase db 'WaveBase',0 + 73 65 00 + 2563 57 61 76 65 49 52 WaveIRQ db 'WaveIRQ',0 + 51 00 + 256B 57 61 76 65 44 4D WaveDMA db 'WaveDMA',0 + 41 00 + 2573 57 61 76 65 52 61 WaveRate db 'WaveRate' + 74 65 + 257B 00 Empty db 0 + + ifdef SBPRO + + OkIRQ db 0 + Filter db ? + + endif + + ifdef GOLD + + Mixer_13 db ? + Mixer_14 db ? + Gold_IRQ db 3, 4, 5, 7, 10, + 11, 12, 15 + endif + + ifdef SB16 + 257C 02 05 07 0A SB16_IRQ db 2, 5, 7, 10 + endif + + EVEN + + ifdef MWSS + + MWSSFreq dw 11025, 3, 16000, + 2, 18900, 5, 22050, 7 + dw 27429, 4, 32000, + 6, 33075, 0dh, 37800, 9 + dw 44100, 0Bh + + MWSSIrq db 0, 0, 010000b, 0 + , 0, 0, 0, 001000b, 0, 010000b + db 011000b, 100000b + , 0, 0, 0, 0 + + MWSSDma db 01b, 10b, 0, 11b + , 0, 0, 0, 0 + + endif + + 2580 0000 Critical dw ? + 2582 0000 DoUpdate dw ? + + 2584 0000 Old_RIRQ_Seg dw ? + 2586 0000 Old_PIRQ_Sel dw ? + 2588 0000 Old_18_Sel dw ? + 258A 0000 Old_RIRQ_Off dw ? + + ALIGN 4 + + 258C 00000000 Old_PIRQ_Off dd ? + 2590 00000000 Old_18_Off dd ? + + ifdef GOLD + + ListNames dd offset WaveBase + dd offset Empty + + elseifdef SB16 + + 2594 0000255A R ListNames dd offset WaveBase + 2598 00002573 R dd offset WaveRate + 259C 0000257B R dd offset Empty + + elseifdef GUS + + ListNames dd offset WaveRate + dd offset Empty + + else + + ListNames dd offset WaveBase + dd offset WaveRate + dd offset WaveIRQ + dd offset WaveDMA + dd offset Empty + + endif + + public Nolanguage PlayRate + + 25A0 = 25A0 ListVars equ $ + + ifdef GOLD + + BASE_ADDR dd 388h + ; By default 388h + PlayRate dd 22000 + ; By default 22 Khz + IRQ_number dd ? + ; no default (read card) + DMA_number dd ? + ; no default (read card) + + + elseifdef SBLASTER + + 25A0 00000220 BASE_ADDR dd 220h + ; By default 220h + 25A4 000055F0 PlayRate dd 22000 + ; By default 22 Khz + 25A8 00000005 IRQ_number dd 5 + ; By default 5 + 25AC 00000001 DMA_number dd 1 + ; By default 1 + + elseifdef MWSS + + BASE_ADDR dd 540h + ; By default 540h + PlayRate dd 22000 + ; By default 22 Khz + IRQ_number dd 9 + ; By default 9 + DMA_number dd 1 + ; By default 1 + + elseifdef GUS + + PlayRate dd 22000 + ; By default 22 Khz + + else + + BASE_ADDR dd 0 + ; no default + PlayRate dd 22000 + ; By default 22 Khz + IRQ_number dd 0 + ; no default + DMA_number dd 0 + ; no default + + endif + + 25B0 0000000D INT_number dd 0Dh + ; By default 0Dh + + public Nolanguage BufferHalf + + 25B4 00000000 BufferHalf dd ? + + 25B8 FFFFFFFF follow dd -1 + + 25BC FFFFFFFF backfollow dd -1 + + ifndef NOIRQ + + 25C0 000000F8 R DMA dd offset DMA1 + ; By default DMA1 + + endif + + 25C4 00000000 weirdcount dd ? + 25C8 00000000 backweirdcount dd ? + + 25CC 00000000 TheVolumeR dd ? + 25D0 00000000 TheVolumeL dd ? + + 25D4 00000000 save_1 dd ? + 25D8 00000000 save_2 dd ? + 25DC 00000000 save_3 dd ? + 25E0 00000000 save_4 dd ? + + + public Nolanguage BUFFER_DMA + public Nolanguage CURRENT_BUFFER + + + ifdef RAM_CARD + + BUFFER_DMA dd ? + ; adress of the buffer + + R_BUFFER_CARD dd ? + ; adress of the buffer on the card for Right cha + nnel + MID_R_BUFFER_CARD dd ? + ; adress of the mid buffer for Right channel + + CURRENT_R_BUFFER_CARD dd ? + ; current half for Right channel + + L_BUFFER_CARD dd ? + ; adress of the buffer on the card for Left chan + nel + MID_L_BUFFER_CARD dd ? + ; adress of the mid buffer for Left channel + + CURRENT_L_BUFFER_CARD dd ? + ; current half for Left channel + else + + 25E4 00000000 BUFFER_DMA dd ? + ; adress of the buffer + 25E8 00000000 MID_BUFFER_DMA dd ? + ; adress of the mid buffer + + 25EC 00000000 CURRENT_BUFFER dd ? + ; current half + endif + + ifdef INTERRRUPT + + DMA_COUNT dd ? + DMA_PTR dd ? + + endif + + + ;*---------------------------------------------- + ----------------------------* + + 25F0 Redirector PROC + + 25F0 CD 18 int 18h + 25F2 CF iretd + + 25F3 Redirector ENDP + + ;*---------------------------------------------- + ----------------------------* + + setalc MACRO + + db 0D6h + + ENDM + + + lve MACRO Reg, Exp + + lea Reg, [Exp] + + ENDM + + + ;*---------------------------------------------- + ----------------------------* + + GET_REAL_VECT MACRO + + mov ax, 0200h + int 31h + + ENDM + + + SET_REAL_VECT MACRO + + mov ax, 0201h + int 31h + + ENDM + + GET_PROT_VECT MACRO + + mov ax, 0204h + int 31h + + ENDM + + + SET_PROT_VECT MACRO + + mov ax, 0205h + int 31h + + ENDM + + CRIT_SECT MACRO + ; Enter Critical Section ;-) + + mov word ptr[Critical], 1 + ; tell the IRQ not to update the buffer + + ; we'll take care of it if nescessary O:-) + ENDM + + + END_CRIT_SECT MACRO + ; Exit Critical Section O:-) + local NoUpdate + ; Update buffer if necessary + + ; Dealing with the critical sect + ion flags................ + ; + DO NOT TOUCH !!!! + + mov word ptr[Critical], 0 + ; exit crit. sect. + + ; this way DoUpdate can't change to 1 anymore + cmp word ptr[DoUpdate], 0 + ; IRQ happened ? + je NoUpdate + ; if DopUpdate change to 0 now, we are in deep + + ; shit anyway because we missed one round! + + ; The program won't crash but we'll ear the old + + ; content of half a buffer and also miss half a + buffer + + ; of new data... :-( + mov word ptr[Critical], 1 + ; yes, crit. again, so we don't update twice + + ; because UpdateBuffer is not reentrant + + ; and we don't want to take a chance on crashing + ! + pushad + ; if DoUpdate change to 1 HERE + + ; it means again that we missed one round! + + ; So we play the buffer we are updating! (funny + noise :-( ) + + ; and then will ear half buffer of old data! + call UpdateBuffer + ; do the update + popad + mov word ptr[Critical], 0 + ; exit crit. sect + + ; this way DoUpdate can't change to 1 anymore + mov word ptr[DoUpdate], 0 + ; Update done, so DoUpdate = 0 + NoUpDate: + + + ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !! + !! + + ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE B + UFFER + + ; TAKES MORE THAN 46000 microsec! + + ; (at 33 Mhz one cycle = .03 microsec so 4600 mi + crosec = 1.5 million cycle) + ENDM + + + ;*---------------------------------------------- + ----------------------------* + + 25F3 GetDMAAddr PROC USES EBX + + 25F3 53 * push ebx + 25F4 33 C0 xor eax, eax + + ifndef NOIRQ + + 25F6 8B 1D 000025C0 R mov ebx, dword ptr[DMA] + + 25FC FA cli + + 25FD 66| 8B 53 0E mov dx, word ptr[ebx + PAGE_ + REG] + 2601 EC in al, dx + 2602 C1 E0 10 shl eax, 16 + + 2605 66| 8B 53 0C mov dx, word ptr[ebx + FF_RE + G] + 2609 EE out dx, al + ; Flip-Flop + + 260A 66| 8B 53 04 mov dx, word ptr[ebx + ADDX_ + REG] ; to get offset + + 260E EC in al, dx + 260F 8A E0 mov ah, al + 2611 EC in al, dx + + 2612 FB sti + + 2613 86 C4 xchg al, ah + + 2615 66| 83 3D 000025AC R cmp word ptr[DMA_number], 3 + 03 + 261D 76 07 jbe noadjust + lve eax, eax*2 + 1 + 261F 8D 04 45 00000000 1 lea eax, [eax*2] + 1 + + 2626 noadjust: + endif + ret + 2626 5B * pop ebx + 2627 C3 * ret 00000h + + 2628 GetDMAAddr ENDP + + ;*---------------------------------------------- + ----------------------------* + + ifndef NOIRQ + + 2628 NewIRQ PROC + + 2628 60 pushad + 2629 1E push ds + 262A 06 push es + 262B FC cld + ; DAMN IT !! :-o + + 262C = 262E local_DS equ $+2 + 262C 66| B8 1234 mov ax, 1234h + 2630 66| 8E D8 mov ds, ax + ; restore DS + 2633 66| 8E C0 mov es, ax + ; and ES !!! + + 2636 B0 20 mov al, 20h + ; allows for new int + 2638 80 3D 000025A8 R cmp byte ptr[IRQ_number], 7 + 07 + 263F 76 02 jbe short NoSecondCtrl + 2641 E6 A0 out 0A0h, al + 2643 E6 20 NoSecondCtrl: out 20h, al + + ifndef DEBUG + + 2645 E8 00000EBF call AckIrq + 264A 72 4A jc short FinIRQ + ; not a DMA IRQ + ifdef SINGLE_DMA + call BlockTransfert + ; Normal ACK location + endif + + endif + 264C A1 000025B4 R mov eax, dword ptr[BufferHal + f] + 2651 34 04 xor al, 4 + ; switch half + 2653 A2 000025B4 R mov byte ptr[BufferHalf], al + + ifdef RAM_CARD + mov eax, dword ptr[R_BUFFER_ + CARD+eax]; get current card buffer address + mov dword ptr[CURRENT_R_BUFF + ER_CARD], eax; update CURRENT_BUFFER_CARD + else + 2658 8B 80 000025E4 R mov eax, dword ptr[BUFFER_DM + A+eax] ; get current buffer address + 265E A3 000025EC R mov dword ptr[CURRENT_BUFFER + ], eax ; update CURRENT_BUFFER + endif + + 2663 66| C7 05 00002582 R mov word ptr[DoUpdate], 1 + 0001 ; Time to do the update + + 266C 66| 83 3D 00002580 R cmp word ptr[Critical], 0 + 00 ; crit. sect ? + 2674 75 20 jne FinIRQ + ; yes, don't update yet! + + 2676 66| C7 05 00002580 R mov word ptr[Critical], 1 + 0001 ; just to make jure it case the interrup + t + 267F E8 00000016 call UpdateBuffer + ; happen again before its finished + 2684 66| C7 05 00002580 R mov word ptr[Critical], 0 + 0000 + + 268D 66| C7 05 00002582 R mov word ptr[DoUpdate], 0 + 0000 ; Update done + + ifdef DEBUG + + call AckIrq + jc short FinIRQ + ; not a DMA IRQ + ifdef SINGLE_DMA + call BlockTransfert + ; Normal ACK location + endif + + endif + + 2696 FinIRQ: + 2696 07 pop es + 2697 1F pop ds + 2698 61 popad + + 2699 CF iretd + + 269A NewIRQ ENDP + + endif + + ;*---------------------------------------------- + ----------------------------* + + ifdef GUS + PUBLIC Nolanguage UpdateBu + ffer + PUBLIC Nolanguage DoUpdate + PUBLIC Nolanguage Critical + endif + + ;*---------------------------------------------- + ----------------------------* + + 269A UpdateBuffer PROC + + 269A B8 00000400 mov eax, BUFFER_SIZE + ifdef RAM_CARD + mov edi, dword ptr[BUFFER_DM + A] ; Buffer + else + 269F 8B 3D 000025EC R mov edi, dword ptr[CURRENT_B + UFFER] ; Buffer + endif + 26A5 80 3D 00002559 R cmp byte ptr[FlagPause], 1 + 01 + 26AC 74 10 je short dopause + + 26AE 8D 1D 00000168 R lea ebx, CurrentList + ; Point to List of samples + + 26B4 8B 33 mov esi, dword ptr[ebx] + ; Current Source + 26B6 0B F6 or esi, esi + ; if 0 then empty list + 26B8 0F 85 0000008D jnz process_1st + 26BE dopause: + 26BE B9 00000400 mov ecx, (BUFFER_SIZE * SSIZ + E) / 4 + MIDPOINT + 1 + 1 IFDEF SAMPLE16BIT + 26C3 33 C0 1 xor eax, eax + 1 ELSE + 1 mov eax, 80808080h + 1 ENDIF + 1 + 26C5 F3/ AB rep stosd + + 26C7 EB 6C jmp endfade + + 26C9 exit: + 26C9 A0 00002559 R mov al, byte ptr[FlagPause] + 26CE FE C8 dec al + 26D0 78 6F js reallyexit + + ifdef RAM_CARD + mov edi, dword ptr[BUFFER_DM + A] ; Buffer + else + 26D2 8B 3D 000025EC R mov edi, dword ptr[CURRENT_B + UFFER] ; Buffer + endif + + 26D8 BE 00000400 mov esi, ( BUFFER_SIZE * SSI + ZE ) / 4 + 26DD 66| 0F BD CE bsr cx, si + + 26E1 66| 4E dec si + ; no need to fade first/last sample + + ; since it will be multiplied by 1 + 26E3 FE C8 dec al + 26E5 75 2A jnz short fadeout + + 26E7 BB 00000001 mov ebx, 1 + ; skip 0 + + ifdef SAMPLE16BIT + + 26EC 8B 17 loopfadein: mov edx, dword ptr[edi] + 26EE 0F BF C2 movsx eax, dx + 26F1 0F AF C3 imul eax, ebx + 26F4 D3 F8 sar eax, cl + 26F6 C1 FA 10 sar edx, 16 + 26F9 0F AF D3 imul edx, ebx + 26FC D3 FA sar edx, cl + 26FE C1 E2 10 shl edx, 16 + 2701 66| 8B D0 mov dx, ax + 2704 89 17 mov dword ptr[edi], edx + 2706 83 C7 04 add edi, 4 + 2709 66| 43 inc bx + 270B 66| 4E dec si + 270D 75 DD jnz short loopfadein + + else + + loopfadein: mov edx, dword ptr[edi] + xor edx, 80808080h + ; convert to signed + REPT 2 + movsx eax, dl + imul eax, ebx + sar eax, cl + mov dl, al + movsx eax, dh + imul eax, ebx + sar eax, cl + mov dh, al + rol edx, 16 + ENDM + xor edx, 80808080h + ; back to unsigned + mov dword ptr[edi], edx + add edi, 4 + inc bx + dec si + jnz short loopfadein + + endif + + 270F EB 24 jmp short endfade + + 2711 fadeout: + 2711 83 C7 04 add edi, 4 + ; skip first + + ifdef SAMPLE16BIT + + 2714 8B 17 loopfadeout: mov edx, dword ptr[edi] + 2716 0F BF C2 movsx eax, dx + 2719 0F AF C6 imul eax, esi + 271C D3 F8 sar eax, cl + 271E C1 FA 10 sar edx, 16 + 2721 0F AF D6 imul edx, esi + 2724 D3 FA sar edx, cl + 2726 C1 E2 10 shl edx, 16 + 2729 66| 8B D0 mov dx, ax + 272C 89 17 mov dword ptr[edi], edx + 272E 83 C7 04 add edi, 4 + 2731 66| 4E dec si + 2733 75 DF jnz short loopfadeout + + else + + loopfadeout: mov edx, dword ptr[edi] + xor edx, 80808080h + ; convert to signed + REPT 2 + movsx eax, dl + imul eax, esi + sar eax, cl + mov dl, al + movsx eax, dh + imul eax, esi + sar eax, cl + mov dh, al + rol edx, 16 + ENDM + xor edx, 80808080h + ; back to unsigned + mov dword ptr[edi], edx + add edi, 4 + dec si + jnz short loopfadeout + endif + + 2735 endfade: + 2735 A0 00002559 R mov al, byte ptr[FlagPause] + 273A 24 01 and al, 1 + 273C A2 00002559 R mov byte ptr[FlagPause], al + 2741 reallyexit: + + 2741 C3 ret + 2742 FinishFill0: + 2742 66| 0B C0 or ax, ax + ; still some room in the buffer? + 2745 0F 84 000002CA jz Finish2 + 274B process_1st: + 274B 66| 8B C8 mov cx, ax + 274E C1 E0 10 shl eax, 16 + 2751 66| 8B C1 mov ax, cx + ; eax = BUFFER_SIZE:BUFFER_SIZE + 2754 66| 8B 53 04 mov dx, word ptr[ebx+FRACT] + ; fractionnal Source + 2758 66| 8B 6B 0E mov bp, word ptr[ebx+INCR] + ; fractionnal inc + 275C 8B 4B 08 mov ecx, dword ptr[ebx+LEFT] + ; length left + + 275F 81 F9 0000FFFF cmp ecx, 0FFFFh + ; length left to fill after sample + 2765 77 05 ja Longer0 + ; 64K or +, then more than the buffer + 2767 66| 2B C1 sub ax, cx + 276A 73 13 jae short NotLonger0 + ; some left? + 276C Longer0: + 276C C1 E8 10 shr eax, 16 + 276F 8B C8 mov ecx, eax + ; length = buffer_size + 2771 29 4B 08 sub dword ptr[ebx+LEFT], ecx + ; reduce length left + 2774 66| C7 05 000025E0 R mov word ptr[save_4], 0 + 0000 ; no room left + 277D EB 08 jmp short StartMix0 + 277F NotLonger0: + 277F 66| 40 inc ax + ; length + 1 (in case left = 0) + 2781 66| A3 000025E0 R mov word ptr[save_4], ax + 2787 StartMix0: + 2787 C1 E2 10 shl edx, 16 + 278A 0B CA or ecx, edx + ; hecx = FRACT + 278C C1 E5 10 shl ebp, 16 + ; hebp = INCR + + ifdef SAMPLE16BIT + + 278F 8B 53 20 mov edx, dword ptr[ebx+VOL_L + EFT] ; read left & right volume + + ifdef STEREO + + 2792 80 7B 28 00 cmp byte ptr[ebx+INTERPOL], + 0 + 2796 0F 84 00000090 je nofilter + + 279C 89 1D 000025DC R mov dword ptr[save_3], ebx + + 27A2 0F BF C2 movsx eax, dx + 27A5 A3 000025D0 R mov [TheVolumeL], eax + 27AA C1 FA 10 sar edx, 16 + 27AD 89 15 000025CC R mov [TheVolumeR], edx + + 27B3 C1 ED 10 shr ebp, 16 + ; BP = fract inc + 27B6 8B D1 mov edx, ecx + 27B8 C1 EA 10 shr edx, 16 + ; DX = fract + + 27BB C1 C1 08 rol ecx, 8 + 27BE 8A 4B 29 mov cl, [ebx+LAST_SAMPLE] + 27C1 C1 C9 08 ror ecx, 8 + + 27C4 EB 09 jmp short next0 + + 27C6 C1 C1 08 start0: rol ecx, 8 + 27C9 8A 0E mov cl, [esi] + 27CB 46 inc esi + 27CC C1 C9 08 ror ecx, 8 + 27CF 8B C1 next0: mov eax, ecx + 27D1 8A 06 mov al, [esi] + ; read data + 27D3 C1 C0 08 rol eax, 8 + 27D6 66| 35 8080 xor ax, 8080h + ; 8 bit signed + 27DA 0F BE D8 movsx ebx, al + 27DD 0F BE C4 movsx eax, ah + ; sign extension to 32 bit + + 27E0 66| F7 D2 not dx + 27E3 42 inc edx + 27E4 0F AF DA imul ebx, edx + 27E7 4A dec edx + 27E8 66| F7 D2 not dx + 27EB 0F AF C2 imul eax, edx + 27EE 03 D8 add ebx, eax + + 27F0 8B C3 mov eax, ebx + 27F2 0F AF 1D 000025CC R imul ebx, [TheVolumeR] + ; Right + 27F9 0F AF 05 000025D0 R imul eax, [TheVolumeL] + ; Left + 2800 C1 F8 10 sar eax, 16 + 2803 66| 8B D8 mov bx, ax + + 2806 89 1F mov [edi], ebx + ; store buffer content + 2808 83 C7 04 add edi, 4 + ; next location + 280B 66| 03 D5 add dx, bp + ; update fractional part of address + 280E 66| 49 dec cx + ; length-1, doesn't touch C but set Z ;- + ) + 2810 77 BD ja short next0 + ; if (not C) and (not Z) next + 2812 75 B2 jnz short start0 + ; if some left, read a new one + + 2814 8B 1D 000025DC R mov ebx, dword ptr[save_3] + + 281A 66| 9C pushf + + 281C C1 C1 08 rol ecx, 8 + 281F 88 4B 29 mov [ebx+LAST_SAMPLE], cl + + 2822 C1 E2 10 shl edx, 16 + 2825 8B CA mov ecx, edx + 2827 46 inc esi + + 2828 66| 9D popf + + 282A EB 2B jmp short end16 + 282C nofilter: + 282C 89 1D 000025DC R mov dword ptr[save_3], ebx + + 2832 AC start01: lodsb + ; read new data + 2833 34 80 xor al, 80h + ; 8 bit signed + 2835 0F BE C0 movsx eax, al + ; sign extension to 32 bit + 2838 8B D8 mov ebx, eax + ; copy into ebx + 283A 66| 0F AF C2 imul ax, dx + ; ax = left + 283E 0F AF DA imul ebx, edx + 2841 66| 8B D8 mov bx, ax + 2844 89 1F next01: mov dword ptr[edi], ebx + ; write data + 2846 83 C7 04 add edi, 4 + ; next location + 2849 03 CD add ecx, ebp + ; update fractional part of address + 284B 66| 49 dec cx + ; length-1, doesn't touch C but set Z ;- + ) + 284D 77 F5 ja short next01 + ; if (not C) and (not Z) next + 284F 75 E1 jnz short start01 + ; if some left, read a new one + + 2851 8B 1D 000025DC R mov ebx, dword ptr[save_3] + 2857 end16: + else + + start0: lodsb + ; read new data + xor al, 80h + ; 8 bit signed + movsx ax, al + ; sign extension to 16 bit + imul ax, dx + ; ax = "volumed" sample + next0: mov word ptr[edi], ax + ; write data + add edi, 2 + ; next location + add ecx, ebp + ; update fractional part of address + dec cx + ; length-1, doesn't touch C but set Z ;- + ) + ja short next0 + ; if (not C) and (not Z) next + jnz short start0 + ; if some left, read a new one + + endif + else + + ifdef STEREO + + mov dl, byte ptr[ebx+VOL_LEF + T] + or dl, dl + jz short middle0 + dec dl + jz short left0 + + mov al, 80h + ; "0" -> left + r_start0: mov ah, byte ptr[esi] + ; read new data -> right + inc esi + r_next0: mov word ptr[edi], ax + ; write data + add edi, 2 + ; next location + add ecx, ebp + ; update fractional part of address + dec cx + ; length-1, doesn't touch C but set Z ;- + ) + ja short r_next0 + ; if (not C) and (not Z) next + jnz short r_start0 + ; if some left, read a new one + jmp short end0 + + left0: + + mov ah, 80h + ; "0" -> right + l_start0: lodsb + ; read new data -> left + l_next0: mov word ptr[edi], ax + ; write data + add edi, 2 + ; next location + add ecx, ebp + ; update fractional part of address + dec cx + ; length-1, doesn't touch C but set Z ;- + ) + ja short l_next0 + ; if (not C) and (not Z) next + jnz short l_start0 + ; if some left, read a new one + jmp short end0 + + middle0: + + m_start0: lodsb + ; read new data -> left + mov ah, al + ; data -> right + m_next0: mov word ptr[edi], ax + ; write data + add edi, 2 + ; next location + add ecx, ebp + ; update fractional part of address + dec cx + ; length-1, doesn't touch C but set Z ;- + ) + ja short m_next0 + ; if (not C) and (not Z) next + jnz short m_start0 + ; if some left, read a new one + + end0: + else + + start0: lodsb + ; read new data + next0: mov byte ptr[edi], al + ; write data + inc edi + ; next location + add ecx, ebp + ; update fractional part of address + dec cx + ; length-1, doesn't touch C but set Z ;- + ) + ja short next0 + ; if (not C) and (not Z) next + jnz short start0 + ; if some left, read a new one + + endif + endif + + 2857 72 01 jc noadjust0 + ; was a new data going to be read? + 2859 4E dec esi + ; no, last data will be read again + 285A noadjust0: + 285A 66| A1 000025E0 R mov ax, word ptr[save_4] + ; left to copy + 2860 66| 0B C0 or ax, ax + 2863 0F 84 000001A3 jz Finish + ; 0 normal end + + 2869 66| 48 dec ax + ; readjust size + + 286B 66| FF 4B 0C dec word ptr[ebx+C_REPEAT] + ; repeat again? + 286F 75 74 jnz Reset0 + ; yes, then reset + + 2871 8B 53 10 mov edx, dword ptr[ebx+SON] + ; no, got a son? + 2874 0B D2 or edx, edx + 2876 78 15 js short NoSon0 + ; no, remove the sample + + 2878 8D 35 00000A00 R lea esi, SonList + ; yes, then find it + 287E KeepLooking0: + 287E 83 3E 00 cmp dword ptr[esi], 0 + ; the end ? + 2881 74 0A je short NoSon0 + ; yes, then no son + 2883 3B 56 14 cmp edx, dword ptr[esi+HANDL + E] ; this one? + 2886 74 2B je short FoundSon0 + ; yes, found! + 2888 83 C6 2C add esi, STRUCT_SIZE + ; no, keep looking + 288B EB F1 jmp short KeepLooking0 + 288D NoSon0: + 288D 33 C9 xor ecx, ecx + 288F 66| 8B C8 mov cx, ax + ; clear rest of the buffer + MIDPOINT + 1 + 1 IFDEF SAMPLE16BIT + 2892 33 C0 1 xor eax, eax + 1 ELSE + 1 mov eax, 80808080h + 1 ENDIF + 1 + IFDEF SCHAR + mov edx, ecx + and ecx, 3 + ; up to 3 by byte + rep stosb + mov ecx, edx + shr ecx, 2 + ; the rest by dword + ELSEIFDEF SUWORD + shr ecx, 1 + jnc short NoAdjustByOne + stosw + NoAdjustByOne: + ENDIF + 2894 F3/ AB rep stosd + + 2896 8B F3 mov esi, ebx + ; point where it is + 2898 8B FB mov edi, ebx + ; idem + 289A 83 C6 2C add esi, STRUCT_SIZE + ; source one further + + 289D 83 3E 00 LoopRemove0: cmp dword ptr[esi], 0 + ; end ? + 28A0 74 09 je short EndRemove0 + ; yes, exit + 28A2 B9 0000000B mov ecx, STRUCT_SIZE / 4 + ; trasnfert one struct + 28A7 F3/ A5 rep movsd + ; transfer + 28A9 EB F2 jmp short LoopRemove0 + 28AB EndRemove0: + 28AB C7 07 00000000 mov dword ptr[edi], 0 + ; write 0 to mark the end + 28B1 EB 46 jmp NextSample + 28B3 FoundSon0: + 28B3 8B EE mov ebp, esi + ; save esi + 28B5 8B D7 mov edx, edi + ; save edi + + 28B7 8B FB mov edi, ebx + ; transfert at the location of the fathe + r + 28B9 B9 0000000B mov ecx, STRUCT_SIZE / 4 + ; count in dword + 28BE F3/ A5 rep movsd + ; transfert + + 28C0 8B F5 mov esi, ebp + ; remove son from SonList + 28C2 8B FD mov edi, ebp + ; so, point to it + 28C4 83 C6 2C add esi, STRUCT_SIZE + ; source one further + 28C7 83 3E 00 LoopSon0: cmp dword ptr[esi], 0 + 28CA 74 09 je short EndSon0 + 28CC B9 0000000B mov ecx, STRUCT_SIZE / 4 + 28D1 F3/ A5 rep movsd + ; transfer while not 0 + 28D3 EB F2 jmp short LoopSon0 + 28D5 EndSon0: + 28D5 C7 07 00000000 mov dword ptr[edi], 0 + ; write 0 to mark the end + + 28DB 8B FA mov edi, edx + ; restore edi in the buffer + 28DD 8B 73 18 mov esi, dword ptr[ebx+START + ] ; restore source, no need to write it + 28E0 E9 FFFFFE5D jmp FinishFill0 + 28E5 Reset0: + 28E5 8B 73 18 mov esi, dword ptr[ebx+START + ] ; restore source, no need to write it + 28E8 8B 6B 1C mov ebp, dword ptr[ebx+DLENG + TH] ; restore length + 28EB 89 6B 08 mov dword ptr[ebx+LEFT], ebp + 28EE 66| C7 43 04 0000 mov word ptr[ebx+FRACT], 0 + 28F4 E9 FFFFFE49 jmp FinishFill0 + + 28F9 NextSample: + 28F9 8B 33 mov esi, dword ptr[ebx] + ; Current Source + 28FB 0B F6 or esi, esi + ; if 0 then end of the list + 28FD 0F 84 FFFFFDC6 jz exit + + ifdef RAM_CARD + mov edi, dword ptr[BUFFER_DM + A] ; Buffer + else + 2903 8B 3D 000025EC R mov edi, dword ptr[CURRENT_B + UFFER] ; Buffer + endif + 2909 66| B8 0400 mov ax, BUFFER_SIZE + 290D FinishFill: + 290D 66| 0B C0 or ax, ax + ; still some room in the buffer? + 2910 0F 84 000000FF jz Finish2 + + 2916 66| 8B C8 mov cx, ax + 2919 C1 E0 10 shl eax, 16 + 291C 66| 8B C1 mov ax, cx + ; eax = BUFFER_SIZE:BUFFER_SIZE + 291F 66| 8B 53 04 mov dx, word ptr[ebx+FRACT] + ; fractionnal Source + 2923 66| 8B 6B 0E mov bp, word ptr[ebx+INCR] + ; fractionnal inc + 2927 8B 4B 08 mov ecx, dword ptr[ebx+LEFT] + ; length left + + 292A 81 F9 0000FFFF cmp ecx, 0FFFFh + ; length left to fill after sample + 2930 77 05 ja Longer + ; 64K or +, then more than the buffer + 2932 66| 2B C1 sub ax, cx + 2935 73 13 jae short NotLonger + ; some left? + 2937 Longer: + 2937 C1 E8 10 shr eax, 16 + ; no, restore buffer_size in ax + 293A 8B C8 mov ecx, eax + ; length = buffer_size + 293C 29 4B 08 sub dword ptr[ebx+LEFT], ecx + ; reduce length left + 293F 66| C7 05 000025E0 R mov word ptr[save_4], 0 + 0000 ; no room left + 2948 EB 08 jmp short startMix00 + 294A NotLonger: + 294A 66| 40 inc ax + ; length + 1 (in case left = 0) + 294C 66| A3 000025E0 R mov word ptr[save_4], ax + 2952 StartMix00: + 2952 C1 E2 10 shl edx, 16 + 2955 0B CA or ecx, edx + ; hecx = FRACT + 2957 C1 E5 10 shl ebp, 16 + ; hebp = INCR + + ifdef SAMPLE16BIT + + 295A 8B 53 20 mov edx, dword ptr[ebx+VOL_L + EFT] + + ifdef STEREO + + comment @ + + mov dword ptr[save_3], ebx + + movsx eax, dx + mov [TheVolumeL], eax + sar edx, 16 + mov [TheVolumeR], edx + + shr ebp, 16 + ; BP = fract inc + mov edx, ecx + shr edx, 16 + ; DX = fract + + dec esi + + start00: inc esi + next00: mov ax, [esi] + ; read data + xor ax, 8080h + ; 8 bit signed + movsx ebx, al + movsx eax, ah + ; sign extension to 32 bit + not dx + inc edx + imul ebx, edx + dec edx + not dx + imul eax, edx + add ebx, eax + + mov eax, ebx + imul ebx, [TheVolumeR] + ; Right + imul eax, [TheVolumeL] + ; Left + sar eax, 16 + mov bx, ax + + add [edi], ebx + ; add with buffer content (one bit might + jump from right to left, but oh well...) + add edi, 4 + ; next location + add dx, bp + ; update fractional part of address + dec cx + ; length-1, doesn't touch C but set Z ;- + ) + ja short next00 + ; if (not C) and (not Z) next + jnz short start00 + ; if some left, read a new one + + pushf + + shl edx, 16 + mov ecx, edx + inc esi + + popf + + mov ebx, dword ptr[save_3] + + @ + + 295D 89 1D 000025DC R mov dword ptr[save_3], ebx + + 2963 AC start00: lodsb + ; read new data + 2964 34 80 xor al, 80h + ; 8 bit signed + 2966 0F BE C0 movsx eax, al + ; sign extension to 32 bit + 2969 8B D8 mov ebx, eax + ; copy into ebx + 296B 66| 0F AF C2 imul ax, dx + ; ax = left + 296F 0F AF DA imul ebx, edx + 2972 66| 8B D8 mov bx, ax + 2975 01 1F next00: add dword ptr[edi], ebx + ; add with buffer content (one bit might + jump from right to left, but oh well...) + 2977 83 C7 04 add edi, 4 + ; next location + 297A 03 CD add ecx, ebp + ; update fractional part of address + 297C 66| 49 dec cx + ; length-1, doesn't touch C but set Z ;- + ) + 297E 77 F5 ja short next00 + ; if (not C) and (not Z) next + 2980 75 E1 jnz short start00 + ; if some left, read a new one + + 2982 8B 1D 000025DC R mov ebx, dword ptr[save_3] + + else + + start00: lodsb + ; read new data + xor al, 80h + ; 8 bit signed + movsx ax, al + ; sign extension to 16 bit + imul ax, dx + ; ax = "volumed" sample + next00: add word ptr[edi], ax + ; add with buffer content + add edi, 2 + ; next location + add ecx, ebp + ; update fractional part of address + dec cx + ; length-1, doesn't touch C but set Z ;- + ) + ja short next00 + ; if (not C) and (not Z) next + jnz short start00 + ; if some left, read a new one + + endif + else + + ifdef STEREO + + mov dl, byte ptr[ebx+VOL_LEF + T] + or dl, dl + jz short middle00 + dec dl + jz short left00 + + inc edi + ; go right + r_start00: lodsb + ; read new data + mov ah, al + ; save it in ah + r_next00: add al, byte ptr[edi] + ; add with buffer content + rcr al, 1 + ; average + adc al, 0 + mov byte ptr[edi], al + ; write result back + add edi, 2 + ; next location + mov al, ah + ; restore data + add ecx, ebp + ; update fractional part of address + dec cx + ; length-1, doesn't touch C but set Z ;- + ) + ja short r_next00 + ; if (not C) and (not Z) next + jnz short r_start00 + ; if some left, read a new one + dec edi + ; go back left + jmp short end00 + + left00: + + l_start00: lodsb + ; read new data + mov ah, al + ; save it in ah + l_next00: add al, byte ptr[edi] + ; add with buffer content + rcr al, 1 + ; average + adc al, 0 + mov byte ptr[edi], al + ; write result back + add edi, 2 + ; next location + mov al, ah + ; restore data + add ecx, ebp + ; update fractional part of address + dec cx + ; length-1, doesn't touch C but set Z ;- + ) + ja short l_next00 + ; if (not C) and (not Z) next + jnz short l_start00 + ; if some left, read a new one + jmp short end00 + + middle00: + + m_start00: lodsb + ; read new data + m_next00: mov dx, word ptr[edi] + ; read buffer, left & right + add dl, al + ; average with left + rcr dl, 1 + adc dl, 0 + add dh, al + ; average with right + rcr dh, 1 + adc dl, 0 + mov word ptr[edi], dx + ; write result back + add edi, 2 + ; next location + add ecx, ebp + ; update fractional part of address + dec cx + ; length-1, doesn't touch C but set Z ;- + ) + ja short m_next00 + ; if (not C) and (not Z) next + jnz short m_start00 + ; if some left, read a new one + + end00: + + else + + start00: lodsb + ; read new data + mov ah, al + ; save it in ah + next00: add al, byte ptr[edi] + ; add with buffer content + rcr al, 1 + ; average + adc al, 0 + mov byte ptr[edi], al + ; write result back + inc edi + ; next location + mov al, ah + ; restore data + add ecx, ebp + ; update fractional part of address + dec cx + ; length-1, doesn't touch C but set Z ;- + ) + ja short next00 + ; if (not C) and (not Z) next + jnz short start00 + ; if some left, read a new one + + endif + endif + 2988 72 01 jc noadjust + ; was a new data going to be read? + 298A 4E dec esi + ; no, last data will be read again + 298B noadjust: + 298B 66| A1 000025E0 R mov ax, word ptr[save_4] + ; left to copy + 2991 66| 0B C0 or ax, ax + 2994 74 76 jz short Finish + ; 0 normal end + + 2996 66| 48 dec ax + ; readjust size + + 2998 66| FF 4B 0C dec word ptr[ebx+C_REPEAT] + ; repeat again? + 299C 75 7F jnz short Reset + ; yes, then reset + + 299E 8B 53 10 mov edx, dword ptr[ebx+SON] + ; no, got a son? + 29A1 0B D2 or edx, edx + 29A3 78 15 js short NoSon + ; no, remove the sample + + 29A5 8D 35 00000A00 R lea esi, SonList + ; yes, then find it + 29AB KeepLooking: + 29AB 83 3E 00 cmp dword ptr[esi], 0 + ; the end ? + 29AE 74 0A je short NoSon + ; yes, then no son + 29B0 3B 56 14 cmp edx, dword ptr[esi+HANDL + E] ; this one? + 29B3 74 25 je short FoundSon + ; yes, found! + 29B5 83 C6 2C add esi, STRUCT_SIZE + ; no, keep looking + 29B8 EB F1 jmp short KeepLooking + 29BA NoSon: + ; remove it + 29BA 8B F3 mov esi, ebx + ; point where it is + 29BC 8B FB mov edi, ebx + ; idem + 29BE 83 C6 2C add esi, STRUCT_SIZE + ; source one further + + 29C1 83 3E 00 LoopRemove: cmp dword ptr[esi], 0 + ; end ? + 29C4 74 09 je short EndRemove + ; yes, exit + 29C6 B9 0000000B mov ecx, STRUCT_SIZE / 4 + ; trasnfert one struct + 29CB F3/ A5 rep movsd + ; transfer + 29CD EB F2 jmp short LoopRemove + 29CF EndRemove: + 29CF C7 07 00000000 mov dword ptr[edi], 0 + ; write 0 to mark the end + 29D5 E9 FFFFFF1F jmp NextSample + 29DA FoundSon: + 29DA 8B EE mov ebp, esi + ; save esi + 29DC 8B D7 mov edx, edi + ; save edi + + 29DE 8B FB mov edi, ebx + ; transfert at the location of the fathe + r + 29E0 B9 0000000B mov ecx, STRUCT_SIZE / 4 + ; count in dword + 29E5 F3/ A5 rep movsd + ; transfert + + 29E7 8B F5 mov esi, ebp + ; remove son from SonList + 29E9 8B FD mov edi, ebp + ; so, point to it + 29EB 83 C6 2C add esi, STRUCT_SIZE + ; source one further + 29EE 83 3E 00 LoopSon: cmp dword ptr[esi], 0 + 29F1 74 09 je short EndSon + 29F3 B9 0000000B mov ecx, STRUCT_SIZE / 4 + 29F8 F3/ A5 rep movsd + ; transfer while not 0 + 29FA EB F2 jmp short LoopSon + 29FC EndSon: + 29FC C7 07 00000000 mov dword ptr[edi], 0 + ; write 0 to mark the end + + 2A02 8B FA mov edi, edx + ; restore edi in the buffer + 2A04 8B 73 18 mov esi, dword ptr[ebx+START + ] ; restore source, no need to write it + 2A07 E9 FFFFFF01 jmp FinishFill + 2A0C Finish: + 2A0C 89 33 mov dword ptr[ebx], esi + ; save current address + 2A0E C1 E9 10 shr ecx, 16 + 2A11 66| 89 4B 04 mov word ptr[ebx+FRACT], cx + ; save fractional part + 2A15 83 C3 2C Finish2: add ebx, STRUCT_SIZE + ; point to next sample + 2A18 E9 FFFFFEDC jmp NextSample + 2A1D Reset: + 2A1D 8B 73 18 mov esi, dword ptr[ebx+START + ] ; restore source, no need to write it + 2A20 8B 6B 1C mov ebp, dword ptr[ebx+DLENG + TH] ; restore length + 2A23 89 6B 08 mov dword ptr[ebx+LEFT], ebp + 2A26 66| C7 43 04 0000 mov word ptr[ebx+FRACT], 0 + 2A2C E9 FFFFFEDC jmp FinishFill + + 2A31 UpdateBuffer ENDP + + ;*---------------------------------------------- + ----------------------------* + + 2A31 StopSample PROC + + CRIT_SECT + 1 + 2A31 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; tell the IRQ not to update the buffer + 1 + 1 ; we'll take care of it if nescessary O:-) + + 2A3A 33 C0 xor eax, eax + + 2A3C A3 00000168 R mov dword ptr[CurrentList], + eax + 2A41 A3 00000A00 R mov dword ptr[SonList], eax + 2A46 A2 00002559 R mov byte ptr[FlagPause], al + 2A4B 48 dec eax + 2A4C A3 000025B8 R mov dword ptr[follow], eax + ; -1 + + 2A51 C7 05 000025C4 R mov dword ptr[weirdcount], 1 + 00010000 0000h + + END_CRIT_SECT + 1 local NoUpdate + 1 ; Update buffer if necessary + 1 + 1 ; Dealing with the critical sect + 1 ion flags................ + 1 ; + 1 DO NOT TOUCH !!!! + 1 + 2A5B 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect. + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2A64 66| 83 3D 00002582 R 1 cmp word ptr[DoUpdate], 0 + 00 1 ; IRQ happened ? + 2A6C 74 22 1 je ??0000 ; + 1 if DopUpdate change to 0 now, we are in deep + 1 + 1 ; shit anyway because we missed one round! + 1 + 1 ; The program won't crash but we'll ear the old + 1 + 1 ; content of half a buffer and also miss half a + 1 buffer + 1 + 1 ; of new data... :-( + 2A6E 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; yes, crit. again, so we don't update twice + 1 + 1 ; because UpdateBuffer is not reentrant + 1 + 1 ; and we don't want to take a chance on crashing + 1 ! + 2A77 60 1 pushad + 1 ; if DoUpdate change to 1 HERE + 1 + 1 ; it means again that we missed one round! + 1 + 1 ; So we play the buffer we are updating! (funny + 1 noise :-( ) + 1 + 1 ; and then will ear half buffer of old data! + 2A78 E8 FFFFFC1D 1 call UpdateBuffer + 1 ; do the update + 2A7D 61 1 popad + 2A7E 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2A87 66| C7 05 00002582 R 1 mov word ptr[DoUpdate], 0 + 0000 1 ; Update done, so DoUpdate = 0 + 2A90 1 ??0000: + 1 + 1 + 1 ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !! + 1 !! + 1 + 1 ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE B + 1 UFFER + 1 + 1 ; TAKES MORE THAN 46000 microsec! + 1 + 1 ; (at 33 Mhz one cycle = .03 microsec so 4600 mi + 1 crosec = 1.5 million cycle) + + 2A90 C3 ret + + 2A91 StopSample ENDP + + ;*---------------------------------------------- + ----------------------------* + + 2A91 StopOneSample PROC USES EBX ESI EDI,\ + thehandle:DWORD + + + 2A91 55 * push ebp + 2A92 8B EC * mov ebp, esp + 2A94 53 * push ebx + 2A95 56 * push esi + 2A96 57 * push edi + 2A97 6A FF push -1 + ; end of recursion + 2A99 8B 45 08 mov eax, thehandle + 2A9C 8D 15 00000168 R lea edx, CurrentList + 2AA2 8B DA mov ebx, edx + + CRIT_SECT + 1 + 2AA4 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; tell the IRQ not to update the buffer + 1 + 1 ; we'll take care of it if nescessary O:-) + + 2AAD 83 3B 00 keeplooking: cmp dword ptr[ebx], 0 + 2AB0 74 0B je short exit + 2AB2 66| 3B 43 14 cmp ax, word ptr[ebx+HANDLE] + 2AB6 74 50 je short found + 2AB8 83 C3 2C add ebx, STRUCT_SIZE + 2ABB EB F0 jmp short keeplooking + 2ABD exit: + 2ABD 8D 1D 00000A00 R lea ebx, SonList + 2AC3 3B D3 cmp edx, ebx + 2AC5 8B D3 mov edx, ebx + 2AC7 75 E4 jne short keeplooking + + 2AC9 58 pop eax + ; get "son" + 2ACA 0B C0 or eax, eax + 2ACC 79 DF jns short keeplooking + ; less than #2 billions samples ! + + END_CRIT_SECT + 1 local NoUpdate + 1 ; Update buffer if necessary + 1 + 1 ; Dealing with the critical sect + 1 ion flags................ + 1 ; + 1 DO NOT TOUCH !!!! + 1 + 2ACE 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect. + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2AD7 66| 83 3D 00002582 R 1 cmp word ptr[DoUpdate], 0 + 00 1 ; IRQ happened ? + 2ADF 74 22 1 je ??0001 ; + 1 if DopUpdate change to 0 now, we are in deep + 1 + 1 ; shit anyway because we missed one round! + 1 + 1 ; The program won't crash but we'll ear the old + 1 + 1 ; content of half a buffer and also miss half a + 1 buffer + 1 + 1 ; of new data... :-( + 2AE1 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; yes, crit. again, so we don't update twice + 1 + 1 ; because UpdateBuffer is not reentrant + 1 + 1 ; and we don't want to take a chance on crashing + 1 ! + 2AEA 60 1 pushad + 1 ; if DoUpdate change to 1 HERE + 1 + 1 ; it means again that we missed one round! + 1 + 1 ; So we play the buffer we are updating! (funny + 1 noise :-( ) + 1 + 1 ; and then will ear half buffer of old data! + 2AEB E8 FFFFFBAA 1 call UpdateBuffer + 1 ; do the update + 2AF0 61 1 popad + 2AF1 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2AFA 66| C7 05 00002582 R 1 mov word ptr[DoUpdate], 0 + 0000 1 ; Update done, so DoUpdate = 0 + 2B03 1 ??0001: + 1 + 1 + 1 ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !! + 1 !! + 1 + 1 ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE B + 1 UFFER + 1 + 1 ; TAKES MORE THAN 46000 microsec! + 1 + 1 ; (at 33 Mhz one cycle = .03 microsec so 4600 mi + 1 crosec = 1.5 million cycle) + + ret + 2B03 5F * pop edi + 2B04 5E * pop esi + 2B05 5B * pop ebx + 2B06 C9 * leave + 2B07 C3 * ret 00000h + 2B08 found: + 2B08 8B 4B 10 mov ecx, dword ptr[ebx+SON] + 2B0B 0B C9 or ecx, ecx + 2B0D 78 01 js short noson + + 2B0F 51 push ecx + ; "son" to be removed + 2B10 noson: + 2B10 8B F3 mov esi, ebx + 2B12 8B FB mov edi, ebx + 2B14 83 C6 2C add esi, STRUCT_SIZE + 2B17 83 3E 00 LoopRemove: cmp dword ptr[esi], 0 + 2B1A 74 09 je short EndRemove + 2B1C B9 0000000B mov ecx, STRUCT_SIZE / 4 + 2B21 F3/ A5 rep movsd + 2B23 EB F2 jmp short LoopRemove + 2B25 EndRemove: + 2B25 C7 07 00000000 mov dword ptr[edi], 0 + 2B2B EB 80 jmp short keeplooking + + 2B2D StopOneSample ENDP + + ;----------------------------------------------- + ----------------------------- + + 2B2D ShiftSamples PROC USES ESI EDI EBX,\ + DestAddr:DWORD, SrcAddr:DWORD, S + izeByte:DWORD + + 2B2D 55 * push ebp + 2B2E 8B EC * mov ebp, esp + 2B30 56 * push esi + 2B31 57 * push edi + 2B32 53 * push ebx + 2B33 8D 15 00000168 R lea edx, CurrentList + + 2B39 8B 75 0C mov esi, SrcAddr + ; Source + 2B3C 8B C6 mov eax, esi + ; save Source for comparison + 2B3E 8B 7D 08 mov edi, DestAddr + ; Destination + 2B41 8B 4D 10 mov ecx, SizeByte + ; number of bytes to move + + 2B44 8A D9 mov bl, cl + ; compute counters + 2B46 C1 E9 02 shr ecx, 2 + 2B49 80 E3 03 and bl, 3 + + CRIT_SECT + 1 + 2B4C 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; tell the IRQ not to update the buffer + 1 + 1 ; we'll take care of it if nescessary O:-) + + 2B55 F3/ A5 rep movsd + ; move the data + 2B57 8A CB mov cl, bl + 2B59 F3/ A4 rep movsb + + 2B5B 2B FE sub edi, esi + ; shift (delta addr) + + 2B5D 8B DA mov ebx, edx + + 2B5F 83 3B 00 keeplooking: cmp dword ptr[ebx], 0 + 2B62 74 0F je short exit + 2B64 3B 43 18 cmp eax, [ebx+START] + 2B67 77 05 ja short notfound + 2B69 01 7B 18 add [ebx+START], edi + 2B6C 01 3B add [ebx], edi + 2B6E notfound: + 2B6E 83 C3 2C add ebx, STRUCT_SIZE + 2B71 EB EC jmp short keeplooking + 2B73 exit: + 2B73 8D 1D 00000A00 R lea ebx, SonList + 2B79 3B D3 cmp edx, ebx + 2B7B 8B D3 mov edx, ebx + 2B7D 75 E0 jne short keeplooking + + END_CRIT_SECT + 1 local NoUpdate + 1 ; Update buffer if necessary + 1 + 1 ; Dealing with the critical sect + 1 ion flags................ + 1 ; + 1 DO NOT TOUCH !!!! + 1 + 2B7F 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect. + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2B88 66| 83 3D 00002582 R 1 cmp word ptr[DoUpdate], 0 + 00 1 ; IRQ happened ? + 2B90 74 22 1 je ??0002 ; + 1 if DopUpdate change to 0 now, we are in deep + 1 + 1 ; shit anyway because we missed one round! + 1 + 1 ; The program won't crash but we'll ear the old + 1 + 1 ; content of half a buffer and also miss half a + 1 buffer + 1 + 1 ; of new data... :-( + 2B92 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; yes, crit. again, so we don't update twice + 1 + 1 ; because UpdateBuffer is not reentrant + 1 + 1 ; and we don't want to take a chance on crashing + 1 ! + 2B9B 60 1 pushad + 1 ; if DoUpdate change to 1 HERE + 1 + 1 ; it means again that we missed one round! + 1 + 1 ; So we play the buffer we are updating! (funny + 1 noise :-( ) + 1 + 1 ; and then will ear half buffer of old data! + 2B9C E8 FFFFFAF9 1 call UpdateBuffer + 1 ; do the update + 2BA1 61 1 popad + 2BA2 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2BAB 66| C7 05 00002582 R 1 mov word ptr[DoUpdate], 0 + 0000 1 ; Update done, so DoUpdate = 0 + 2BB4 1 ??0002: + 1 + 1 + 1 ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !! + 1 !! + 1 + 1 ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE B + 1 UFFER + 1 + 1 ; TAKES MORE THAN 46000 microsec! + 1 + 1 ; (at 33 Mhz one cycle = .03 microsec so 4600 mi + 1 crosec = 1.5 million cycle) + + ret + 2BB4 5B * pop ebx + 2BB5 5F * pop edi + 2BB6 5E * pop esi + 2BB7 C9 * leave + 2BB8 C3 * ret 00000h + + 2BB9 ShiftSamples ENDP + + ;----------------------------------------------- + ----------------------------- + + 2BB9 StopOneSampleLong PROC USES ESI EDI,\ + LongHandle:DWORD + + 2BB9 55 * push ebp + 2BBA 8B EC * mov ebp, esp + 2BBC 56 * push esi + 2BBD 57 * push edi + 2BBE 8B 45 08 mov eax, LongHandle + + CRIT_SECT + 1 + 2BC1 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; tell the IRQ not to update the buffer + 1 + 1 ; we'll take care of it if nescessary O:-) + + 2BCA E8 000000CB call SearchLongHandle + 2BCF 0B D2 or edx, edx + 2BD1 74 1B jz short notfound + + 2BD3 8B F2 mov esi, edx + 2BD5 8B FA mov edi, edx + 2BD7 83 C6 2C add esi, STRUCT_SIZE + 2BDA 83 3E 00 LoopRemove: cmp dword ptr[esi], 0 + 2BDD 74 09 je short EndRemove + 2BDF B9 0000000B mov ecx, STRUCT_SIZE / 4 + 2BE4 F3/ A5 rep movsd + 2BE6 EB F2 jmp short LoopRemove + 2BE8 EndRemove: + 2BE8 C7 07 00000000 mov dword ptr[edi], 0 + 2BEE notfound: + END_CRIT_SECT + 1 local NoUpdate + 1 ; Update buffer if necessary + 1 + 1 ; Dealing with the critical sect + 1 ion flags................ + 1 ; + 1 DO NOT TOUCH !!!! + 1 + 2BEE 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect. + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2BF7 66| 83 3D 00002582 R 1 cmp word ptr[DoUpdate], 0 + 00 1 ; IRQ happened ? + 2BFF 74 22 1 je ??0003 ; + 1 if DopUpdate change to 0 now, we are in deep + 1 + 1 ; shit anyway because we missed one round! + 1 + 1 ; The program won't crash but we'll ear the old + 1 + 1 ; content of half a buffer and also miss half a + 1 buffer + 1 + 1 ; of new data... :-( + 2C01 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; yes, crit. again, so we don't update twice + 1 + 1 ; because UpdateBuffer is not reentrant + 1 + 1 ; and we don't want to take a chance on crashing + 1 ! + 2C0A 60 1 pushad + 1 ; if DoUpdate change to 1 HERE + 1 + 1 ; it means again that we missed one round! + 1 + 1 ; So we play the buffer we are updating! (funny + 1 noise :-( ) + 1 + 1 ; and then will ear half buffer of old data! + 2C0B E8 FFFFFA8A 1 call UpdateBuffer + 1 ; do the update + 2C10 61 1 popad + 2C11 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2C1A 66| C7 05 00002582 R 1 mov word ptr[DoUpdate], 0 + 0000 1 ; Update done, so DoUpdate = 0 + 2C23 1 ??0003: + 1 + 1 + 1 ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !! + 1 !! + 1 + 1 ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE B + 1 UFFER + 1 + 1 ; TAKES MORE THAN 46000 microsec! + 1 + 1 ; (at 33 Mhz one cycle = .03 microsec so 4600 mi + 1 crosec = 1.5 million cycle) + + ret + 2C23 5F * pop edi + 2C24 5E * pop esi + 2C25 C9 * leave + 2C26 C3 * ret 00000h + + 2C27 StopOneSampleLong ENDP + + ;*---------------------------------------------- + ----------------------------* + + 2C27 SampleInList PROC USES EBX,\ + thehandle:DWORD + + CRIT_SECT + 1 + 2C27 55 * push ebp + 2C28 8B EC * mov ebp, esp + 2C2A 53 * push ebx + 2C2B 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; tell the IRQ not to update the buffer + 1 + 1 ; we'll take care of it if nescessary O:-) + + 2C34 8B 55 08 mov edx, thehandle + 2C37 B8 00000001 mov eax, 1 + ; True + + 2C3C 8D 0D 00000168 R lea ecx, CurrentList + 2C42 8B D9 mov ebx, ecx + + 2C44 83 3B 00 keeplooking: cmp dword ptr[ebx], 0 + 2C47 74 0B je short exit + 2C49 66| 3B 53 14 cmp dx, word ptr[ebx+HANDLE] + 2C4D 74 13 je short found + 2C4F 83 C3 2C add ebx, STRUCT_SIZE + 2C52 EB F0 jmp short keeplooking + 2C54 exit: + 2C54 8D 1D 00000A00 R lea ebx, SonList + 2C5A 3B CB cmp ecx, ebx + 2C5C 8B CB mov ecx, ebx + 2C5E 75 E4 jne keeplooking + + 2C60 33 C0 xor eax, eax + ; False + 2C62 found: + END_CRIT_SECT + 1 local NoUpdate + 1 ; Update buffer if necessary + 1 + 1 ; Dealing with the critical sect + 1 ion flags................ + 1 ; + 1 DO NOT TOUCH !!!! + 1 + 2C62 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect. + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2C6B 66| 83 3D 00002582 R 1 cmp word ptr[DoUpdate], 0 + 00 1 ; IRQ happened ? + 2C73 74 22 1 je ??0004 ; + 1 if DopUpdate change to 0 now, we are in deep + 1 + 1 ; shit anyway because we missed one round! + 1 + 1 ; The program won't crash but we'll ear the old + 1 + 1 ; content of half a buffer and also miss half a + 1 buffer + 1 + 1 ; of new data... :-( + 2C75 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; yes, crit. again, so we don't update twice + 1 + 1 ; because UpdateBuffer is not reentrant + 1 + 1 ; and we don't want to take a chance on crashing + 1 ! + 2C7E 60 1 pushad + 1 ; if DoUpdate change to 1 HERE + 1 + 1 ; it means again that we missed one round! + 1 + 1 ; So we play the buffer we are updating! (funny + 1 noise :-( ) + 1 + 1 ; and then will ear half buffer of old data! + 2C7F E8 FFFFFA16 1 call UpdateBuffer + 1 ; do the update + 2C84 61 1 popad + 2C85 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2C8E 66| C7 05 00002582 R 1 mov word ptr[DoUpdate], 0 + 0000 1 ; Update done, so DoUpdate = 0 + 2C97 1 ??0004: + 1 + 1 + 1 ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !! + 1 !! + 1 + 1 ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE B + 1 UFFER + 1 + 1 ; TAKES MORE THAN 46000 microsec! + 1 + 1 ; (at 33 Mhz one cycle = .03 microsec so 4600 mi + 1 crosec = 1.5 million cycle) + + ret + 2C97 5B * pop ebx + 2C98 C9 * leave + 2C99 C3 * ret 00000h + + 2C9A SampleInList ENDP + + + ;*---------------------------------------------- + ----------------------------* + + 2C9A SearchLongHandle PROC + + 2C9A 8D 15 00000168 R lea edx, CurrentList + 2CA0 8D 0D 00000A00 R lea ecx, SonList + + 2CA6 83 3A 00 keeplooking: cmp dword ptr[edx], 0 + 2CA9 74 0A je short exit + 2CAB 3B 42 14 cmp eax, dword ptr[edx+HANDL + E] + 2CAE 74 0D je short found + 2CB0 83 C2 2C add edx, STRUCT_SIZE + 2CB3 EB F1 jmp short keeplooking + 2CB5 exit: + 2CB5 3B D1 cmp edx, ecx + 2CB7 8B D1 mov edx, ecx + 2CB9 75 EB jne keeplooking + + 2CBB 33 D2 xor edx, edx + 2CBD found: + 2CBD C3 ret + + 2CBE SearchLongHandle ENDP + + + ;*---------------------------------------------- + ----------------------------* + + 2CBE ChangeVolume PROC \ + LongHandle:DWORD, volleft:DWORD, + volright:DWORD + + ifdef STEREO + ifdef SAMPLE16BIT + + 2CBE 55 * push ebp + 2CBF 8B EC * mov ebp, esp + 2CC1 8B 45 08 mov eax, LongHandle + + CRIT_SECT + 1 + 2CC4 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; tell the IRQ not to update the buffer + 1 + 1 ; we'll take care of it if nescessary O:-) + + 2CCD E8 FFFFFFC8 call SearchLongHandle + 2CD2 0B D2 or edx, edx + 2CD4 74 14 jz short notfound + + 2CD6 8B 45 0C mov eax, volleft + 2CD9 C1 E8 02 shr eax, SHIFT_SAMPLE - 1 + ; Preshift according to number of channe + ls + 2CDC 66| 89 42 20 mov word ptr[edx+VOL_LEFT], + ax + 2CE0 8B 45 10 mov eax, volright + 2CE3 C1 E8 02 shr eax, SHIFT_SAMPLE - 1 + ; Preshift according to number of channe + ls + ifdef SURROUND + neg eax + endif + 2CE6 66| 89 42 22 mov word ptr[edx+VOL_RIGHT], + ax + + 2CEA notfound: + + END_CRIT_SECT + 1 local NoUpdate + 1 ; Update buffer if necessary + 1 + 1 ; Dealing with the critical sect + 1 ion flags................ + 1 ; + 1 DO NOT TOUCH !!!! + 1 + 2CEA 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect. + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2CF3 66| 83 3D 00002582 R 1 cmp word ptr[DoUpdate], 0 + 00 1 ; IRQ happened ? + 2CFB 74 22 1 je ??0005 ; + 1 if DopUpdate change to 0 now, we are in deep + 1 + 1 ; shit anyway because we missed one round! + 1 + 1 ; The program won't crash but we'll ear the old + 1 + 1 ; content of half a buffer and also miss half a + 1 buffer + 1 + 1 ; of new data... :-( + 2CFD 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; yes, crit. again, so we don't update twice + 1 + 1 ; because UpdateBuffer is not reentrant + 1 + 1 ; and we don't want to take a chance on crashing + 1 ! + 2D06 60 1 pushad + 1 ; if DoUpdate change to 1 HERE + 1 + 1 ; it means again that we missed one round! + 1 + 1 ; So we play the buffer we are updating! (funny + 1 noise :-( ) + 1 + 1 ; and then will ear half buffer of old data! + 2D07 E8 FFFFF98E 1 call UpdateBuffer + 1 ; do the update + 2D0C 61 1 popad + 2D0D 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2D16 66| C7 05 00002582 R 1 mov word ptr[DoUpdate], 0 + 0000 1 ; Update done, so DoUpdate = 0 + 2D1F 1 ??0005: + 1 + 1 + 1 ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !! + 1 !! + 1 + 1 ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE B + 1 UFFER + 1 + 1 ; TAKES MORE THAN 46000 microsec! + 1 + 1 ; (at 33 Mhz one cycle = .03 microsec so 4600 mi + 1 crosec = 1.5 million cycle) + + else + + mov eax, LongHandle + + CRIT_SECT + + call SearchLongHandle + or edx, edx + jz short notfound + + push edi + mov edi, edx + + mov cx, word ptr[volleft] + or cx, cx + jnz short okleft + mov cx, 2 + ; if volleft = 0 then right + jmp short storepos + okleft: mov ax, word ptr[volright] + shl ax, 7 + ; * 128 + xor dx, dx + div cx + mov cx, 2 + ; right + cmp ax, 222 + ; 1.732 (= tan 60) * 128 + jae short storepos + dec cx + ; left + cmp ax, 74 + ; .577 (= tan 30) * 128 + jb short storepos + dec cx + ; middle + storepos: mov word ptr[edi+VOL_LEFT], + cx ; Store position (0:middle, 1:left, 2:ri + ght) + + pop edi + notfound: + + END_CRIT_SECT + + endif + else + ifdef SAMPLE16BIT + + mov eax, LongHandle + + CRIT_SECT + + call SearchLongHandle + or edx, edx + jz short notfound + + push edi + push ebx + mov edi, edx + + mov eax, volleft + imul eax, eax + mov ecx, volright + imul ecx, ecx + add eax, ecx + call sqr2 + shr eax, SHIFT_SAMPLE - 1 + ; Preshift according to number of channe + ls + mov word ptr[edi+VOL_LEFT], + ax ; VOL_LEFT = sqr(volleft^2 + volright^2) + + pop ebx + pop esi + + notfound: + + END_CRIT_SECT + + endif + endif + + ret + 2D1F C9 * leave + 2D20 C3 * ret 00000h + + 2D21 ChangeVolume ENDP + + ifdef SAMPLE16BIT + ifndef STEREO + + ;*---------------------------------------------- + ----------------------------* + + ; EAX = Sqr(EAX) + + Sqr2 PROC + + cmp eax, 3 + ; if eax <= 3 then + jbe short asqr_0_1 + ; square root is 0 or 1 + + xor edx, edx + ; clear edx + mov ebx, eax + ; copy eax into ebx so that + + ; edx:ebx are used "like" a 64 bit + + ; register + + bsr eax, ebx + ; position of last 1 of ebx in eax + + mov cl, 33 + ; compute how many left shift + sub cl, al + ; are needed in order to have the + and cl, 11111110b + ; most significant 2 bit pair at the + + ; leftmost position of edx + + shld edx, ebx, cl + ; shift edx:ebx by the number + shl ebx, cl + ; computed above + + mov ecx, eax + ; compute in ecx how many pairs of + shr ecx, 1 + ; 2 bit are left to be processed + + mov eax, 1 + ; eax = 1 + dec edx + ; edx = edx - 1 + + asqr_loop: shld edx, ebx, 2 + ; edx:ebx << 2 + shl ebx, 2 + ; + lve eax, eax*2 + ; eax * 2 + cmp edx, eax + ; compare edx and eax + jb short asqr_neg + ; if edx> 1 + dec ecx + ; one less pair to process + jnz short asqr_loop + ; if there is some left then go asqr_loop + ret + ; return to caller + + asqr_0_1: or eax, eax + ; if eax = 0 + jz short asqr_00 + ; then return to caller + mov eax, 1 + ; else eax = 1 + asqr_00: ret + ; return to caller + + Sqr2 ENDP + + endif + endif + + ;*---------------------------------------------- + ----------------------------* + + 2D21 MixSample PROC USES ESI EDI EBX,\ + thehandle:DWORD, pitchbend:DWORD + , therepeat:DWORD,\ + plug:DWORD, volleft:DWORD, volri + ght:DWORD,\ + buffer:DWORD; buffer with .VOC + + 2D21 55 * push ebp + 2D22 8B EC * mov ebp, esp + 2D24 56 * push esi + 2D25 57 * push edi + 2D26 53 * push ebx + 2D27 8B 75 20 mov esi, buffer + + 2D2A 33 C0 xor eax, eax + 2D2C 8A 06 mov al, [esi] + 2D2E FE C0 inc al + 2D30 3C 0A cmp al, 10 + 2D32 72 02 jb okfilter + + 2D34 33 C0 xor eax, eax + + 2D36 50 okfilter: push eax + + 2D37 0F B7 46 14 movzx eax, word ptr[esi+14h] + 2D3B 03 F0 add esi, eax + ; skip header + + 2D3D 80 3E 01 cmp byte ptr[esi], 1 + ; only 1 bloc type allowed + 2D40 0F 85 000001B9 jne typeunknown + + 2D46 80 7E 05 00 cmp byte ptr[esi + 5], 0 + ; pack method + 2D4A 0F 85 000001AF jne typeunknown + + ; This crap should be removed by using a + file format containing the + ; real sampling frequency instead of tha + t stupid sr number in .VOC ! + ; :-( + + 2D50 66| BA 000F mov dx, 0Fh + 2D54 66| B8 4240 mov ax, 4240h + ; dx:ax = 1000000 + + 2D58 33 DB xor ebx, ebx + 2D5A 8A 5E 04 mov bl, byte ptr[esi + 4] + ; bl = sr + 2D5D F6 DB neg bl + ; bl = 256 - sr + + 2D5F 66| F7 F3 div bx + + 2D62 66| D1 E2 shl dx, 1 + 2D65 66| 83 D0 00 adc ax, 0 + ; round to nearest + + 2D69 66| 8B D8 mov bx, ax + + ; ebx = real sampling rate + ; up to here ! and then avoid this ^ div + ! + + + 2D6C 8B 46 01 mov eax, dword ptr[esi + 1] + ; size sample + 2D6F 25 00FFFFFF and eax, 0FFFFFFh + ; 24 significant bits + 2D74 83 E8 02 sub eax, 2 + ; -2 header + + + 2D77 83 C6 06 add esi, 6 + ; esi->data + 2D7A 89 35 000025D4 R mov dword ptr[save_1], esi + ; save it + + 2D80 8B 55 0C mov edx, pitchbend + 2D83 C1 E2 04 shl edx, 4 + + 2D86 0F AF DA imul ebx, edx + 2D89 C1 EB 10 shr ebx, 16 + 2D8C 66| 83 D3 00 adc bx, 0 + ; ebx = scaled sampling rate + + 2D90 33 D2 xor edx, edx + 2D92 93 xchg eax, ebx + ; edx = 0, eax = sr, ebx = size + 2D93 92 xchg edx, eax + ; edx = sr, eax = 0, ebx = size + 2D94 66| F7 35 000025A4 R div word ptr[PlayRate] + ; dx:ax / PlayRate; ax = INCR + + 2D9B 3D 0000FFFF cmp eax, 0FFFFh + 2DA0 76 05 jbe okincr + 2DA2 B8 0000FFFF mov eax, 0FFFFh + 2DA7 A3 000025D8 R okincr: mov dword ptr[save_2], eax + ; save_2 = INCR + + 2DAC 8B CB mov ecx, ebx + ; ecx = size + 2DAE 8B F3 mov esi, ebx + 2DB0 C1 EE 10 shr esi, 16 + ; esi = hi(size) + + 2DB3 8B D6 mov edx, esi + 2DB5 93 xchg eax, ebx + ; eax = size, ebx = INCR + + 2DB6 48 dec eax + ; A TRY !!!! (will make loop around next + longer...) + + 2DB7 C1 E0 10 shl eax, 16 + 2DBA F7 F3 div ebx + ; div 64 bits !!! + 2DBC 2B C6 sub eax, esi + ; sub max roundoff error + 2DBE 8B F0 mov esi, eax + ; esi = eax = new size + + 2DC0 F7 E3 mul ebx + ; remultiply + 2DC2 66| 8B D8 mov bx, ax + ; FRACT in bx + 2DC5 0F AC D0 10 shrd eax, edx, 16 + ; size in eax + 2DC9 66| 8B 15 000025D8 R mov dx, word ptr[save_2] + ; INCR in dx + + 2DD0 2B C8 sub ecx, eax + ; how much am I off? + 2DD2 0F 86 00000127 jbe typeunknown + ; security, should not happen! + + 2DD8 46 next: inc esi + ; length + 1 + 2DD9 66| 03 DA add bx, dx + ; update fractional part of address + 2DDC 73 FA jnc short next + ; if (not C) next + 2DDE 66| 49 dec cx + 2DE0 75 F6 jnz short next + ; not right yet, loop + + 2DE2 A1 000025B8 R mov eax, dword ptr[follow] + 2DE7 8D 1D 00000168 R lea ebx, CurrentList + 2DED 8B FB mov edi, ebx + + 2DEF 66| 8B 4D 08 mov cx, word ptr[thehandle] + + IFNDEF SAMPLE_16BIT + + 2DF3 66| 81 F9 1234 cmp cx, VOICE_HANDLE + 2DF8 75 0B jne ok_handle + + 2DFA 50 push eax + 2DFB 51 push ecx + 2DFC 52 push edx + 2DFD E8 FFFFFC2F call StopSample + 2E02 5A pop edx + 2E03 59 pop ecx + 2E04 58 pop eax + 2E05 ok_handle: + + ENDIF + 2E05 0B 0D 000025C4 R or ecx, dword ptr[weirdcoun + t] ; why not ? + 2E0B 66| FF 05 000025C6 R inc word ptr[weirdcount+2] + + CRIT_SECT + 1 + 2E12 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; tell the IRQ not to update the buffer + 1 + 1 ; we'll take care of it if nescessary O:-) + + 2E1B 83 7D 14 00 cmp plug, 0 + 2E1F 74 31 je NoPlug + + 2E21 8D 3D 00000A00 R lea edi, SonList + + 2E27 83 3B 00 keeplooking0: cmp dword ptr[ebx], 0 + 2E2A 74 0A je short SearchSonList + 2E2C 3B 43 14 cmp eax, dword ptr[ebx+HANDL + E] ; look for the "father" sample + 2E2F 74 1E je short found + 2E31 83 C3 2C add ebx, STRUCT_SIZE + 2E34 EB F1 jmp short keeplooking0 + 2E36 SearchSonList: + 2E36 8D 1D 00000A00 R lea ebx, SonList + 2E3C 83 3B 00 keeplooking1: cmp dword ptr[ebx], 0 + 2E3F 74 0A je short Exit + 2E41 3B 43 14 cmp eax, dword ptr[ebx+HANDL + E] ; look for the "father" sample + 2E44 74 09 je short found + 2E46 83 C3 2C add ebx, STRUCT_SIZE + 2E49 EB F1 jmp short keeplooking1 + 2E4B exit: + 2E4B 33 C0 xor eax, eax + 2E4D EB 76 jmp endcritical + 2E4F found: + 2E4F 89 4B 10 mov dword ptr[ebx+SON], ecx + ; connect it to ist "son" + 2E52 NoPlug: + 2E52 33 C0 xor eax, eax + 2E54 83 EF 2C sub edi, STRUCT_SIZE + + 2E57 83 C7 2C SearchEnd: add edi, STRUCT_SIZE + 2E5A 3B 07 cmp eax, dword ptr[edi] + 2E5C 75 F9 jne short SearchEnd + + 2E5E 89 0D 000025B8 R mov dword ptr[follow], ecx + ; update follow + 2E64 89 4F 14 mov dword ptr[edi+HANDLE], e + cx ; sample handle + 2E67 66| 8B 4D 10 mov cx, word ptr[therepeat] + 2E6B 66| 89 4F 0C mov word ptr[edi+C_REPEAT], + cx ; Repeat + 2E6F 89 77 08 mov dword ptr[edi+LEFT], esi + ; length + 2E72 89 77 1C mov dword ptr[edi+DLENGTH], + esi ; length + 2E75 A1 000025D4 R mov eax, dword ptr[save_1] + 2E7A 89 07 mov dword ptr[edi], eax + ; Start + 2E7C 89 47 18 mov dword ptr[edi+START], ea + x ; Start + 2E7F A1 000025D8 R mov eax, dword ptr[save_2] + 2E84 66| 89 47 0E mov word ptr[edi+INCR], ax + ; increment + 2E88 C7 47 04 00010000 mov dword ptr[edi+FRACT], 10 + 000h ; fractional (with 1 above so != 0) + 2E8F C7 47 10 FFFFFFFF mov dword ptr[edi+SON], -1 + ; son + 2E96 C7 47 24 FFFFFFFF mov dword ptr[edi+INFO0], -1 + ; info0 + 2E9D 58 pop eax + 2E9E 88 47 28 mov [edi+INTERPOL], al + ; filter on/off + 2EA1 C6 47 29 80 mov byte ptr[edi+LAST_SAMPLE + ], 80h ; 80h ( 0 ) + ifdef STEREO + ifdef SAMPLE16BIT + 2EA5 8B 45 18 mov eax, volleft + 2EA8 C1 E8 02 shr eax, SHIFT_SAMPLE - 1 + ; Preshift according to number of channe + ls + 2EAB 66| 89 47 20 mov word ptr[edi+VOL_LEFT], + ax + 2EAF 8B 45 1C mov eax, volright + 2EB2 C1 E8 02 shr eax, SHIFT_SAMPLE - 1 + ; Preshift according to number of channe + ls + + ifdef SURROUND + neg eax + endif + + 2EB5 66| 89 47 22 mov word ptr[edi+VOL_RIGHT], + ax + else + mov si, 2 + ; right + mov ecx, volleft + or ecx, ecx + jz short storepos + okleft: mov eax, volright + shl eax, 7 + ; * 128 + xor edx, edx + div ecx + cmp eax, 74 + ; 1.732 (= tan 60) * 128 + jb short storepos + dec si + ; left + cmp eax, 222 + ; .577 (= tan 30) * 128 + jae short storepos + dec si + ; middle + storepos: mov word ptr[edi+VOL_LEFT], + si ; Store position (0:middle, 1:left, 2:ri + ght) + mov word ptr[edi+VOL_RIGHT], + 1 ; to fill with non 0 + endif + else + ifdef SAMPLE16BIT + mov eax, volleft + imul eax, eax + mov ecx, volright + imul ecx, ecx + add eax, ecx + call sqr2 + shr eax, SHIFT_SAMPLE - 1 + ; Preshift according to number of channe + ls + mov word ptr[edi+VOL_LEFT], + ax ; VOL_LEFT = sqr(volleft^2 + volright^2) + mov word ptr[edi+VOL_RIGHT], + 1 ; to fill with non 0 + else + mov dword ptr[edi+VOL_LEFT], + 1 ; to fill with non 0 + endif + endif + 2EB9 C7 47 2C 00000000 mov dword ptr[edi+STRUCT_SIZ + E], 0 ; mark end of List + + 2EC0 A1 000025B8 R mov eax, dword ptr[follow] + 2EC5 endcritical: + END_CRIT_SECT + 1 local NoUpdate + 1 ; Update buffer if necessary + 1 + 1 ; Dealing with the critical sect + 1 ion flags................ + 1 ; + 1 DO NOT TOUCH !!!! + 1 + 2EC5 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect. + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2ECE 66| 83 3D 00002582 R 1 cmp word ptr[DoUpdate], 0 + 00 1 ; IRQ happened ? + 2ED6 74 22 1 je ??0006 ; + 1 if DopUpdate change to 0 now, we are in deep + 1 + 1 ; shit anyway because we missed one round! + 1 + 1 ; The program won't crash but we'll ear the old + 1 + 1 ; content of half a buffer and also miss half a + 1 buffer + 1 + 1 ; of new data... :-( + 2ED8 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; yes, crit. again, so we don't update twice + 1 + 1 ; because UpdateBuffer is not reentrant + 1 + 1 ; and we don't want to take a chance on crashing + 1 ! + 2EE1 60 1 pushad + 1 ; if DoUpdate change to 1 HERE + 1 + 1 ; it means again that we missed one round! + 1 + 1 ; So we play the buffer we are updating! (funny + 1 noise :-( ) + 1 + 1 ; and then will ear half buffer of old data! + 2EE2 E8 FFFFF7B3 1 call UpdateBuffer + 1 ; do the update + 2EE7 61 1 popad + 2EE8 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2EF1 66| C7 05 00002582 R 1 mov word ptr[DoUpdate], 0 + 0000 1 ; Update done, so DoUpdate = 0 + 2EFA 1 ??0006: + 1 + 1 + 1 ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !! + 1 !! + 1 + 1 ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE B + 1 UFFER + 1 + 1 ; TAKES MORE THAN 46000 microsec! + 1 + 1 ; (at 33 Mhz one cycle = .03 microsec so 4600 mi + 1 crosec = 1.5 million cycle) + + ret + 2EFA 5B * pop ebx + 2EFB 5F * pop edi + 2EFC 5E * pop esi + 2EFD C9 * leave + 2EFE C3 * ret 00000h + 2EFF typeunknown: + 2EFF 58 pop eax + 2F00 33 C0 xor eax, eax + ret + 2F02 5B * pop ebx + 2F03 5F * pop edi + 2F04 5E * pop esi + 2F05 C9 * leave + 2F06 C3 * ret 00000h + + 2F07 MixSample ENDP + + ;*---------------------------------------------- + ----------------------------* + + ifdef SINGLE_DMA + + BlockTransfert PROC + + push ebx + + mov ecx, BUFFER_SIZE * SSIZE + cmp word ptr[DMA_number], 3 + jbe noLengthAdj + shr ecx, 1 + NoLengthAdj: + dec ecx + ; buffer size - 1 + + mov ebx, dword ptr[DMA] + ; Point to DMAx + + mov dx, word ptr[ebx + MASK_ + REG] + mov al, byte ptr[ebx + MASK2 + ] ; mask channel + out dx, al + + mov dx, word ptr[ebx + FF_RE + G] + out dx, al + ; flip-flop + + + mov dx, word ptr[ebx + COUNT + _REG] + mov al, cl + ; buffer size - 1 + out dx, al + mov al, ch + out dx, al + + mov dx, word ptr[ebx + ADDX_ + REG] + mov eax, dword ptr[BufferHal + f] + mov eax, dword ptr[BUFFER_DM + A+eax] ; start offset + cmp word ptr[DMA_number], 3 + jbe noAddrAdj + shr eax, 1 + NoAddrAdj: + out dx, al + shr eax, 8 + out dx, al + + mov dx, word ptr[ebx + PAGE_ + REG] + shr eax, 8 + ; page of DMA transfert + out dx, al + + mov dx, word ptr[ebx + MODE_ + REG] + mov al, byte ptr[ebx + VOICE + _OUT] ; output sample + out dx, al + + mov dx, word ptr[ebx + MASK_ + REG] + mov al, byte ptr[ebx + MASK1 + ] ; channel OK + out dx, al + + pop ebx + + jmp StartDMACard + + BlockTransfert ENDP + + endif + + ;*---------------------------------------------- + ----------------------------* + + 2F07 PauseSample PROC + + 2F07 33 C0 xor eax, eax + + CRIT_SECT + 1 + 2F09 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; tell the IRQ not to update the buffer + 1 + 1 ; we'll take care of it if nescessary O:-) + + 2F12 A0 00002559 R mov al, byte ptr[FlagPause] + 2F17 FE C8 dec al + 2F19 24 02 and al, 10b + 2F1B 0C 01 or al, 01b + ; 0->3, 1->1, 2->1, 3->3 + 2F1D A2 00002559 R mov byte ptr[FlagPause], al + 2F22 D1 E8 shr eax, 1 + 2F24 34 01 xor al, 1 + + END_CRIT_SECT + 1 local NoUpdate + 1 ; Update buffer if necessary + 1 + 1 ; Dealing with the critical sect + 1 ion flags................ + 1 ; + 1 DO NOT TOUCH !!!! + 1 + 2F26 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect. + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2F2F 66| 83 3D 00002582 R 1 cmp word ptr[DoUpdate], 0 + 00 1 ; IRQ happened ? + 2F37 74 22 1 je ??0007 ; + 1 if DopUpdate change to 0 now, we are in deep + 1 + 1 ; shit anyway because we missed one round! + 1 + 1 ; The program won't crash but we'll ear the old + 1 + 1 ; content of half a buffer and also miss half a + 1 buffer + 1 + 1 ; of new data... :-( + 2F39 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; yes, crit. again, so we don't update twice + 1 + 1 ; because UpdateBuffer is not reentrant + 1 + 1 ; and we don't want to take a chance on crashing + 1 ! + 2F42 60 1 pushad + 1 ; if DoUpdate change to 1 HERE + 1 + 1 ; it means again that we missed one round! + 1 + 1 ; So we play the buffer we are updating! (funny + 1 noise :-( ) + 1 + 1 ; and then will ear half buffer of old data! + 2F43 E8 FFFFF752 1 call UpdateBuffer + 1 ; do the update + 2F48 61 1 popad + 2F49 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2F52 66| C7 05 00002582 R 1 mov word ptr[DoUpdate], 0 + 0000 1 ; Update done, so DoUpdate = 0 + 2F5B 1 ??0007: + 1 + 1 + 1 ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !! + 1 !! + 1 + 1 ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE B + 1 UFFER + 1 + 1 ; TAKES MORE THAN 46000 microsec! + 1 + 1 ; (at 33 Mhz one cycle = .03 microsec so 4600 mi + 1 crosec = 1.5 million cycle) + + 2F5B C3 ret + + 2F5C PauseSample ENDP + + ;*---------------------------------------------- + ----------------------------* + + 2F5C ContinueSample PROC + + 2F5C 33 C0 xor eax, eax + + CRIT_SECT + 1 + 2F5E 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; tell the IRQ not to update the buffer + 1 + 1 ; we'll take care of it if nescessary O:-) + + 2F67 A0 00002559 R mov al, byte ptr[FlagPause] + 2F6C FE C0 inc al + 2F6E 24 02 and al, 10b + ; 0->0, 1->2, 2->2, 3->0 + 2F70 A2 00002559 R mov byte ptr[FlagPause], al + 2F75 D1 E8 shr eax, 1 + + END_CRIT_SECT + 1 local NoUpdate + 1 ; Update buffer if necessary + 1 + 1 ; Dealing with the critical sect + 1 ion flags................ + 1 ; + 1 DO NOT TOUCH !!!! + 1 + 2F77 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect. + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2F80 66| 83 3D 00002582 R 1 cmp word ptr[DoUpdate], 0 + 00 1 ; IRQ happened ? + 2F88 74 22 1 je ??0008 ; + 1 if DopUpdate change to 0 now, we are in deep + 1 + 1 ; shit anyway because we missed one round! + 1 + 1 ; The program won't crash but we'll ear the old + 1 + 1 ; content of half a buffer and also miss half a + 1 buffer + 1 + 1 ; of new data... :-( + 2F8A 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; yes, crit. again, so we don't update twice + 1 + 1 ; because UpdateBuffer is not reentrant + 1 + 1 ; and we don't want to take a chance on crashing + 1 ! + 2F93 60 1 pushad + 1 ; if DoUpdate change to 1 HERE + 1 + 1 ; it means again that we missed one round! + 1 + 1 ; So we play the buffer we are updating! (funny + 1 noise :-( ) + 1 + 1 ; and then will ear half buffer of old data! + 2F94 E8 FFFFF701 1 call UpdateBuffer + 1 ; do the update + 2F99 61 1 popad + 2F9A 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 2FA3 66| C7 05 00002582 R 1 mov word ptr[DoUpdate], 0 + 0000 1 ; Update done, so DoUpdate = 0 + 2FAC 1 ??0008: + 1 + 1 + 1 ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !! + 1 !! + 1 + 1 ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE B + 1 UFFER + 1 + 1 ; TAKES MORE THAN 46000 microsec! + 1 + 1 ; (at 33 Mhz one cycle = .03 microsec so 4600 mi + 1 crosec = 1.5 million cycle) + + 2FAC C3 ret + + 2FAD ContinueSample ENDP + + ;----------------------------------------------- + ----------------------------- + + ifndef NOIRQ + + 2FAD InstallISR PROC + + 2FAD 52 push edx + + 2FAE 8A 1D 000025B0 R mov bl, byte ptr[INT_number] + ; plug ISR on user INT + 2FB4 66| 8C C9 mov cx, cs + SET_PROT_VECT + 1 + 2FB7 66| B8 0205 1 mov ax, 0205h + 2FBB CD 31 1 int 31h + 1 + + 2FBD 5A pop edx + + 2FBE 83 3D 000025A8 R cmp dword ptr[IRQ_number], 7 + 07 ; if IRQ > 7 + 2FC5 76 25 jbe nobi + + 2FC7 B3 18 mov bl, 18h + ; plug as well on int 18h + 2FC9 66| 8C C9 mov cx, cs + SET_PROT_VECT + 1 + 2FCC 66| B8 0205 1 mov ax, 0205h + 2FD0 CD 31 1 int 31h + 1 + + 2FD2 8A 1D 000025B0 R mov bl, byte ptr[INT_number] + ; plug into real usr INT + 2FD8 B9 000025F0 R mov ecx, offset Redirector + 2FDD 66| 8B D1 mov dx, cx + ; compute real-mode + 2FE0 66| 33 C9 xor cx, cx + ; seg:ofs + 2FE3 C1 E9 04 shr ecx, 4 + SET_REAL_VECT + 1 + 2FE6 66| B8 0201 1 mov ax, 0201h + 2FEA CD 31 1 int 31h + 1 + 2FEC nobi: + 2FEC C3 ret + + 2FED InstallISR ENDP + + endif + + ;----------------------------------------------- + ----------------------------- + + 2FED InitCard PROC USES EBX EDI ESI EBP,\ + Buffer:DWORD + + ifndef NOIRQ + 2FED 55 * push ebp + 2FEE 8B EC * mov ebp, esp + 2FF0 53 * push ebx + 2FF1 57 * push edi + 2FF2 56 * push esi + 2FF3 55 * push ebp + 2FF4 66| 8C 1D 0000262E R mov word ptr[local_DS], ds + endif + 2FFB 8B 45 08 mov eax, Buffer + 2FFE A3 000025E4 R mov dword ptr[BUFFER_DMA], e + ax + + ifndef SBPRO + 3003 E8 0000042E call ResetCard + endif + + ifndef NOIRQ + + 3008 33 C0 xor eax, eax + 300A 66| A1 000025AC R mov ax, word ptr[DMA_number] + 3010 66| 83 F8 07 cmp ax, 7 + 3014 77 0B ja short ErrorDMA + 3016 8B 04 85 00000148 R mov eax, dword ptr[TAB_DMA+e + ax*4] + 301D 0B C0 or eax, eax + 301F 75 08 jnz short DMAFound + 3021 ErrorDMA: + 3021 33 C0 xor eax, eax + ret + 3023 5D * pop ebp + 3024 5E * pop esi + 3025 5F * pop edi + 3026 5B * pop ebx + 3027 C9 * leave + 3028 C3 * ret 00000h + 3029 DMAFound: + 3029 A3 000025C0 R mov dword ptr[DMA], eax + + 302E A1 000025A8 R mov eax, dword ptr[IRQ_numbe + r] + 3033 3C 07 cmp al, 7 + 3035 77 04 ja short Second + 3037 04 08 add al, 8 + 3039 EB 02 jmp short gotvect + 303B Second: + 303B 04 68 add al, 70h - 8 + 303D gotvect: + 303D A3 000025B0 R mov dword ptr[INT_number], e + ax ; save user int + + 3042 8A D8 mov bl, al + GET_PROT_VECT + 1 + 3044 66| B8 0204 1 mov ax, 0204h + 3048 CD 31 1 int 31h + 1 + 304A 66| 89 0D 00002586 R mov word ptr[Old_PIRQ_Sel], + cx + 3051 89 15 0000258C R mov dword ptr[Old_PIRQ_Off], + edx + + 3057 83 3D 000025A8 R cmp dword ptr[IRQ_number], 7 + 07 + 305E 76 2F jbe nobi + + 3060 8A 1D 000025B0 R mov bl, byte ptr[INT_number] + ; if IRQ>7 save real vect + GET_REAL_VECT + 1 + 3066 66| B8 0200 1 mov ax, 0200h + 306A CD 31 1 int 31h + 1 + 306C 66| 89 0D 00002584 R mov word ptr[Old_RIRQ_Seg], + cx + 3073 66| 89 15 0000258A R mov word ptr[Old_RIRQ_Off], + dx + + 307A B3 18 mov bl, 18h + ; if IRQ>7 save int 18h + GET_PROT_VECT + 1 + 307C 66| B8 0204 1 mov ax, 0204h + 3080 CD 31 1 int 31h + 1 + 3082 66| 89 0D 00002588 R mov word ptr[Old_18_Sel], cx + 3089 89 15 00002590 R mov dword ptr[Old_18_Off], e + dx + 308F nobi: + + 308F 66| BA 0021 mov dx, 21h + ; IRQ mask reg + 3093 66| 8B 0D 000025A8 R mov cx, word ptr[IRQ_number] + 309A 66| 83 F9 07 cmp cx, 7 + 309E 76 04 jbe short Ok21 + 30A0 66| BA 00A1 mov dx, 0A1h + ; reg A1h, 2nd ctrl + 30A4 EC Ok21: in al, dx + 30A5 A2 00002558 R mov byte ptr[IRQ_mask], al + ; save mask + 30AA 80 E1 07 and cl, 7 + 30AD B3 01 mov bl, 1 + 30AF D2 E3 shl bl, cl + 30B1 F6 D3 not bl + 30B3 22 C3 and al, bl + ; unmask IRQ + 30B5 EE out dx, al + ; write new mask + + ifdef SBPRO + call ResetCard + endif + + 30B6 BA 00002628 R mov edx, offset NewIRQ + 30BB E8 FFFFFEED call InstallISR + endif + 30C0 E8 FFFFF96C call StopSample + ; to reset everything + + 30C5 33 C0 xor eax, eax + 30C7 A3 00001298 R mov dword ptr[BackCurrentLis + t], eax + 30CC A3 00001B30 R mov dword ptr[BackSonList], + eax + + 30D1 8B 3D 000025E4 R mov edi, dword ptr[BUFFER_DM + A] + + 30D7 8B C7 mov eax, edi + 30D9 05 00001000 add eax, BUFFER_SIZE * SSIZE + 30DE A3 000025E8 R mov dword ptr[MID_BUFFER_DMA + ], eax ; init pointer + 30E3 A3 000025EC R mov dword ptr[CURRENT_BUFFER + ], eax ; init pointer + + 30E8 C7 05 000025B4 R mov dword ptr[BufferHalf], 4 + 00000004 ; point on second half + + 30F2 B9 00000800 mov ecx, (BUFFER_SIZE * 2 * + SSIZE) / 4; clear all buffer + MIDPOINT + 1 + 1 IFDEF SAMPLE16BIT + 30F7 33 C0 1 xor eax, eax + 1 ELSE + 1 mov eax, 80808080h + 1 ENDIF + 1 + 30F9 F3/ AB rep stosd + + ifndef NOIRQ + + ifdef AUTO_DMA + + 30FB B9 00002000 mov ecx, BUFFER_SIZE * 2 * S + SIZE + 3100 66| 83 3D 000025AC R cmp word ptr[DMA_number], 3 + 03 + 3108 76 02 jbe noLengthAdj + 310A D1 E9 shr ecx, 1 + 310C NoLengthAdj: + 310C 49 dec ecx + + 310D 8B 1D 000025C0 R mov ebx, dword ptr[DMA] + ; Point to DMAx + + 3113 66| 8B 53 08 mov dx, word ptr[ebx + MASK_ + REG] + 3117 8A 43 03 mov al, byte ptr[ebx + MASK2 + ] ; mask channel + 311A EE out dx, al + + 311B 66| 8B 53 0C mov dx, word ptr[ebx + FF_RE + G] + 311F EE out dx, al + ; flip-flop + + 3120 66| 8B 53 06 mov dx, word ptr[ebx + COUNT + _REG] + 3124 8A C1 mov al, cl + ; buffer size - 1 + 3126 EE out dx, al + 3127 8A C5 mov al, ch + 3129 EE out dx, al + + 312A 66| 8B 53 04 mov dx, word ptr[ebx + ADDX_ + REG] + 312E A1 000025E4 R mov eax, dword ptr[BUFFER_DM + A] ; start offset + 3133 66| 83 3D 000025AC R cmp word ptr[DMA_number], 3 + 03 + 313B 76 0D jbe noAddrAdj + ; shr eax, 1 + 313D D1 E8 shr eax, 1 + 313F 66| 8B F8 mov di, ax + 3142 66| 33 C0 xor ax, ax + 3145 D1 E0 shl eax, 1 + 3147 66| 8B C7 mov ax, di + 314A NoAddrAdj: + 314A EE out dx, al + 314B C1 E8 08 shr eax, 8 + 314E EE out dx, al + + 314F 66| 8B 53 0E mov dx, word ptr[ebx + PAGE_ + REG] + 3153 C1 E8 08 shr eax, 8 + ; page of DMA transfert + 3156 EE out dx, al + + 3157 66| 8B 53 0A mov dx, word ptr[ebx + MODE_ + REG] + 315B 8A 43 01 mov al, byte ptr[ebx + AUTO_ + OUT] ; output sample + 315E EE out dx, al + + 315F 66| 8B 53 08 mov dx, word ptr[ebx + MASK_ + REG] + 3163 8A 43 02 mov al, byte ptr[ebx + MASK1 + ] ; channel OK + 3166 EE out dx, al + endif + + endif + + ifdef AUTO_DMA + 3167 E8 000003B8 call StartDMACard + elseifdef SINGLE_DMA + call BlockTransfert + ; Start DMA transfert + endif + 316C B8 00000001 mov eax, 1 + ret + 3171 5D * pop ebp + 3172 5E * pop esi + 3173 5F * pop edi + 3174 5B * pop ebx + 3175 C9 * leave + 3176 C3 * ret 00000h + + 3177 InitCard ENDP + + ;----------------------------------------------- + ----------------------------- + + 3177 ClearCard PROC USES EBX ESI EDI EBP + + 3177 53 * push ebx + 3178 56 * push esi + 3179 57 * push edi + 317A 55 * push ebp + 317B E8 FFFFF8B1 call StopSample + ; just in case something was playing... + 3180 E8 00000359 call CloseCard + + ifndef NOIRQ + 3185 66| BA 0021 mov dx, 21h + ; read IRQ mask + 3189 66| 83 3D 000025A8 R cmp word ptr[IRQ_number], 7 + 07 + 3191 76 05 jbe short Ok21 + 3193 66| 81 C2 0080 add dx, 80h + ; reg 0A1h + 3198 A0 00002558 R Ok21: mov al, byte ptr[IRQ_mask] + ; get old mask + 319D EE out dx, al + ; write old IRQ mask + + 319E 8A 1D 000025B0 R mov bl, byte ptr[INT_number] + 31A4 66| 8B 0D 00002586 R mov cx, word ptr[Old_PIRQ_se + l] + 31AB 8B 15 0000258C R mov edx, dword ptr[Old_PIRQ_ + off] + SET_PROT_VECT + 1 + 31B1 66| B8 0205 1 mov ax, 0205h + 31B5 CD 31 1 int 31h + 1 + + 31B7 83 3D 000025A8 R cmp dword ptr[IRQ_number], 7 + 07 + 31BE 76 2F jbe nobi + + 31C0 8A 1D 000025B0 R mov bl, byte ptr[INT_number] + 31C6 66| 8B 0D 00002584 R mov cx, word ptr[Old_RIRQ_se + g] + 31CD 66| 8B 15 0000258A R mov dx, word ptr[Old_RIRQ_of + f] + SET_REAL_VECT + 1 + 31D4 66| B8 0201 1 mov ax, 0201h + 31D8 CD 31 1 int 31h + 1 + + 31DA B3 18 mov bl, 18h + 31DC 66| 8B 0D 00002588 R mov cx, word ptr[Old_18_sel] + 31E3 8B 15 00002590 R mov edx, dword ptr[Old_18_of + f] + SET_PROT_VECT + 1 + 31E9 66| B8 0205 1 mov ax, 0205h + 31ED CD 31 1 int 31h + 1 + 31EF nobi: + + endif + + ret + 31EF 5D * pop ebp + 31F0 5F * pop edi + 31F1 5E * pop esi + 31F2 5B * pop ebx + 31F3 C3 * ret 00000h + + 31F4 ClearCard ENDP + + ;----------------------------------------------- + ----------------------------- + + 31F4 AskVars PROC ,\ + pListNames:DWORD, pListVars:DWOR + D + + 31F4 55 * push ebp + 31F5 8B EC * mov ebp, esp + 31F7 B8 00002594 R mov eax, offset ListNames + 31FC 8B 4D 08 mov ecx, pListNames + 31FF 89 01 mov dword ptr[ecx], eax + 3201 B8 000025A0 R mov eax, offset ListVars + 3206 8B 4D 0C mov ecx, pListVars + 3209 89 01 mov dword ptr[ecx], eax + ret + 320B C9 * leave + 320C C3 * ret 00000h + + 320D AskVars ENDP + + + ;----------------------------------------------- + ----------------------------- + + 320D GetBufferSize PROC + + 320D B8 00002000 mov eax, BUFFER_SIZE * 2 * S + SIZE + + 3212 C3 ret + + 3213 GetBufferSize ENDP + + ;----------------------------------------------- + ----------------------------- + + 3213 GiveSampleInfo0 PROC \ + LongHandle:DWORD, Info:DWORD + + 3213 55 * push ebp + 3214 8B EC * mov ebp, esp + 3216 8B 45 08 mov eax, LongHandle + + CRIT_SECT + 1 + 3219 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; tell the IRQ not to update the buffer + 1 + 1 ; we'll take care of it if nescessary O:-) + + 3222 E8 FFFFFA73 call SearchLongHandle + 3227 0B D2 or edx, edx + 3229 74 06 jz short notfound + + 322B 8B 45 0C mov eax, Info + 322E 89 42 24 mov dword ptr[edx+INFO0], ea + x + 3231 notfound: + END_CRIT_SECT + 1 local NoUpdate + 1 ; Update buffer if necessary + 1 + 1 ; Dealing with the critical sect + 1 ion flags................ + 1 ; + 1 DO NOT TOUCH !!!! + 1 + 3231 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect. + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 323A 66| 83 3D 00002582 R 1 cmp word ptr[DoUpdate], 0 + 00 1 ; IRQ happened ? + 3242 74 22 1 je ??0009 ; + 1 if DopUpdate change to 0 now, we are in deep + 1 + 1 ; shit anyway because we missed one round! + 1 + 1 ; The program won't crash but we'll ear the old + 1 + 1 ; content of half a buffer and also miss half a + 1 buffer + 1 + 1 ; of new data... :-( + 3244 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; yes, crit. again, so we don't update twice + 1 + 1 ; because UpdateBuffer is not reentrant + 1 + 1 ; and we don't want to take a chance on crashing + 1 ! + 324D 60 1 pushad + 1 ; if DoUpdate change to 1 HERE + 1 + 1 ; it means again that we missed one round! + 1 + 1 ; So we play the buffer we are updating! (funny + 1 noise :-( ) + 1 + 1 ; and then will ear half buffer of old data! + 324E E8 FFFFF447 1 call UpdateBuffer + 1 ; do the update + 3253 61 1 popad + 3254 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 325D 66| C7 05 00002582 R 1 mov word ptr[DoUpdate], 0 + 0000 1 ; Update done, so DoUpdate = 0 + 3266 1 ??0009: + 1 + 1 + 1 ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !! + 1 !! + 1 + 1 ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE B + 1 UFFER + 1 + 1 ; TAKES MORE THAN 46000 microsec! + 1 + 1 ; (at 33 Mhz one cycle = .03 microsec so 4600 mi + 1 crosec = 1.5 million cycle) + + ret + 3266 C9 * leave + 3267 C3 * ret 00000h + + 3268 GiveSampleInfo0 ENDP + + ;----------------------------------------------- + ----------------------------- + + 3268 GetSnapSample PROC USES EBX,\ + pList:DWORD + + 3268 55 * push ebp + 3269 8B EC * mov ebp, esp + 326B 53 * push ebx + 326C 8D 05 000023C8 R lea eax, SnapList + 3272 8B 55 08 mov edx, pList + 3275 89 02 mov dword ptr[edx], eax + + 3277 8D 15 00000168 R lea edx, CurrentList + 327D 8D 0D 00000A00 R lea ecx, SonList + + CRIT_SECT + 1 + 3283 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; tell the IRQ not to update the buffer + 1 + 1 ; we'll take care of it if nescessary O:-) + + 328C 83 3A 00 keeplooking: cmp dword ptr[edx], 0 + 328F 74 1B je short exit + + 3291 8B 5A 14 mov ebx, dword ptr[edx+HANDL + E] + 3294 89 18 mov dword ptr[eax], ebx + 3296 8B 5A 24 mov ebx, dword ptr[edx+INFO0 + ] + 3299 89 58 04 mov dword ptr[eax+4], ebx + 329C 8B 1A mov ebx, dword ptr[edx] + 329E 2B 5A 18 sub ebx, dword ptr[edx+START + ] + 32A1 89 58 08 mov dword ptr[eax+8], ebx + + 32A4 83 C0 0C add eax, 12 + 32A7 83 C2 2C add edx, STRUCT_SIZE + 32AA EB E0 jmp short keeplooking + 32AC exit: + 32AC 3B CA cmp ecx, edx + 32AE 8B D1 mov edx, ecx + 32B0 75 DA jne keeplooking + + END_CRIT_SECT + 1 local NoUpdate + 1 ; Update buffer if necessary + 1 + 1 ; Dealing with the critical sect + 1 ion flags................ + 1 ; + 1 DO NOT TOUCH !!!! + 1 + 32B2 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect. + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 32BB 66| 83 3D 00002582 R 1 cmp word ptr[DoUpdate], 0 + 00 1 ; IRQ happened ? + 32C3 74 22 1 je ??000A ; + 1 if DopUpdate change to 0 now, we are in deep + 1 + 1 ; shit anyway because we missed one round! + 1 + 1 ; The program won't crash but we'll ear the old + 1 + 1 ; content of half a buffer and also miss half a + 1 buffer + 1 + 1 ; of new data... :-( + 32C5 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; yes, crit. again, so we don't update twice + 1 + 1 ; because UpdateBuffer is not reentrant + 1 + 1 ; and we don't want to take a chance on crashing + 1 ! + 32CE 60 1 pushad + 1 ; if DoUpdate change to 1 HERE + 1 + 1 ; it means again that we missed one round! + 1 + 1 ; So we play the buffer we are updating! (funny + 1 noise :-( ) + 1 + 1 ; and then will ear half buffer of old data! + 32CF E8 FFFFF3C6 1 call UpdateBuffer + 1 ; do the update + 32D4 61 1 popad + 32D5 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 32DE 66| C7 05 00002582 R 1 mov word ptr[DoUpdate], 0 + 0000 1 ; Update done, so DoUpdate = 0 + 32E7 1 ??000A: + 1 + 1 + 1 ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !! + 1 !! + 1 + 1 ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE B + 1 UFFER + 1 + 1 ; TAKES MORE THAN 46000 microsec! + 1 + 1 ; (at 33 Mhz one cycle = .03 microsec so 4600 mi + 1 crosec = 1.5 million cycle) + + 32E7 2D 000023C8 R sub eax, offset SnapList + 32EC C1 E8 03 shr eax, 3 + + ret + 32EF 5B * pop ebx + 32F0 C9 * leave + 32F1 C3 * ret 00000h + + 32F2 GetSnapSample ENDP + + + ;----------------------------------------------- + ----------------------------- + + 32F2 CopyList PROC + + 32F2 83 3E 00 keepcopying: cmp dword ptr[esi], 0 + 32F5 74 09 je short endcopy + 32F7 B9 0000000B mov ecx, STRUCT_SIZE / 4 + 32FC F3/ A5 rep movsd + 32FE EB F2 jmp short keepcopying + 3300 C7 07 00000000 endcopy: mov dword ptr[edi], 0 + 3306 C3 ret + + 3307 CopyList ENDP + + ;----------------------------------------------- + ----------------------------- + + 3307 SAveStateSample PROC USES ESI EDI + + 3307 56 * push esi + 3308 57 * push edi + 3309 E8 FFFFFBF9 call PauseSample + + 330E 80 3D 00002559 R waitpause: cmp byte ptr[FlagPause], 1 + 01 + 3315 75 F7 jne short waitpause + + CRIT_SECT + 1 + 3317 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; tell the IRQ not to update the buffer + 1 + 1 ; we'll take care of it if nescessary O:-) + + 3320 8D 35 00000168 R lea esi, CurrentList + ; backup CurrentList + 3326 8D 3D 00001298 R lea edi, BackCurrentList + 332C E8 FFFFFFC1 call CopyList + 3331 8D 35 00000A00 R lea esi, SonList + ; backup SonList + 3337 8D 3D 00001B30 R lea edi, BackSonList + 333D E8 FFFFFFB0 call CopyList + 3342 A1 000025B8 R mov eax, dword ptr[follow] + ; Backup follow + 3347 A3 000025BC R mov dword ptr[backfollow], e + ax + 334C A1 000025C4 R mov eax, dword ptr[weirdcoun + t] ; Backup weirdcount + 3351 A3 000025C8 R mov dword ptr[backweirdcount + ], eax + + 3356 33 C0 xor eax, eax + ; empty both lists + 3358 A3 00000168 R mov dword ptr[CurrentList], + eax + 335D A3 00000A00 R mov dword ptr[SonList], eax + + 3362 C6 05 00002559 R mov byte ptr[FlagPause], 0 + 00 + + END_CRIT_SECT + 1 local NoUpdate + 1 ; Update buffer if necessary + 1 + 1 ; Dealing with the critical sect + 1 ion flags................ + 1 ; + 1 DO NOT TOUCH !!!! + 1 + 3369 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect. + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 3372 66| 83 3D 00002582 R 1 cmp word ptr[DoUpdate], 0 + 00 1 ; IRQ happened ? + 337A 74 22 1 je ??000B ; + 1 if DopUpdate change to 0 now, we are in deep + 1 + 1 ; shit anyway because we missed one round! + 1 + 1 ; The program won't crash but we'll ear the old + 1 + 1 ; content of half a buffer and also miss half a + 1 buffer + 1 + 1 ; of new data... :-( + 337C 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; yes, crit. again, so we don't update twice + 1 + 1 ; because UpdateBuffer is not reentrant + 1 + 1 ; and we don't want to take a chance on crashing + 1 ! + 3385 60 1 pushad + 1 ; if DoUpdate change to 1 HERE + 1 + 1 ; it means again that we missed one round! + 1 + 1 ; So we play the buffer we are updating! (funny + 1 noise :-( ) + 1 + 1 ; and then will ear half buffer of old data! + 3386 E8 FFFFF30F 1 call UpdateBuffer + 1 ; do the update + 338B 61 1 popad + 338C 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 3395 66| C7 05 00002582 R 1 mov word ptr[DoUpdate], 0 + 0000 1 ; Update done, so DoUpdate = 0 + 339E 1 ??000B: + 1 + 1 + 1 ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !! + 1 !! + 1 + 1 ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE B + 1 UFFER + 1 + 1 ; TAKES MORE THAN 46000 microsec! + 1 + 1 ; (at 33 Mhz one cycle = .03 microsec so 4600 mi + 1 crosec = 1.5 million cycle) + + ret + 339E 5F * pop edi + 339F 5E * pop esi + 33A0 C3 * ret 00000h + + 33A1 SAveStateSample ENDP + + ;----------------------------------------------- + ----------------------------- + + 33A1 RestoreStateSample PROC USES ESI EDI + + 33A1 56 * push esi + 33A2 57 * push edi + 33A3 E8 FFFFFB5F call PauseSample + + 33A8 80 3D 00002559 R waitpause: cmp byte ptr[FlagPause], 1 + 01 + 33AF 75 F7 jne short waitpause + + CRIT_SECT + 1 + 33B1 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; tell the IRQ not to update the buffer + 1 + 1 ; we'll take care of it if nescessary O:-) + + 33BA 8D 35 00001298 R lea esi, BackCurrentList + ; restore CurrentList + 33C0 8D 3D 00000168 R lea edi, CurrentList + 33C6 E8 FFFFFF27 call CopyList + 33CB 8D 3D 00001B30 R lea edi, BackSonList + ; restore SonList + 33D1 8D 3D 00000A00 R lea edi, SonList + 33D7 E8 FFFFFF16 call CopyList + 33DC A1 000025BC R mov eax, dword ptr[backfollo + w] ; restore follow + 33E1 A3 000025B8 R mov dword ptr[follow], eax + 33E6 A1 000025C8 R mov eax, dword ptr[backweird + count] ; restore weirdcount + 33EB A1 000025C4 R mov eax, dword ptr[weirdcoun + t] + + END_CRIT_SECT + 1 local NoUpdate + 1 ; Update buffer if necessary + 1 + 1 ; Dealing with the critical sect + 1 ion flags................ + 1 ; + 1 DO NOT TOUCH !!!! + 1 + 33F0 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect. + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 33F9 66| 83 3D 00002582 R 1 cmp word ptr[DoUpdate], 0 + 00 1 ; IRQ happened ? + 3401 74 22 1 je ??000C ; + 1 if DopUpdate change to 0 now, we are in deep + 1 + 1 ; shit anyway because we missed one round! + 1 + 1 ; The program won't crash but we'll ear the old + 1 + 1 ; content of half a buffer and also miss half a + 1 buffer + 1 + 1 ; of new data... :-( + 3403 66| C7 05 00002580 R 1 mov word ptr[Critical], 1 + 0001 1 ; yes, crit. again, so we don't update twice + 1 + 1 ; because UpdateBuffer is not reentrant + 1 + 1 ; and we don't want to take a chance on crashing + 1 ! + 340C 60 1 pushad + 1 ; if DoUpdate change to 1 HERE + 1 + 1 ; it means again that we missed one round! + 1 + 1 ; So we play the buffer we are updating! (funny + 1 noise :-( ) + 1 + 1 ; and then will ear half buffer of old data! + 340D E8 FFFFF288 1 call UpdateBuffer + 1 ; do the update + 3412 61 1 popad + 3413 66| C7 05 00002580 R 1 mov word ptr[Critical], 0 + 0000 1 ; exit crit. sect + 1 + 1 ; this way DoUpdate can't change to 1 anymore + 341C 66| C7 05 00002582 R 1 mov word ptr[DoUpdate], 0 + 0000 1 ; Update done, so DoUpdate = 0 + 3425 1 ??000C: + 1 + 1 + 1 ; ALL THOSE NASTY THING SHOULD NOT HAPPEN :-) !! + 1 !! + 1 + 1 ; BECAUSE IT WOULD MEAN THAT THE UPDATE OF THE B + 1 UFFER + 1 + 1 ; TAKES MORE THAN 46000 microsec! + 1 + 1 ; (at 33 Mhz one cycle = .03 microsec so 4600 mi + 1 crosec = 1.5 million cycle) + + 3425 E8 FFFFFB32 call ContinueSample + + 342A 80 3D 00002559 R waitcontinue: cmp byte ptr[FlagPause], 0 + 00 + 3431 75 F7 jne short waitcontinue + + ret + 3433 5F * pop edi + 3434 5E * pop esi + 3435 C3 * ret 00000h + + 3436 RestoreStateSample ENDP + + ;----------------------------------------------- + ----------------------------- + ;----------------------------------------------- + ----------------------------- + + ifdef MWSS + + ResetCard PROC USES EBX + + + mov ax, word ptr[PlayRate] + cmp ax, 44100 + jae short Freq44 + lea edx, MWSSFreq + SearchFreq: cmp ax, word ptr[edx] + jb short FoundFreq + add edx, 4 + jmp short SearchFreq + Freq44: + mov ax, 44100 + mov cl, 0Bh + jmp short WBack + FoundFreq: + mov ax, word ptr[edx] + ; closest faster speed + mov cl, byte ptr[edx+2] + ; clock select + WBack: + mov word ptr[PlayRate], ax + or cl, 01010000b + ; 16 bit linear, Stereo + + mov edx, [IRQ_number] + ; IRQ + mov al, [MWSSIrq+edx] + + mov edx, [DMA_number] + ; DMA + or al, [MWSSDma+edx] + + mov dx, word ptr[BASE_ADDR] + + add dl, 3 + ; offset 3 + out dx, al + ; program IRQ & DMA + + inc dl + ; offset 4 + mov al, 6 + ; left vol + out dx, al + inc dl + ; offset 5 + mov al, 80h + ; mute + out dx, al + dec dl + ; offset 4 + mov al, 7 + ; right vol + out dx, al + inc dl + ; offset 5 + mov al, 80h + ; mute + out dx, al + + dec dl + ; offset 4 + mov al, 13 + ; digital mix + out dx, al + inc dl + ; offset 5 + xor al, al + ; mute + out dx, al + + dec dl + ; offset 4 + mov al, 2 + ; left aux1 + out dx, al + inc dl + ; offset 5 + mov al, 80h + ; mute + out dx, al + dec dl + ; offset 4 + mov al, 3 + ; right aux1 + out dx, al + inc dl + ; offset 5 + mov al, 80h + ; mute + out dx, al + + dec dl + ; offset 4 + mov al, 4 + ; left aux2 + out dx, al + inc dl + ; offset 5 + mov al, 80h + ; mute + out dx, al + dec dl + ; offset 4 + mov al, 5 + ; right aux2 + out dx, al + inc dl + ; offset 5 + mov al, 80h + ; mute + out dx, al + + dec dl + ; offset 4 + mov al, 49h + ; enter MCE, Interface Ctrl + out dx, al + inc dl + ; offset 5 + mov al, 08h + ; auto-calibrate + out dx, al + + dec dl + ; offset 4 + mov al, 48h + ; MCE, Interface Ctrl + out dx, al + inc dl + ; offset 5 + mov al, cl + ; 16 bit linear, stereo, speed + out dx, al + + dec dl + ; offset 4 + wait_init: in al, dx + and al, 80h + jnz wait_init + + + xor al, al + out dx, al + ; clear MCE + + xor bx, bx + ; at least 6 millisec. + wait0: in al, dx + dec bx + jnz short wait0 + + + wait_cal: mov al, 0Bh + ; Test & Init Reg + out dx, al + inc dl + ; offset 5 + in al, dx + dec dl + ; offset 4 + and al, 20h + jnz wait_cal + + mov al, 6 + ; left vol + out dx, al + inc dl + ; offset 5 + xor al, al + ; max vol + out dx, al + dec dl + ; offset 4 + mov al, 7 + ; right vol + out dx, al + inc dl + ; offset 5 + xor al, al + ; max vol + out dx, al + + ret + + ResetCard ENDP + + ;*---------------------------------------------- + ----------------------------* + + CloseCard PROC + + mov dx, word ptr[BASE_ADDR] + ; DSP + + add dl, 4 + ; offset 4 + mov al, 0Ah + ; Pin Ctrl reg + out dx, al + inc dx + ; offset 5 + xor al, al + ; turn off interrupts + out dx, al + + inc dx + ; offset 6 + out dx, al + ; Ack outstanding interrupts + + sub dl, 2 + ; offset 4 + mov al, 9 + ; Interface Config reg + out dx, al + inc dx + ; offset 5 + xor al, al + ; turn off codec DMA + out dx, al + + sub dl, 2 + out dx, al + ; deselect IRQ and DMA + + ret + + CloseCard ENDP + + ;----------------------------------------------- + ----------------------------- + + AckIrq PROC + + mov dx, word ptr[BASE_ADDR] + ; DSP + add dl, 6 + in al, dx + shr al, 1 + ; get int flag in C + cmc + ; complement C in order to return error + if 0 + out dx, al + ; Ack anyway + ret + + AckIrq ENDP + + ;----------------------------------------------- + ----------------------------- + + StartDMACard PROC + + mov cx, BUFFER_SIZE - 1 + + mov dx, word ptr[BASE_ADDR] + ; DSP + + add dl, 6 + out dx, al + ; clear any pending IRQ + + sub dl, 2 + ; offset 4 + mov al, 15 + ; DMA Count Lower + out dx, al + inc dl + ; offset 5 + mov al, cl + out dx, al + dec dl + ; offset 4 + mov al, 14 + ; DMA Count Upper + out dx, al + inc dl + ; offset 5 + mov al, ch + out dx, al + + dec dl + ; offset 4 + mov al, 9 + ; Interface config + out dx, al + inc dl + ; offset 5 + mov al, 00000101b + ; DMA Playback + out dx, al + dec dl + ; offset 4 + mov al, 0Ah + ; Pin Ctrl Reg + out dx, al + inc dx + ; offset 5 + mov al, 00000010b + ; Turn on Interrupts + out dx, al + + ret + + StartDMACard ENDP + + endif + + ;----------------------------------------------- + ----------------------------- + ;----------------------------------------------- + ----------------------------- + + ifdef SBLASTER + + WRITE_DSP MACRO VAL + ; write to DSP whithout timeout + local wait_dsp + + wait_dsp: in al, dx + or al, al + js wait_dsp + + mov al, VAL + out dx, al + + ENDM + + WRITE_MIXER MACRO REG, VAL + ; write to MIXER chip + + mov al, REG + out dx, al + inc dx + mov al, VAL + out dx, al + dec dx + + ENDM + + READ_MIXER MACRO REG + ; read from MIXER chip + + mov al, REG + out dx, al + inc dx + in al, dx + dec dx + + ENDM + + ifdef SBPRO + + InitIRQ PROC + + pushad + push ds + + mov ax, cs:word ptr[local_DS + ] ; restore DS + mov ds, ax + + mov al, 20h + ; allows for new int + cmp byte ptr[IRQ_number], 7 + jbe short NoSecondCtrl + out 0A0h, al + NoSecondCtrl: out 20h, al + + call AckIrq + jc short FinIRQ + ; not a DMA IRQ + + mov byte ptr[OkIRQ], 1 + FinIRQ: + pop ds + popad + + iretd + + InitIRQ ENDP + + endif + + + 3436 ResetCard PROC + + 3436 81 3D 000025A4 R cmp dword ptr[PlayRate], 120 + 00002EE0 00 + 3440 73 0A jae OkRateLow + 3442 C7 05 000025A4 R mov dword ptr[PlayRate], 120 + 00002EE0 00 + 344C OkRateLow: + + 344C 81 3D 000025A4 R cmp dword ptr[PlayRate], 220 + 000055F0 00 + 3456 76 0A jbe OkRateHigh + 3458 C7 05 000025A4 R mov dword ptr[PlayRate], 220 + 000055F0 00 + 3462 OkRateHigh: + + ifndef SB16 + ifdef SBPRO + mov dx, 07A1h + mov ax, 2000h + ; dx:ax = 128000000 + else + mov dx, 0F42h + mov ax, 4000h + ; dx:ax = 256000000 + endif + div word ptr[PlayRate] + ; divide by PlayRate + neg ax + shr ax, 8 + mov cx, ax + ; cl = "Magic" + + push ecx + + ifdef SBPRO + mov dx, 07h + mov ax, 0A120h + ; dx:ax = 500000 + else + mov dx, 0Fh + mov ax, 4240h + ; dx:ax = 1000000 + endif + neg cl + div cx + ; divide by "-Magic" + mov word ptr[PlayRate], ax + ; write back PlayRate + endif + + 3462 66| 8B 15 000025A0 R mov dx, word ptr[BASE_ADDR] + 3469 80 C2 06 add dl, 6 + ; reset port (offset 6) + 346C B0 01 mov al, 1 + ; write 1 + 346E EE out dx, al + + 346F B4 18 mov ah, 8 * 3 + ; 4 * "in al, dx" = 1 microsec on std IS + A bus (8 Mhz) + 3471 EC wait_io: in al, dx + ; so 8 to be sure if 16 MHz ! + 3472 FE CC dec ah + ; kill the cat ! + 3474 75 FB jnz short wait_io + + 3476 32 C0 xor al, al + 3478 EE out dx, al + ; write 0 + + ; now reset should be done.. + 3479 80 C2 04 add dl, 4 + ; offset 0Ah + + 347C 80 C2 04 Next: add dl, 4 + ; offset 0Eh + + 347F EC Wait_s: in al, dx + 3480 0A C0 or al, al + 3482 79 FB jns Wait_s + + 3484 80 EA 04 sub dl, 4 + ; offset 0Ah + 3487 EC in al, dx + ; read if reset terminated + + 3488 3C AA cmp al, RESET_TEST_CODE + ; should be... + 348A 75 F0 jne Next + + ifdef SB16 + 348C 80 EA 06 sub dl, 6 + ; offset 04h + 348F B0 80 mov al, 80h + 3491 EE out dx, al + 3492 66| 42 inc dx + ; offset 05h + 3494 33 C0 xor eax, eax + 3496 EC in al, dx + 3497 24 0F and al, 0Fh + ; mask reserved bit + 3499 66| 0F BC C0 bsf ax, ax + 349D 8A 80 0000257C R mov al, byte ptr[SB16_IRQ+ea + x] + 34A3 A3 000025A8 R mov dword ptr[IRQ_number], e + ax + 34A8 66| 4A dec dx + ; offset 04h + 34AA B0 81 mov al, 81h + 34AC EE out dx, al + 34AD 66| 42 inc dx + ; offset 05h + 34AF EC in al, dx + 34B0 24 EB and al, 11101011b + ; mask reserved bit + ifdef SAMPLE16BIT + 34B2 66| 0F BD C0 bsr ax, ax + else + bsf ax, ax + endif + 34B6 A3 000025AC R mov dword ptr[DMA_number], e + ax + + 34BB 80 C2 07 add dl, 7 + ; offset 0Ch + WRITE_DSP DSP_RATE_CMD + ; rate + 1 local wait_dsp + 1 + 34BE EC 1 ??000D: in al, dx + 34BF 0A C0 1 or al, al + 34C1 78 FB 1 js ??000D + 1 + 34C3 B0 41 1 mov al, DSP_RATE_CMD + 34C5 EE 1 out dx, al + 1 + 34C6 66| 8B 0D 000025A4 R mov cx, word ptr[PlayRate] + WRITE_DSP ch + ; + 1 local wait_dsp + 1 + 34CD EC 1 ??000E: in al, dx + 34CE 0A C0 1 or al, al + 34D0 78 FB 1 js ??000E + 1 + 34D2 8A C5 1 mov al, ch + 34D4 EE 1 out dx, al + 1 + WRITE_DSP cl + ; + 1 local wait_dsp + 1 + 34D5 EC 1 ??000F: in al, dx + 34D6 0A C0 1 or al, al + 34D8 78 FB 1 js ??000F + 1 + 34DA 8A C1 1 mov al, cl + 34DC EE 1 out dx, al + 1 + else + add dl, 02h + ; offset 0Ch + WRITE_DSP DSP_ONSPK_CMD + ; Turn speaker on + + ifdef SBPRO + + mov edx, offset InitIRQ + ; Temporary IRQ handler + call InstallISR + + mov dx, word ptr[BASE_ADDR] + + add dl, 4 + ; offset 4 + mov al, 0Eh + ; stereo switch & filter + out dx, al + inc dx + ; offset 5 + in al, dx + or al, 2 + ; enable stereo + out dx, al + + mov ecx, dword ptr[DMA] + ; Point to DMAx + + mov dx, word ptr[ecx + MASK_ + REG] + mov al, byte ptr[ecx + MASK2 + ] ; mask channel + out dx, al + + mov dx, word ptr[ecx + FF_RE + G] + out dx, al + ; flip-flop + + + mov dx, word ptr[ecx + COUNT + _REG] + xor al, al + out dx, al + out dx, al + + mov eax, dword ptr[BUFFER_DM + A] ; start offset + mov byte ptr[eax], 80h + ; write a "0" into the buffer + + mov dx, word ptr[ecx + ADDX_ + REG] + out dx, al + shr eax, 8 + out dx, al + + mov dx, word ptr[ecx + PAGE_ + REG] + shr eax, 8 + ; page of DMA transfert + out dx, al + + mov dx, word ptr[ecx + MODE_ + REG] + mov al, byte ptr[ecx + VOICE + _OUT] ; output sample + out dx, al + + mov dx, word ptr[ecx + MASK_ + REG] + mov al, byte ptr[ecx + MASK1 + ] ; channel OK + out dx, al + + mov dx, word ptr[BASE_ADDR] + add dl, 0Ch + ; offset 0Ch + + mov byte ptr[OkIRQ], 0 + + WRITE_DSP DSP_VO8S_CMD + WRITE_DSP 0 + WRITE_DSP 0 + + WaitIRQ: cmp byte ptr[OkIRQ], 1 + jne short WaitIRQ + + sub dl, 8 + ; offset 4 + mov al, 0Eh + ; stereo switch & filter + out dx, al + inc dx + ; offset 5 + in al, dx + mov byte ptr[Filter], al + or al, 20h + ; disable filter + out dx, al + add dl, 7 + ; offset 0Ch + endif + + pop ecx + + WRITE_DSP DSP_TIME_CMD + ; "rate" + WRITE_DSP cl + ; magic number ! + + endif + 34DD C3 ret + + 34DE ResetCard ENDP + + ;*---------------------------------------------- + ----------------------------* + + 34DE CloseCard PROC + + 34DE 66| 8B 15 000025A0 R mov dx, word ptr[BASE_ADDR] + ; point to DSP + + ifdef SB16 + 34E5 80 C2 0C add dl, 0CH + ifdef SAMPLE16BIT + WRITE_DSP DSP_VO16S_CMD + ; single-cycle 16 bit DMA + 1 local wait_dsp + 1 + 34E8 EC 1 ??0010: in al, dx + 34E9 0A C0 1 or al, al + 34EB 78 FB 1 js ??0010 + 1 + 34ED B0 B0 1 mov al, DSP_VO16S_CMD + 34EF EE 1 out dx, al + 1 + ifdef STEREO + WRITE_DSP DSP_16STEREO_MODE + ; 16 bit stereo + 1 local wait_dsp + 1 + 34F0 EC 1 ??0011: in al, dx + 34F1 0A C0 1 or al, al + 34F3 78 FB 1 js ??0011 + 1 + 34F5 B0 30 1 mov al, DSP_16STEREO_MODE + 34F7 EE 1 out dx, al + 1 + else + WRITE_DSP DSP_16MONO_MODE + ; 16 bit mono + endif + else + WRITE_DSP DSP_VO8S_4_CMD + ; single-cycle 8 bit DMA + ifdef STEREO + WRITE_DSP DSP_8STEREO_MODE + ; 8 bit stereo + else + WRITE_DSP DSP_8MONO_MODE + ; 8 bit mono + endif + endif + WRITE_DSP 0 + ; length of 1 to finish + 1 local wait_dsp + 1 + 34F8 EC 1 ??0012: in al, dx + 34F9 0A C0 1 or al, al + 34FB 78 FB 1 js ??0012 + 1 + 34FD B0 00 1 mov al, 0 + 34FF EE 1 out dx, al + 1 + WRITE_DSP 0 + 1 local wait_dsp + 1 + 3500 EC 1 ??0013: in al, dx + 3501 0A C0 1 or al, al + 3503 78 FB 1 js ??0013 + 1 + 3505 B0 00 1 mov al, 0 + 3507 EE 1 out dx, al + 1 + else + ifdef SBPRO + add dl, 6 + ; reset port (offset 6) + mov al, 1 + ; write 1 + out dx, al + + mov ah, 8 * 3 + ; 4 * "in al, dx" = 1 microsec on std IS + A bus (8 Mhz) + wait_io: in al, dx + ; so 8 to be sure if 16 MHz ! + dec ah + ; kill the cat ! + jnz wait_io + + xor al, al + out dx, al + ; write 0 + + ; now reset should be done.. + add dl, 4 + ; offset 0Ah + + Next: add dl, 4 + ; offset 0Eh + + Wait_s: in al, dx + or al, al + jns Wait_s + + sub dl, 4 + ; offset 0Ah + in al, dx + ; read if reset terminated + + cmp al, RESET_TEST_CODE + ; should be... + jne Next + + sub dl, 6 + ; offset 4 + mov al, 0Eh + out dx, al + inc dx + ; offset 5 + mov al, byte ptr[Filter] + ; restore filter + out dx, al + + dec dx + mov al, 0Eh + out dx, al + inc dx + ; offset 5 + in al, dx + and al, 11111101b + ; turn off stereo + out dx, al + + add dl, 7 + ; offset 0Ch + WRITE_DSP DSP_OFFSPK_CMD + ; Turn speaker off + + else + + add dl, 0CH + WRITE_DSP DSP_OFFSPK_CMD + ; Turn speaker off + WRITE_DSP DSP_VO8S_CMD + ; single-cycle 8 bit DMA + WRITE_DSP 0 + ; length of 1 to finish + WRITE_DSP 0 + + endif + endif + + 3508 C3 ret + + 3509 CloseCard ENDP + + ;----------------------------------------------- + ----------------------------- + + 3509 AckIrq PROC + + 3509 66| 8B 15 000025A0 R mov dx, word ptr[BASE_ADDR] + ; DSP IRQ ACK + ifdef SB16 + 3510 80 C2 04 add dl, 4 + ; offset 4 + 3513 B0 82 mov al, 82h + 3515 EE out dx, al + 3516 66| 42 inc dx + ; offset 5 + 3518 EC in al, dx + ifdef SAMPLE16BIT + 3519 24 02 and al, 2 + 351B 74 05 jz NoDMAIRQ + 351D 80 C2 0A add dl, 10 + ; offset Fh + else + and al, 1 + jz NoDMAIRQ + add dl, 9 + ; offset Eh + endif + 3520 EC in al, dx + 3521 C3 ret + 3522 NoDMAIRQ: + 3522 F9 stc + 3523 C3 ret + else + add dl, 0Eh + ; 8 bit Samples ACK + in al, dx + ret + endif + + 3524 AckIrq ENDP + + ;----------------------------------------------- + ----------------------------- + + 3524 StartDMACard PROC + + 3524 66| 8B 15 000025A0 R mov dx, word ptr[BASE_ADDR] + ; DSP + 352B 80 C2 0C add dl, 0Ch + + ifdef STEREO + 352E 66| B9 07FF mov cx, BUFFER_SIZE * 2 - 1 + ; half-buffer size - 1 for DMA + else + mov cx, BUFFER_SIZE - 1 + ; half-buffer size - 1 for DMA + endif + + ifdef SB16 + + + ifdef SAMPLE16BIT + WRITE_DSP DSP_VO16_CMD + ; auto-init 16 bit DMA + 1 local wait_dsp + 1 + 3532 EC 1 ??0014: in al, dx + 3533 0A C0 1 or al, al + 3535 78 FB 1 js ??0014 + 1 + 3537 B0 B6 1 mov al, DSP_VO16_CMD + 3539 EE 1 out dx, al + 1 + ifdef STEREO + WRITE_DSP DSP_16STEREO_MODE + ; 16 bit stereo + 1 local wait_dsp + 1 + 353A EC 1 ??0015: in al, dx + 353B 0A C0 1 or al, al + 353D 78 FB 1 js ??0015 + 1 + 353F B0 30 1 mov al, DSP_16STEREO_MODE + 3541 EE 1 out dx, al + 1 + else + WRITE_DSP DSP_16MONO_MODE + ; 16 bit mono + endif + else + WRITE_DSP DSP_VO8_4_CMD + ; auto-init 8 bit DMA + ifdef STEREO + WRITE_DSP DSP_8STEREO_MODE + ; 8 bit stereo + else + WRITE_DSP DSP_8MONO_MODE + ; 8 bit mono + endif + endif + WRITE_DSP cl + 1 local wait_dsp + 1 + 3542 EC 1 ??0016: in al, dx + 3543 0A C0 1 or al, al + 3545 78 FB 1 js ??0016 + 1 + 3547 8A C1 1 mov al, cl + 3549 EE 1 out dx, al + 1 + WRITE_DSP ch + 1 local wait_dsp + 1 + 354A EC 1 ??0017: in al, dx + 354B 0A C0 1 or al, al + 354D 78 FB 1 js ??0017 + 1 + 354F 8A C5 1 mov al, ch + 3551 EE 1 out dx, al + 1 + + elseifdef SBLASTER1 + + WRITE_DSP DSP_VO8S_CMD + ; single-cycle 8 bit DMA + WRITE_DSP cl + WRITE_DSP ch + + else + + WRITE_DSP DSP_BSIZE_CMD + ; Set block size + WRITE_DSP cl + WRITE_DSP ch + + ifdef SBPRO + WRITE_DSP DSP_VO8H_CMD + ; auto-init 8 bit high-speed DMA + else + WRITE_DSP DSP_VO8_CMD + ; auto-init 8 bit DMA + endif + endif + 3552 C3 ret + + 3553 StartDMACard ENDP + + endif + + ;----------------------------------------------- + ----------------------------- + ;----------------------------------------------- + ----------------------------- + + ifdef GOLD + + SELECT_MIXER MACRO + local wait + + mov al, 0FFh + out dx, al + out dx, al + wait: in al, dx + and al, 11000000b + jnz wait + + ENDM + + LEAVE_MIXER MACRO + local wait + + wait: in al, dx + and al, 11000000b + jnz wait + mov al, 0FEh + out dx, al + out dx, al + + ENDM + + WRITE_MIXER MACRO PORT, VAL + local wait1, wait2 + + mov al, PORT + out dx, al + wait1: in al, dx + and al, 11000000b + jnz wait1 + inc dx + mov al, VAL + out dx, al + dec dx + wait2: in al, dx + and al, 11000000b + jnz wait2 + + ENDM + + READ_MIXER MACRO PORT + local wait1, wait2 + + mov al, PORT + out dx, al + wait1: in al, dx + and al, 11000000b + jnz wait1 + inc dx + in al, dx + dec dx + mov ah, al + wait2: in al, dx + and al, 11000000b + jnz wait2 + mov al, ah + + ENDM + + WRITE_MMA0 MACRO PORT, VAL + + mov al, PORT + out dx, al + inc dx + mov al, VAL + out dx, al + dec dx + in al, dx + in al, dx + + ENDM + + READ_MMA0 MACRO PORT + + mov al, PORT + out dx, al + inc dx + in al, dx + dec dx + mov ah, al + in al, dx + in al, dx + mov al, ah + + ENDM + + WRITE_MMA1 MACRO PORT, VAL + + mov al, PORT + out dx, al + add dx, 3 + mov al, VAL + out dx, al + sub dx, 3 + in al, dx + in al, dx + + ENDM + + READ_MMA1 MACRO PORT + + mov al, PORT + out dx, al + add dx, 3 + in al, dx + sub dx, 3 + mov ah, al + in al, dx + in al, dx + mov al, ah + + ENDM + + + ;*---------------------------------------------- + ----------------------------* + + ResetCard PROC + + mov dx, word ptr[BASE_ADDR] + add dx, 2 + ; MIXER + + SELECT_MIXER + + WRITE_MIXER 8h, 11001110b + ; STEREO mode + WRITE_MIXER 11h, 00001000b + ; filter on output, no mic input, no PC- + speaker input + + READ_MIXER 13h + + mov byte ptr[Mixer_13], al + + mov cl, al + + and eax, 3 + lea ebx, Gold_IRQ + mov al, byte ptr[ebx+eax] + mov dword ptr[IRQ_number], e + ax + + mov al, cl + shr al, 4 + and al, 3 + mov dword ptr[DMA_number], e + ax + + or cl, 10001000b + ; enable DMA0, enable IRQ + WRITE_MIXER 13h, cl + + READ_MIXER 14h + + mov byte ptr[Mixer_14], al + + mov cl, al + and cl, 01111111b + WRITE_MIXER 14h, cl + + LEAVE_MIXER + + add dx, 2 + ; MMA + + WRITE_MMA0 9, 80h + ; reset channel 0 + WRITE_MMA1 9, 80h + ; reset channel 1 + + mov cx, 4 + fillFIFO0: WRITE_MMA0 0Bh, 0 + dec cx + jnz FillFIFO0 + + mov cx, 4 + fillFIFO1: WRITE_MMA1 0Bh, 0 + dec cx + jnz FillFIFO1 + + WRITE_MMA0 9, 00101110b + ; 22.05 Khz, PCM, L, Play + WRITE_MMA1 9, 01001110b + ; 22.05 Khz, PCM, R, Play + + mov word ptr[PlayRate], 2205 + 0 ; 22.05 Khz + + WRITE_MMA0 0Ch, 11000101b + ; Interleave, 16 bit, 96 byte FIFO, DMA + WRITE_MMA1 0Ch, 01000011b + ; 16 bit, no FIFO (use other channel), D + MA + + + WRITE_MMA0 0Ah, 0FFh + ; Maximum volume (volume will be control + led by mixer) + WRITE_MMA1 0Ah, 0FFh + + mov cx, 100 + fillFIFO: WRITE_MMA0 0Bh, 0 + dec cx + jnz FillFIFO + + ret + + ResetCard ENDP + + ;*---------------------------------------------- + ----------------------------* + + CloseCard PROC + + mov dx, word ptr[BASE_ADDR] + add dx, 4 + ; MMA + + WRITE_MMA1 0Ch, 01000010b + ; 16 bit, no FIFO, no DMA + WRITE_MMA0 0Ch, 01000010b + ; 16 bit, no FIFO, no DMA + + WRITE_MMA0 9, 80h + ; reset channel 0 + WRITE_MMA1 9, 80h + ; reset channel 1 + + sub dx, 2 + ; MIXER + + SELECT_MIXER + + WRITE_MIXER 13h, Mixer_13 + WRITE_MIXER 14h, Mixer_14 + + LEAVE_MIXER + + ret + + CloseCard ENDP + + ;----------------------------------------------- + ----------------------------- + + AckIrq PROC + + mov dx, word ptr[BASE_ADDR] + add dx, 4 + ; MMA + + in al, dx + and al, 1 + jz short noDMA + + mov ebx, dword ptr[DMA] + ; Point to DMAx + + mov dx, word ptr[ebx + FF_RE + G] + out dx, al + ; flip-flop + + mov dx, word ptr[ebx + COUNT + _REG] + in al, dx + mov ah, al + in al, dx + xchg al, ah + + or ax, ax + jz short OkDMA + inc ax + jnz short noDMA + OkDMA: + clc + ret + NoDMA: + stc + ret + + AckIrq ENDP + + ;----------------------------------------------- + ----------------------------- + + StartDMACard PROC + + mov dx, word ptr[BASE_ADDR] + add dx, 4 + ; MMA + + WRITE_MMA0 9, 00101111b + ; 22.05 Khz, PCM, L, Play, GO + + ret + + StartDMACard ENDP + + endif + + ;----------------------------------------------- + ----------------------------- + ;----------------------------------------------- + ----------------------------- + + ifdef GUS + + extrn Nolanguage resetcard:PROC + + ;*---------------------------------------------- + ----------------------------* + + extrn Nolanguage CloseCard:PROC + + ;*---------------------------------------------- + ----------------------------* + + extrn Nolanguage StartDMACard:PROC + + endif + + ;----------------------------------------------- + ----------------------------- + ;----------------------------------------------- + ----------------------------- + + END + Microsoft (R) Macro Assembler Version 6.1a 09/22/94 16:09:36 +wave_a.asm Symbols 2 - 1 + + + + +Macros: + + N a m e Type + +CRIT_SECT . . . . . . . . . . . Proc +END_CRIT_SECT . . . . . . . . . Proc +GET_PROT_VECT . . . . . . . . . Proc +GET_REAL_VECT . . . . . . . . . Proc +MIDPOINT . . . . . . . . . . . . Proc +READ_MIXER . . . . . . . . . . . Proc +SET_PROT_VECT . . . . . . . . . Proc +SET_REAL_VECT . . . . . . . . . Proc +WRITE_DSP . . . . . . . . . . . Proc +WRITE_MIXER . . . . . . . . . . Proc +lve . . . . . . . . . . . . . . Proc +setalc . . . . . . . . . . . . . Proc + + +Segments and Groups: + + N a m e Size Length Align Combine Class + +FLAT . . . . . . . . . . . . . . GROUP +_DATA . . . . . . . . . . . . . 32 Bit 0000 DWord Public 'DATA' + +_TEXT . . . . . . . . . . . . . 32 Bit 3553 DWord Public 'CODE' + + + +Procedures, parameters and locals: + + N a m e Type Value Attr + +AckIrq . . . . . . . . . . . . . P Near 3509 _TEXT Length= 001B Pub + lic SYSCALL + NoDMAIRQ . . . . . . . . . . . L Near 3522 _TEXT +AskVars . . . . . . . . . . . . P Near 31F4 _TEXT Length= 0019 Pub + lic SYSCALL + pListNames . . . . . . . . . . DWord bp + 0008 + pListVars . . . . . . . . . . DWord bp + 000C +ChangeVolume . . . . . . . . . . P Near 2CBE _TEXT Length= 0063 Pub + lic SYSCALL + LongHandle . . . . . . . . . . DWord bp + 0008 + volleft . . . . . . . . . . . DWord bp + 000C + volright . . . . . . . . . . . DWord bp + 0010 + notfound . . . . . . . . . . . L Near 2CEA _TEXT + ??0005 . . . . . . . . . . . . L Near 2D1F _TEXT +ClearCard . . . . . . . . . . . P Near 3177 _TEXT Length= 007D Pub + lic SYSCALL + Ok21 . . . . . . . . . . . . . L Near 3198 _TEXT + nobi . . . . . . . . . . . . . L Near 31EF _TEXT +CloseCard . . . . . . . . . . . P Near 34DE _TEXT Length= 002B Pub + lic SYSCALL + ??0010 . . . . . . . . . . . . L Near 34E8 _TEXT + ??0011 . . . . . . . . . . . . L Near 34F0 _TEXT + ??0012 . . . . . . . . . . . . L Near 34F8 _TEXT + ??0013 . . . . . . . . . . . . L Near 3500 _TEXT +ContinueSample . . . . . . . . . P Near 2F5C _TEXT Length= 0051 Pub + lic SYSCALL + ??0008 . . . . . . . . . . . . L Near 2FAC _TEXT +CopyList . . . . . . . . . . . . P Near 32F2 _TEXT Length= 0015 Pub + lic SYSCALL + keepcopying . . . . . . . . . L Near 32F2 _TEXT + endcopy . . . . . . . . . . . L Near 3300 _TEXT +GetBufferSize . . . . . . . . . P Near 320D _TEXT Length= 0006 Pub + lic SYSCALL +GetDMAAddr . . . . . . . . . . . P Near 25F3 _TEXT Length= 0035 Pub + lic SYSCALL + noadjust . . . . . . . . . . . L Near 2626 _TEXT +GetSnapSample . . . . . . . . . P Near 3268 _TEXT Length= 008A Pub + lic SYSCALL + pList . . . . . . . . . . . . DWord bp + 0008 + keeplooking . . . . . . . . . L Near 328C _TEXT + exit . . . . . . . . . . . . . L Near 32AC _TEXT + ??000A . . . . . . . . . . . . L Near 32E7 _TEXT +GiveSampleInfo0 . . . . . . . . P Near 3213 _TEXT Length= 0055 Pub + lic SYSCALL + LongHandle . . . . . . . . . . DWord bp + 0008 + Info . . . . . . . . . . . . . DWord bp + 000C + notfound . . . . . . . . . . . L Near 3231 _TEXT + ??0009 . . . . . . . . . . . . L Near 3266 _TEXT +InitCard . . . . . . . . . . . . P Near 2FED _TEXT Length= 018A Pub + lic SYSCALL + Buffer . . . . . . . . . . . . DWord bp + 0008 + ErrorDMA . . . . . . . . . . . L Near 3021 _TEXT + DMAFound . . . . . . . . . . . L Near 3029 _TEXT + Second . . . . . . . . . . . . L Near 303B _TEXT + gotvect . . . . . . . . . . . L Near 303D _TEXT + nobi . . . . . . . . . . . . . L Near 308F _TEXT + Ok21 . . . . . . . . . . . . . L Near 30A4 _TEXT + NoLengthAdj . . . . . . . . . L Near 310C _TEXT + NoAddrAdj . . . . . . . . . . L Near 314A _TEXT +InstallISR . . . . . . . . . . . P Near 2FAD _TEXT Length= 0040 Pub + lic SYSCALL + nobi . . . . . . . . . . . . . L Near 2FEC _TEXT +MixSample . . . . . . . . . . . P Near 2D21 _TEXT Length= 01E6 Pub + lic SYSCALL + thehandle . . . . . . . . . . DWord bp + 0008 + pitchbend . . . . . . . . . . DWord bp + 000C + therepeat . . . . . . . . . . DWord bp + 0010 + plug . . . . . . . . . . . . . DWord bp + 0014 + volleft . . . . . . . . . . . DWord bp + 0018 + volright . . . . . . . . . . . DWord bp + 001C + buffer . . . . . . . . . . . . DWord bp + 0020 + okfilter . . . . . . . . . . . L Near 2D36 _TEXT + okincr . . . . . . . . . . . . L Near 2DA7 _TEXT + next . . . . . . . . . . . . . L Near 2DD8 _TEXT + ok_handle . . . . . . . . . . L Near 2E05 _TEXT + keeplooking0 . . . . . . . . . L Near 2E27 _TEXT + SearchSonList . . . . . . . . L Near 2E36 _TEXT + keeplooking1 . . . . . . . . . L Near 2E3C _TEXT + exit . . . . . . . . . . . . . L Near 2E4B _TEXT + found . . . . . . . . . . . . L Near 2E4F _TEXT + NoPlug . . . . . . . . . . . . L Near 2E52 _TEXT + SearchEnd . . . . . . . . . . L Near 2E57 _TEXT + endcritical . . . . . . . . . L Near 2EC5 _TEXT + ??0006 . . . . . . . . . . . . L Near 2EFA _TEXT + typeunknown . . . . . . . . . L Near 2EFF _TEXT +NewIRQ . . . . . . . . . . . . . P Near 2628 _TEXT Length= 0072 Pub + lic SYSCALL + NoSecondCtrl . . . . . . . . . L Near 2643 _TEXT + FinIRQ . . . . . . . . . . . . L Near 2696 _TEXT +PauseSample . . . . . . . . . . P Near 2F07 _TEXT Length= 0055 Pub + lic SYSCALL + ??0007 . . . . . . . . . . . . L Near 2F5B _TEXT +Redirector . . . . . . . . . . . P Near 25F0 _TEXT Length= 0003 Pub + lic SYSCALL +ResetCard . . . . . . . . . . . P Near 3436 _TEXT Length= 00A8 Pub + lic SYSCALL + OkRateLow . . . . . . . . . . L Near 344C _TEXT + OkRateHigh . . . . . . . . . . L Near 3462 _TEXT + wait_io . . . . . . . . . . . L Near 3471 _TEXT + Next . . . . . . . . . . . . . L Near 347C _TEXT + Wait_s . . . . . . . . . . . . L Near 347F _TEXT + ??000D . . . . . . . . . . . . L Near 34BE _TEXT + ??000E . . . . . . . . . . . . L Near 34CD _TEXT + ??000F . . . . . . . . . . . . L Near 34D5 _TEXT +RestoreStateSample . . . . . . . P Near 33A1 _TEXT Length= 0095 Pub + lic SYSCALL + waitpause . . . . . . . . . . L Near 33A8 _TEXT + ??000C . . . . . . . . . . . . L Near 3425 _TEXT + waitcontinue . . . . . . . . . L Near 342A _TEXT +SAveStateSample . . . . . . . . P Near 3307 _TEXT Length= 009A Pub + lic SYSCALL + waitpause . . . . . . . . . . L Near 330E _TEXT + ??000B . . . . . . . . . . . . L Near 339E _TEXT +SampleInList . . . . . . . . . . P Near 2C27 _TEXT Length= 0073 Pub + lic SYSCALL + thehandle . . . . . . . . . . DWord bp + 0008 + keeplooking . . . . . . . . . L Near 2C44 _TEXT + exit . . . . . . . . . . . . . L Near 2C54 _TEXT + found . . . . . . . . . . . . L Near 2C62 _TEXT + ??0004 . . . . . . . . . . . . L Near 2C97 _TEXT +SearchLongHandle . . . . . . . . P Near 2C9A _TEXT Length= 0024 Pub + lic SYSCALL + keeplooking . . . . . . . . . L Near 2CA6 _TEXT + exit . . . . . . . . . . . . . L Near 2CB5 _TEXT + found . . . . . . . . . . . . L Near 2CBD _TEXT +ShiftSamples . . . . . . . . . . P Near 2B2D _TEXT Length= 008C Pub + lic SYSCALL + DestAddr . . . . . . . . . . . DWord bp + 0008 + SrcAddr . . . . . . . . . . . DWord bp + 000C + SizeByte . . . . . . . . . . . DWord bp + 0010 + keeplooking . . . . . . . . . L Near 2B5F _TEXT + notfound . . . . . . . . . . . L Near 2B6E _TEXT + exit . . . . . . . . . . . . . L Near 2B73 _TEXT + ??0002 . . . . . . . . . . . . L Near 2BB4 _TEXT +StartDMACard . . . . . . . . . . P Near 3524 _TEXT Length= 002F Pub + lic SYSCALL + ??0014 . . . . . . . . . . . . L Near 3532 _TEXT + ??0015 . . . . . . . . . . . . L Near 353A _TEXT + ??0016 . . . . . . . . . . . . L Near 3542 _TEXT + ??0017 . . . . . . . . . . . . L Near 354A _TEXT +StopOneSampleLong . . . . . . . P Near 2BB9 _TEXT Length= 006E Pub + lic SYSCALL + LongHandle . . . . . . . . . . DWord bp + 0008 + LoopRemove . . . . . . . . . . L Near 2BDA _TEXT + EndRemove . . . . . . . . . . L Near 2BE8 _TEXT + notfound . . . . . . . . . . . L Near 2BEE _TEXT + ??0003 . . . . . . . . . . . . L Near 2C23 _TEXT +StopOneSample . . . . . . . . . P Near 2A91 _TEXT Length= 009C Pub + lic SYSCALL + thehandle . . . . . . . . . . DWord bp + 0008 + keeplooking . . . . . . . . . L Near 2AAD _TEXT + exit . . . . . . . . . . . . . L Near 2ABD _TEXT + ??0001 . . . . . . . . . . . . L Near 2B03 _TEXT + found . . . . . . . . . . . . L Near 2B08 _TEXT + noson . . . . . . . . . . . . L Near 2B10 _TEXT + LoopRemove . . . . . . . . . . L Near 2B17 _TEXT + EndRemove . . . . . . . . . . L Near 2B25 _TEXT +StopSample . . . . . . . . . . . P Near 2A31 _TEXT Length= 0060 Pub + lic SYSCALL + ??0000 . . . . . . . . . . . . L Near 2A90 _TEXT +UpdateBuffer . . . . . . . . . . P Near 269A _TEXT Length= 0397 Pub + lic SYSCALL + dopause . . . . . . . . . . . L Near 26BE _TEXT + exit . . . . . . . . . . . . . L Near 26C9 _TEXT + loopfadein . . . . . . . . . . L Near 26EC _TEXT + fadeout . . . . . . . . . . . L Near 2711 _TEXT + loopfadeout . . . . . . . . . L Near 2714 _TEXT + endfade . . . . . . . . . . . L Near 2735 _TEXT + reallyexit . . . . . . . . . . L Near 2741 _TEXT + FinishFill0 . . . . . . . . . L Near 2742 _TEXT + process_1st . . . . . . . . . L Near 274B _TEXT + Longer0 . . . . . . . . . . . L Near 276C _TEXT + NotLonger0 . . . . . . . . . . L Near 277F _TEXT + StartMix0 . . . . . . . . . . L Near 2787 _TEXT + start0 . . . . . . . . . . . . L Near 27C6 _TEXT + next0 . . . . . . . . . . . . L Near 27CF _TEXT + nofilter . . . . . . . . . . . L Near 282C _TEXT + start01 . . . . . . . . . . . L Near 2832 _TEXT + next01 . . . . . . . . . . . . L Near 2844 _TEXT + end16 . . . . . . . . . . . . L Near 2857 _TEXT + noadjust0 . . . . . . . . . . L Near 285A _TEXT + KeepLooking0 . . . . . . . . . L Near 287E _TEXT + NoSon0 . . . . . . . . . . . . L Near 288D _TEXT + LoopRemove0 . . . . . . . . . L Near 289D _TEXT + EndRemove0 . . . . . . . . . . L Near 28AB _TEXT + FoundSon0 . . . . . . . . . . L Near 28B3 _TEXT + LoopSon0 . . . . . . . . . . . L Near 28C7 _TEXT + EndSon0 . . . . . . . . . . . L Near 28D5 _TEXT + Reset0 . . . . . . . . . . . . L Near 28E5 _TEXT + NextSample . . . . . . . . . . L Near 28F9 _TEXT + FinishFill . . . . . . . . . . L Near 290D _TEXT + Longer . . . . . . . . . . . . L Near 2937 _TEXT + NotLonger . . . . . . . . . . L Near 294A _TEXT + StartMix00 . . . . . . . . . . L Near 2952 _TEXT + start00 . . . . . . . . . . . L Near 2963 _TEXT + next00 . . . . . . . . . . . . L Near 2975 _TEXT + noadjust . . . . . . . . . . . L Near 298B _TEXT + KeepLooking . . . . . . . . . L Near 29AB _TEXT + NoSon . . . . . . . . . . . . L Near 29BA _TEXT + LoopRemove . . . . . . . . . . L Near 29C1 _TEXT + EndRemove . . . . . . . . . . L Near 29CF _TEXT + FoundSon . . . . . . . . . . . L Near 29DA _TEXT + LoopSon . . . . . . . . . . . L Near 29EE _TEXT + EndSon . . . . . . . . . . . . L Near 29FC _TEXT + Finish . . . . . . . . . . . . L Near 2A0C _TEXT + Finish2 . . . . . . . . . . . L Near 2A15 _TEXT + Reset . . . . . . . . . . . . L Near 2A1D _TEXT + + +Symbols: + + N a m e Type Value Attr + +@CodeSize . . . . . . . . . . . Number 0000h +@DataSize . . . . . . . . . . . Number 0000h +@Interface . . . . . . . . . . . Number 0002h +@Model . . . . . . . . . . . . . Number 0007h +@code . . . . . . . . . . . . . Text _TEXT +@data . . . . . . . . . . . . . Text FLAT +@fardata? . . . . . . . . . . . Text FLAT +@fardata . . . . . . . . . . . . Text FLAT +@stack . . . . . . . . . . . . . Text FLAT +ADDRESS . . . . . . . . . . . . Number 0000h +ADDX_REG . . . . . . . . . . . . Number 0004h +AUTO_DMA . . . . . . . . . . . . Number 0001h +AUTO_OUT . . . . . . . . . . . . Number 0001h +BASE_ADDR . . . . . . . . . . . DWord 25A0 _TEXT +BUFFER_DMA . . . . . . . . . . . DWord 25E4 _TEXT Public SYSCALL +BUFFER_SIZE . . . . . . . . . . Number 0400h +BackCurrentList . . . . . . . . Byte 1298 _TEXT +BackSonList . . . . . . . . . . Byte 1B30 _TEXT +BufferHalf . . . . . . . . . . . DWord 25B4 _TEXT Public SYSCALL +COUNT_REG . . . . . . . . . . . Number 0006h +CURRENT_BUFFER . . . . . . . . . DWord 25EC _TEXT Public SYSCALL +C_REPEAT . . . . . . . . . . . . Number 000Ch +Critical . . . . . . . . . . . . Word 2580 _TEXT +CurrentList . . . . . . . . . . Byte 0168 _TEXT +DLENGTH . . . . . . . . . . . . Number 001Ch +DMA0_ADDX_REG . . . . . . . . . Word 00EC _TEXT +DMA0_AUTO_OUT . . . . . . . . . Byte 00E9 _TEXT +DMA0_COUNT_REG . . . . . . . . . Word 00EE _TEXT +DMA0_FF_REG . . . . . . . . . . Word 00F4 _TEXT +DMA0_MASK1 . . . . . . . . . . . Byte 00EA _TEXT +DMA0_MASK2 . . . . . . . . . . . Byte 00EB _TEXT +DMA0_MASK_REG . . . . . . . . . Word 00F0 _TEXT +DMA0_MODE_REG . . . . . . . . . Word 00F2 _TEXT +DMA0_PAGE_REG . . . . . . . . . Word 00F6 _TEXT +DMA0_VOICE_OUT . . . . . . . . . Byte 00E8 _TEXT +DMA0 . . . . . . . . . . . . . . Number 00E8h +DMA1_ADDX_REG . . . . . . . . . Word 00FC _TEXT +DMA1_AUTO_OUT . . . . . . . . . Byte 00F9 _TEXT +DMA1_COUNT_REG . . . . . . . . . Word 00FE _TEXT +DMA1_FF_REG . . . . . . . . . . Word 0104 _TEXT +DMA1_MASK1 . . . . . . . . . . . Byte 00FA _TEXT +DMA1_MASK2 . . . . . . . . . . . Byte 00FB _TEXT +DMA1_MASK_REG . . . . . . . . . Word 0100 _TEXT +DMA1_MODE_REG . . . . . . . . . Word 0102 _TEXT +DMA1_PAGE_REG . . . . . . . . . Word 0106 _TEXT +DMA1_VOICE_OUT . . . . . . . . . Byte 00F8 _TEXT +DMA1 . . . . . . . . . . . . . . Number 00F8h +DMA3_ADDX_REG . . . . . . . . . Word 010C _TEXT +DMA3_AUTO_OUT . . . . . . . . . Byte 0109 _TEXT +DMA3_COUNT_REG . . . . . . . . . Word 010E _TEXT +DMA3_FF_REG . . . . . . . . . . Word 0114 _TEXT +DMA3_MASK1 . . . . . . . . . . . Byte 010A _TEXT +DMA3_MASK2 . . . . . . . . . . . Byte 010B _TEXT +DMA3_MASK_REG . . . . . . . . . Word 0110 _TEXT +DMA3_MODE_REG . . . . . . . . . Word 0112 _TEXT +DMA3_PAGE_REG . . . . . . . . . Word 0116 _TEXT +DMA3_VOICE_OUT . . . . . . . . . Byte 0108 _TEXT +DMA3 . . . . . . . . . . . . . . Number 0108h +DMA5_ADDX_REG . . . . . . . . . Word 011C _TEXT +DMA5_AUTO_OUT . . . . . . . . . Byte 0119 _TEXT +DMA5_COUNT_REG . . . . . . . . . Word 011E _TEXT +DMA5_FF_REG . . . . . . . . . . Word 0124 _TEXT +DMA5_MASK1 . . . . . . . . . . . Byte 011A _TEXT +DMA5_MASK2 . . . . . . . . . . . Byte 011B _TEXT +DMA5_MASK_REG . . . . . . . . . Word 0120 _TEXT +DMA5_MODE_REG . . . . . . . . . Word 0122 _TEXT +DMA5_PAGE_REG . . . . . . . . . Word 0126 _TEXT +DMA5_VOICE_OUT . . . . . . . . . Byte 0118 _TEXT +DMA5 . . . . . . . . . . . . . . Number 0118h +DMA6_ADDX_REG . . . . . . . . . Word 012C _TEXT +DMA6_AUTO_OUT . . . . . . . . . Byte 0129 _TEXT +DMA6_COUNT_REG . . . . . . . . . Word 012E _TEXT +DMA6_FF_REG . . . . . . . . . . Word 0134 _TEXT +DMA6_MASK1 . . . . . . . . . . . Byte 012A _TEXT +DMA6_MASK2 . . . . . . . . . . . Byte 012B _TEXT +DMA6_MASK_REG . . . . . . . . . Word 0130 _TEXT +DMA6_MODE_REG . . . . . . . . . Word 0132 _TEXT +DMA6_PAGE_REG . . . . . . . . . Word 0136 _TEXT +DMA6_VOICE_OUT . . . . . . . . . Byte 0128 _TEXT +DMA6 . . . . . . . . . . . . . . Number 0128h +DMA7_ADDX_REG . . . . . . . . . Word 013C _TEXT +DMA7_AUTO_OUT . . . . . . . . . Byte 0139 _TEXT +DMA7_COUNT_REG . . . . . . . . . Word 013E _TEXT +DMA7_FF_REG . . . . . . . . . . Word 0144 _TEXT +DMA7_MASK1 . . . . . . . . . . . Byte 013A _TEXT +DMA7_MASK2 . . . . . . . . . . . Byte 013B _TEXT +DMA7_MASK_REG . . . . . . . . . Word 0140 _TEXT +DMA7_MODE_REG . . . . . . . . . Word 0142 _TEXT +DMA7_PAGE_REG . . . . . . . . . Word 0146 _TEXT +DMA7_VOICE_OUT . . . . . . . . . Byte 0138 _TEXT +DMA7 . . . . . . . . . . . . . . Number 0138h +DMA_number . . . . . . . . . . . DWord 25AC _TEXT +DMA . . . . . . . . . . . . . . DWord 25C0 _TEXT +DSP_16MONO_MODE . . . . . . . . Number 0010h +DSP_16STEREO_MODE . . . . . . . Number 0030h +DSP_8MONO_MODE . . . . . . . . . Number 0000h +DSP_8STEREO_MODE . . . . . . . . Number 0020h +DSP_BSIZE_CMD . . . . . . . . . Number 0048h +DSP_OFFSPK_CMD . . . . . . . . . Number 00D3h +DSP_ONSPK_CMD . . . . . . . . . Number 00D1h +DSP_RATE_CMD . . . . . . . . . . Number 0041h +DSP_TIME_CMD . . . . . . . . . . Number 0040h +DSP_VO16S_CMD . . . . . . . . . Number 00B0h +DSP_VO16_CMD . . . . . . . . . . Number 00B6h +DSP_VO8H_CMD . . . . . . . . . . Number 0090h +DSP_VO8S_4_CMD . . . . . . . . . Number 00C0h +DSP_VO8S_CMD . . . . . . . . . . Number 0014h +DSP_VO8_4_CMD . . . . . . . . . Number 00C6h +DSP_VO8_CMD . . . . . . . . . . Number 001Ch +DoUpdate . . . . . . . . . . . . Word 2582 _TEXT +Empty . . . . . . . . . . . . . Byte 257B _TEXT +FF_REG . . . . . . . . . . . . . Number 000Ch +FRACT . . . . . . . . . . . . . Number 0004h +FlagPause . . . . . . . . . . . Byte 2559 _TEXT +HANDLE . . . . . . . . . . . . . Number 0014h +INCR . . . . . . . . . . . . . . Number 000Eh +INFO0 . . . . . . . . . . . . . Number 0024h +INTERPOL . . . . . . . . . . . . Number 0028h +INT_number . . . . . . . . . . . DWord 25B0 _TEXT +IRQ_mask . . . . . . . . . . . . Byte 2558 _TEXT +IRQ_number . . . . . . . . . . . DWord 25A8 _TEXT +LAST_SAMPLE . . . . . . . . . . Number 0029h +LEFT . . . . . . . . . . . . . . Number 0008h +LIST_SIZE . . . . . . . . . . . Number 0032h +ListFuncs . . . . . . . . . . . DWord 00A0 _TEXT +ListNames . . . . . . . . . . . DWord 2594 _TEXT +ListVars . . . . . . . . . . . . Number 25A0h +MASK1 . . . . . . . . . . . . . Number 0002h +MASK2 . . . . . . . . . . . . . Number 0003h +MASK_REG . . . . . . . . . . . . Number 0008h +MID_BUFFER_DMA . . . . . . . . . DWord 25E8 _TEXT +MODE_REG . . . . . . . . . . . . Number 000Ah +NoLanguage . . . . . . . . . . . Text SYSCALL +Old_18_Off . . . . . . . . . . . DWord 2590 _TEXT +Old_18_Sel . . . . . . . . . . . Word 2588 _TEXT +Old_PIRQ_Off . . . . . . . . . . DWord 258C _TEXT +Old_PIRQ_Sel . . . . . . . . . . Word 2586 _TEXT +Old_RIRQ_Off . . . . . . . . . . Word 258A _TEXT +Old_RIRQ_Seg . . . . . . . . . . Word 2584 _TEXT +PAGE_REG . . . . . . . . . . . . Number 000Eh +PlayRate . . . . . . . . . . . . DWord 25A4 _TEXT Public SYSCALL +RESET_TEST_CODE . . . . . . . . Number 00AAh +SAMPLE16BIT . . . . . . . . . . Text +SB16_IRQ . . . . . . . . . . . . Byte 257C _TEXT +SB16 . . . . . . . . . . . . . . Text +SBLASTER . . . . . . . . . . . . Number 0001h +SHIFT_SAMPLE . . . . . . . . . . Number 0003h +SLONG . . . . . . . . . . . . . Number 0001h +SNAP_SIZE . . . . . . . . . . . Number 0008h +SON . . . . . . . . . . . . . . Number 0010h +SSIZE . . . . . . . . . . . . . Number 0004h +START . . . . . . . . . . . . . Number 0018h +STEREO . . . . . . . . . . . . . Text +STRUCT_SIZE . . . . . . . . . . Number 002Ch +SnapList . . . . . . . . . . . . Byte 23C8 _TEXT +SonList . . . . . . . . . . . . Byte 0A00 _TEXT +TAB_DMA . . . . . . . . . . . . DWord 0148 _TEXT +TheVolumeL . . . . . . . . . . . DWord 25D0 _TEXT +TheVolumeR . . . . . . . . . . . DWord 25CC _TEXT +VOICE_HANDLE . . . . . . . . . . Number 1234h +VOICE_OUT . . . . . . . . . . . Number 0000h +VOL_LEFT . . . . . . . . . . . . Number 0020h +VOL_RIGHT . . . . . . . . . . . Number 0022h +WaveBase . . . . . . . . . . . . Byte 255A _TEXT +WaveDMA . . . . . . . . . . . . Byte 256B _TEXT +WaveIRQ . . . . . . . . . . . . Byte 2563 _TEXT +WaveRate . . . . . . . . . . . . Byte 2573 _TEXT +backfollow . . . . . . . . . . . DWord 25BC _TEXT +backweirdcount . . . . . . . . . DWord 25C8 _TEXT +driver_start . . . . . . . . . . DWord 0000 _TEXT Public SYSCALL +follow . . . . . . . . . . . . . DWord 25B8 _TEXT +jumps . . . . . . . . . . . . . Text ; +local_DS . . . . . . . . . . . . Number 262Eh +save_1 . . . . . . . . . . . . . DWord 25D4 _TEXT +save_2 . . . . . . . . . . . . . DWord 25D8 _TEXT +save_3 . . . . . . . . . . . . . DWord 25DC _TEXT +save_4 . . . . . . . . . . . . . DWord 25E0 _TEXT +weirdcount . . . . . . . . . . . DWord 25C4 _TEXT + + 0 Warnings + 0 Errors diff --git a/LIB386/LIB_SAMP/WAVE_DLL.MAK b/LIB386/LIB_SAMP/WAVE_DLL.MAK new file mode 100644 index 0000000..f7d36af --- /dev/null +++ b/LIB386/LIB_SAMP/WAVE_DLL.MAK @@ -0,0 +1,102 @@ +ASM = ml +#AFLAGS = /m2 /mx /z /zi /t /jMASM51 /jQUIRKS +AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=; +LINKDIR = format os2 lx dll + +dll: w_pas16.dll w_pas.dll w_gus.dll w_mwss.dll w_sb.dll w_sb2.dll w_sbpro.dll w_sb16.dll w_gold.dll + +# +# Wave driver: GF1, Gravis UltraSound +# + +w_gus.dll: wave_a.asm gusdig32.obj + $(ASM) $(AFLAGS) /DGUS wave_a.asm + wlink n w_gus.dll f wave_a,gusdig32,pminit_d l gf1_ospm.lib $(LINKDIR) + +# +# Wave driver: PAS16 +# + +w_pas16.dll: wave_a.asm + $(ASM) $(AFLAGS) /DPAS16 wave_a.asm + wlink n w_pas16.dll f wave_a $(LINKDIR) + +# +# Wave driver: PAS +# + +w_pas.dll: wave_a.asm + $(ASM) $(AFLAGS) /DPAS wave_a.asm + wlink n w_pas.dll f wave_a $(LINKDIR) + +# +# Wave driver: AD1848 SoundPort, Microsoft Windows Sound System +# + +w_mwss.dll: wave_a.asm + $(ASM) $(AFLAGS) /DMWSS wave_a.asm + wlink n w_mwss.dll f wave_a $(LINKDIR) + +# +# Wave driver: Sound Blaster +# + +w_sb.dll: wave_a.asm + $(ASM) $(AFLAGS) /DSBLASTER1 wave_a.asm + wlink n w_sb.dll f wave_a $(LINKDIR) + +# +# Wave driver: Sound Blaster 2 +# + +w_sb2.dll: wave_a.asm + $(ASM) $(AFLAGS) /DSBLASTER wave_a.asm + wlink n w_sb2.dll f wave_a $(LINKDIR) + +# +# Wave driver: Sound Blaster Pro +# + +w_sbpro.dll: wave_a.asm + $(ASM) $(AFLAGS) /DSBPRO wave_a.asm + wlink n w_sbpro.dll f wave_a $(LINKDIR) + +# +# Wave driver: Sound Blaster 16, STEREO, 16 BIT +# + +w_sb16.dll: wave_a.asm + $(ASM) $(AFLAGS) /DSB16 /DSTEREO /DSAMPLE16BIT wave_a.asm + wlink n w_sb16.dll f wave_a $(LINKDIR) + +# +# Wave driver: Sound Blaster 16, STEREO, 16 BIT, SURROUND +# + +w_sb16_s.dll: wave_a.asm + $(ASM) $(AFLAGS) /DSB16 /DSTEREO /DSAMPLE16BIT /DSURROUND wave_a.asm + wlink n w_sb16_s.dll f wave_a $(LINKDIR) + +# +# Wave driver: Sound Blaster 16, STEREO, 8 BIT +# + +w_sb16_8.dll: wave_a.asm + $(ASM) $(AFLAGS) /DSB16 /DSTEREO wave_a.asm + wlink n w_sb16_8.dll f wave_a $(LINKDIR) + +# +# Wave driver: Sound Blaster 16, MONO, 16 BIT +# + +w_sb16_m.dll: wave_a.asm + $(ASM) $(AFLAGS) /DSB16 /DSAMPLE16BIT wave_a.asm + wlink n w_sb16_m.dll f wave_a $(LINKDIR) + +# +# Wave driver: Yamaha Gold, Adlib Gold +# + +w_gold.dll: wave_a.asm + $(ASM) $(AFLAGS) /DGOLD wave_a.asm + wlink n w_gold.dll f wave_a $(LINKDIR) diff --git a/LIB386/LIB_SAMP/WAVE_I.ASM b/LIB386/LIB_SAMP/WAVE_I.ASM new file mode 100644 index 0000000..a752405 --- /dev/null +++ b/LIB386/LIB_SAMP/WAVE_I.ASM @@ -0,0 +1,227 @@ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; SAMP_A.ASM 386 +; (c) Adeline 1993 +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*--------------------------------------------------------------------------* + + .386 + jumps + + .model SMALL, SYSCALL + + .DATA + + PUBLIC NoLanguage Wave_listfcts + PUBLIC NoLanguage Wave_Driver_Enable + + +Wave_listfcts dd 0 +Wave_Driver_Enable dd 0 + + .CODE + + PUBLIC NoLanguage _InitCard + PUBLIC NoLanguage _ClearCard + PUBLIC NoLanguage WaveAskVars + PUBLIC NoLanguage WavePlay + PUBLIC NoLanguage WaveGiveInfo0 + PUBLIC NoLanguage WaveStop + PUBLIC NoLanguage WaveStopOne + PUBLIC NoLanguage WaveInList + PUBLIC NoLanguage WaveGetSnap + PUBLIC NoLanguage WavePause + PUBLIC NoLanguage WaveContinue + PUBLIC NoLanguage WaveSaveState + PUBLIC NoLanguage WaveRestoreState + PUBLIC NoLanguage WaveChangeVolume + PUBLIC NoLanguage WaveGetAddr + PUBLIC NoLanguage _GetBufferSize + PUBLIC NoLanguage WaveChangeVolume + PUBLIC NoLanguage WaveMove + PUBLIC NoLanguage WaveStopOneLong + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +WaveCallFuncs PROC + + cmp byte ptr[Wave_Driver_Enable], 0 + je return + + shl eax, 2 + add eax, dword ptr[Wave_listfcts] + jmp dword ptr[eax] +return: + xor eax, eax ; FALSE, NULL or 0 + ret + +WaveCallFuncs ENDP + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + + +_InitCard PROC + + mov eax, 0 + jmp WaveCallFuncs + +_InitCard ENDP + +;---------------------------------------------------------------------------- + +_ClearCard PROC + + mov eax, 1 + jmp WaveCallFuncs + +_ClearCard ENDP + +;---------------------------------------------------------------------------- + +WaveAskVars PROC + + mov eax, 2 + jmp WaveCallFuncs + +WaveAskVars ENDP + +;*--------------------------------------------------------------------------* + +WavePlay PROC + + mov eax, 3 + jmp WaveCallFuncs + +WavePlay ENDP + +;---------------------------------------------------------------------------- + +WaveGiveInfo0 PROC + + mov eax, 4 + jmp WaveCallFuncs + +WaveGiveInfo0 ENDP + +;*--------------------------------------------------------------------------* + +WaveStop PROC + + mov eax, 5 + jmp WaveCallFuncs + +WaveStop ENDP + +;*--------------------------------------------------------------------------* + +WaveStopOne PROC + + mov eax, 6 + jmp WaveCallFuncs + +WaveStopOne ENDP + +;*--------------------------------------------------------------------------* + +WaveInList PROC + + mov eax, 7 + jmp WaveCallFuncs + +WaveInList ENDP + +;---------------------------------------------------------------------------- + +WaveGetSnap PROC + + mov eax, 8 + jmp WaveCallFuncs + +WaveGetSnap ENDP + +;*--------------------------------------------------------------------------* + +WavePause PROC + + mov eax, 9 + jmp WaveCallFuncs + +WavePause ENDP + +;*--------------------------------------------------------------------------* + +WaveContinue PROC + + mov eax, 10 + jmp WaveCallFuncs + +WaveContinue ENDP + +;---------------------------------------------------------------------------- + +WaveSaveState PROC + + mov eax, 11 + jmp WaveCallFuncs + +WaveSaveState ENDP + +;---------------------------------------------------------------------------- + +WaveRestoreState PROC + + mov eax, 12 + jmp WaveCallFuncs + +WaveRestoreState ENDP + +;---------------------------------------------------------------------------- + +WaveGetAddr PROC + + mov eax, 13 + jmp WaveCallFuncs + +WaveGetAddr ENDP + +;---------------------------------------------------------------------------- + +_GetBufferSize PROC + + mov eax, 14 + jmp WaveCallFuncs + +_GetBufferSize ENDP + +;---------------------------------------------------------------------------- + +WaveChangeVolume PROC + + mov eax, 15 + jmp WaveCallFuncs + +WaveChangeVolume ENDP + +;---------------------------------------------------------------------------- + +WaveMove PROC + + mov eax, 16 + jmp WaveCallFuncs + +WaveMove ENDP + +;---------------------------------------------------------------------------- + +WaveStopOneLong PROC + + mov eax, 17 + jmp WaveCallFuncs + +WaveStopOneLong ENDP + +;---------------------------------------------------------------------------- + + END diff --git a/LIB386/LIB_SVGA/BLOC.C b/LIB386/LIB_SVGA/BLOC.C new file mode 100644 index 0000000..3273d1c --- /dev/null +++ b/LIB386/LIB_SVGA/BLOC.C @@ -0,0 +1,6 @@ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛÛßßß Ûßßßß ÛßßßÛ Ûßßßß Ûßßßß ÛÛÜ Û ÛÜ ÜÛ ÛßßßÛ ÛßßßÜ Ûßßßß + ßßßßÛ ÛÛ ÛÛßÛß ÛÛßß ÛÛßß ÛÛßÛÛ ÛÛß Û ÛÛ Û ÛÛ Û ÛÛßß + ßßßßß ßßßßß ßß ß ßßßßß ßßßßß ßß ß ßßßßß ßß ß ßßßßß ßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ diff --git a/LIB386/LIB_SVGA/BUILD.BAT b/LIB386/LIB_SVGA/BUILD.BAT new file mode 100644 index 0000000..3b9991b --- /dev/null +++ b/LIB386/LIB_SVGA/BUILD.BAT @@ -0,0 +1,13 @@ +call watcom10 + +pkunzip -o obj >NUL +wmake +pkzip -m obj *.obj >NUL + +call watcom9 + +pkunzip -o obj9 >NUL +wmake WATCOM9=yes +pkzip -m obj9 *.obj >NUL + +call watcom10 diff --git a/LIB386/LIB_SVGA/BUILDDLL.BAT b/LIB386/LIB_SVGA/BUILDDLL.BAT new file mode 100644 index 0000000..2eb1801 --- /dev/null +++ b/LIB386/LIB_SVGA/BUILDDLL.BAT @@ -0,0 +1,3 @@ +pkunzip -o obj >NUL +wmake /f dll.mak +pkzip -m obj *.obj >NUL diff --git a/LIB386/LIB_SVGA/CPYMASK.ASM b/LIB386/LIB_SVGA/CPYMASK.ASM new file mode 100644 index 0000000..1a7ae2d --- /dev/null +++ b/LIB386/LIB_SVGA/CPYMASK.ASM @@ -0,0 +1,405 @@ +;---------------------------------------------------------------------------- +; Mask_A.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386P + jumps + .model SMALL, SYSCALL +;---------------------------------------------------------------------------- + .data +;---------------------------------------------------------------------------- + include \projet\lib386\lib_svga\svga.ash +comment @ + DWORD TabOffset[] + Brick: + - BYTE Delta X + - BYTE Delta Y + Line(Delta Y): + - BYTE NbBlock + Block 0: Nb Zero to Jump + Block 1: Nb Zero to Write + Block 2: Nb Zero to Jump + etc... +@ + +BufferClip db 512 dup(?) +OffsetBegin dd 0 +NbPix dd 0 + +extrn NoLanguage Screen:DWORD + +;---------------------------------------------------------------------------- + .code + + public NoLanguage CopyMask + +;---------------------------------------------------------------------------- +CopyMask proc uses esi edi ebx ebp,\ + nummask:DWORD, xmask:DWORD, ymask:DWORD, \ + bankmask:DWORD, ptsrc:DWORD + + mov eax, nummask + mov ebx, xmask + mov ecx, ymask + mov esi, bankmask + + add esi, [esi+eax*4]; ESI = Begin Data + + + movzx eax, byte ptr[esi+2] ; Hot X + add ebx, eax + movzx eax, byte ptr[esi+3] ; Hot Y + add ecx, eax + + +;----------------------------------------------- + lodsb ; Delta X + movzx edx, al ; + lodsb ; Nb Line ( Delta Y ) + movzx eax, al + + + add esi, 2 ; Jump Hot X & Hot Y + + +;----------------------------------------------- Test Clipping + add edx, ebx + add eax, ecx + dec edx + dec eax + cmp ebx, ClipXmin + jl ClippingMask + cmp ecx, ClipYmin + jl ClippingMask + cmp edx, ClipXmax + jg ClippingMask + cmp eax, ClipYmax + jg ClippingMask + sub edx, ebx + sub eax, ecx + inc edx + inc eax +;----------------------------------------------- Calcul Offset Ecran + add ebx, TabOffLine[ecx*4] + + mov edi, Log + add edi, ebx + + mov ebp, ptsrc + add ebp, ebx + + mov bh, al ; BH = NbLine + sub edx, Screen_X ; EDX = Offset Screen + neg edx ; EDX = Screen_X-edx + xor ecx, ecx ; Maz Compteur + mov eax, ecx +;----------------------------------------------- Init NbBlock for this line +NextLine: lodsb ; Nb Block for this line + mov bl, al ; BL = NbBlock +;----------------------------------------------- Manage One Line +SameLine: lodsb ; Nb Zero to Jump + add edi, eax ; Incrust on Log + add ebp, eax ; And on PtSrc + + dec bl + je EndBlock + + lodsb ; Nb Zero to Write + mov cl, al + +; xor al, al +; rep stosb + + xchg esi, ebp + mov al, cl + shr cl, 2 + rep movsd ; Write Datas From PtSrc + mov cl, al + and cl, 11b + rep movsb + xchg esi, ebp + + + dec bl ; Nb Block-- + jne SameLine ; Continue Same Line +EndBlock: + add edi, edx ; EDI += Offset Screen + add ebp, edx + dec bh ; NbLine-- + jne NextLine ; Next Line +;----------------------------------------------- Incrust + ret +;-------------------------------------------------------------------- Clipping +; Graph : ( EBX, ECX ) ( EDX, EAX ) +ClippingMask: + cmp ebx, ClipXmax + jg EndMask + cmp ecx, ClipYmax + jg EndMask + cmp edx, ClipXmin + jl EndMask + cmp eax, ClipYmin + jl EndMask + + cmp ecx, ClipYmin + jge PasHaut + +;---------------------- Clipping Haut, Saute ClipYmin-ECX Line(s) + + sub ecx, ClipYMin + neg ecx + mov ebp, eax + xor eax, eax + +NextH: lodsb + add esi, eax + loop NextH + + mov ecx, ClipYMin + mov eax, ebp + +;---------------------- Clipping Bas +PasHaut: cmp eax, ClipYmax + jle PasBas + mov eax, ClipYmax +;---------------------- Clipping Gauche +Pasbas: mov OffsetBegin, 0 + cmp ebx, ClipXmin + jge PasGauche + + mov ebp, ClipXmin + sub ebp, ebx + mov OffsetBegin, ebp + +;---------------------- Clipping Droit +PasGauche: + mov ebp, edx + sub ebp, ebx + sub ebp, OffsetBegin + inc ebp + mov NbPix, ebp + + cmp edx, ClipXmax + jle PasDroit + + sub edx, ClipXmax + sub NbPix, edx + mov edx, ClipXmax +;---------------------- + + + + + + + + + +PasDroit: ; ESI debut data Y ok pas X + ; EBX not clipped X0 + ; ECX good Y0 + ; EAX clipped Y1 + ; NbPix real X nb pix + ; OffsetBegin start X ( !!!!! < 128 ) + + mov ebp, esi + + mov edi, TabOffLine[ecx*4] + add edi, ebx + mov esi, edi ; good Y offset screen + add edi, Log + add esi, Screen ; Screen + + mov edx, eax + sub edx, ecx + inc edx + + xor ecx, ecx + +l1: push esi + push edi + + mov bl, byte ptr[ebp] ; nb blocs + inc ebp + + mov bh, byte ptr[NbPix] ; nb point … copier + + mov ecx, [OffsetBegin] ; start x + mov ah, cl ; nb pix count + add edi, ecx ; new pos screen + add esi, ecx + +l0: mov al, byte ptr[ebp] ; nb pix to jump + inc ebp + dec bl + sub ah, al + jz okdraw ; tombe pile + jc rptj ; reste pix to jump + or bl, bl + jz aplus + + mov al, byte ptr[ebp] ; nb copy point + inc ebp + dec bl + sub ah, al + jz okjump + jc rgtc ; reste graph to copy + + or bl, bl ; jmp l0 + jnz l0 + jmp aplus + +rptj: neg ah ; ah nb pix to jump + mov cl, ah + sub bh, ah ; reste … ecrire + jle aplus + add edi, ecx + add esi, ecx + jmp okdraw + +rgtc: neg ah ; al nb pix to copy + mov cl, ah + sub bh, ah ; reste … ecrire + jc cpt ; copy pas tout + rep movsb ; copy + jz aplus ; tombe pile + jmp okjump + +cpt: add cl, bh + rep movsb + jmp aplus + + EVEN +okjump: mov cl, byte ptr[ebp] ; al nb pix to jump + inc ebp + dec bl + jz aplus + sub bh, cl ; reste … ecrire + jle aplus ; fini + add edi, ecx + add esi, ecx + +okdraw: mov cl, byte ptr[ebp] ; nb pix to copy + inc ebp + dec bl + sub bh, cl ; reste … ecrire + jc cpt ; copy pas tout + rep movsb ; copy + jz aplus ; tombe pile + or bl,bl ; nb bloc-- + jz aplus + jmp short okjump + +aplus: ; ligne finie + + movzx eax, bl + add ebp, eax + + pop edi + pop esi + add edi, 640 + add esi, 640 + + + dec dl ; nb lig-- + jnz l1 + + + + +comment # + add ebx, TabOffLine[ecx*4] + mov edi, Log + add edi, ebx + + sub eax, ecx + inc al + mov bh, al ; BH NbLine + xor ecx, ecx + mov ebp, edi +;---------------------------------------------- + ; ESI = DATAS LINE +NextL: lea edi, BufferClip ; EDI = BUFFERCLIP + lodsb ; NbBlock + mov bl, al +SameL: lodsb + mov cl, al + mov al, 1 + rep stosb + dec bl + je EndLine + lodsb + mov cl, al + xor al, al + rep stosb + dec bl + jne SameL +;---------------------- +EndLine: push esi ; SAVE ESI + lea esi, BufferClip ; ESI = BUFFERCLIP + mov edi, ebp ; EDI = SCREEN + mov ecx, OffsetBegin + add esi, ecx + add edi, ecx + mov ecx, NbPix +;---------------------- +Again: + lodsb + or al, al + jne Incrust + mov [edi], al +Incrust: inc edi + loop Again + + add ebp, 640 + pop esi + dec bh + jne NextL +;---------------------- + # + +EndMask: ret + +CopyMask endp + +;---------------------------------------------------------------------------- +; The + End + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LIB386/LIB_SVGA/DB.BAT b/LIB386/LIB_SVGA/DB.BAT new file mode 100644 index 0000000..0f8fcb6 --- /dev/null +++ b/LIB386/LIB_SVGA/DB.BAT @@ -0,0 +1 @@ +td286 -do -vg test \ No newline at end of file diff --git a/LIB386/LIB_SVGA/DLL.ASM b/LIB386/LIB_SVGA/DLL.ASM new file mode 100644 index 0000000..20d266d --- /dev/null +++ b/LIB386/LIB_SVGA/DLL.ASM @@ -0,0 +1,628 @@ +;---------------------------------------------------------------------------- +; INITSVGA.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + + .386p + jumps + .model FLAT, SYSCALL + +;---------------------------------------------------------------------------- + .code + + PUBLIC driver_start + +driver_start dd OFFSET ListFuncs + +IFDEF REALTEK + db 'Realtek RTG 3105' +ENDIF + +IFDEF OAK + db 'OAK OTI 067/077' +ENDIF + +IFDEF NCR + db 'NCR 77C22' +ENDIF + +IFDEF COMPAQ + db 'Compaq QVision/AVGA' +ENDIF + +IFDEF TSENG + db 'Tseng Lab ET 3000/4000' +ENDIF + +IFDEF PARADISE + db 'Paradise/Western Digital' +ENDIF + +IFDEF GENOA + db 'Genoa' +ENDIF + +IFDEF S3 + db 'S3' +ENDIF + +IFDEF CIRRUS + db 'Cirrus Logic' +ENDIF + +IFDEF TRIDENT + db 'Trident' +ENDIF + +IFDEF ATI + db 'ATI' +ENDIF + + db ' Super VGA Driver, Version 1.00,', 13, 10 + db 'Copyright (c) Adeline Software International 1994, All Rights Reserved.', 13, 10, 10, 0 + + +Scanline textequ +BankSize textequ +BankOver textequ +NonStdVESA textequ +BankShift textequ + + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÛßßß Ûßßßß ÛßßßÛ Ûßßßß Ûßßßß ÛÛÜ Û ÛÜ ÜÛ ÛßßßÛ ÛßßßÜ Ûßßßß +; ßßßßÛ ÛÛ ÛÛßÛß ÛÛßß ÛÛßß ÛÛßÛÛ ÛÛß Û ÛÛ Û ÛÛ Û ÛÛßß +; ßßßßß ßßßßß ßß ß ßßßßß ßßßßß ßß ß ßßßßß ßß ß ßßßßß ßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef REALTEK + +ListFuncs dd offset InitMode + dd offset NewBank + dd 0 + +;---------------------------------------------------------------------------- +NewBank proc + + mov dx, 3D7h + out dx, al + + ret + +NewBank endp + +;---------------------------------------------------------------------------- +InitMode proc + + mov ax, 26h + int 10h + + ret + +InitMode endp + +;---------------------------------------------------------------------------- + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef OAK + +ListFuncs dd offset InitMode + dd offset NewBank + dd 0 + +;---------------------------------------------------------------------------- +NewBank proc + + mov ah, al + shl al, 4 + or ah, al + mov dx, 3DEh + mov al, 11h + out dx, ax + + ret + +NewBank endp + +;---------------------------------------------------------------------------- +InitMode proc + + mov ax, 53h + int 10h + + ret + +InitMode endp + +;---------------------------------------------------------------------------- + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef NCR + +ListFuncs dd offset InitMode + dd offset NewBank + dd 0 + +;---------------------------------------------------------------------------- +NewBank proc + + shl ax, 10 + mov al, 18h + mov dx, 03C4h + out dx, ax + + ret + +NewBank endp + +;---------------------------------------------------------------------------- +InitMode proc + + mov ax, 5Fh + int 10h + + ret + +InitMode endp + +;---------------------------------------------------------------------------- + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef COMPAQ + +ListFuncs dd offset InitMode + dd offset NewBank + dd 0 + +;---------------------------------------------------------------------------- +NewBank proc + + shl ax, 12 + mov al, 45h + mov dx, 03CEh + out dx, ax + + ret + +NewBank endp + +;---------------------------------------------------------------------------- +InitMode proc + + mov ScanLine, 1024 + mov NonStdVESA, 1 + + mov ax, 32h + int 10h + + mov dx, 03CEh + mov ax, 050Fh + out dx, ax ; unlock extended regs + + ret + +InitMode endp + +;---------------------------------------------------------------------------- + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef TSENG + +ListFuncs dd offset InitMode + dd offset NewBank + dd 0 + +;---------------------------------------------------------------------------- +NewBank proc ; ET3000, Should work + ; on the ET4000 also + ; as long as we don't + ; read the screen... + mov dx, 03CDh + or al, 40h + out dx, al + + ret + +NewBank endp + +;---------------------------------------------------------------------------- +InitMode proc ; ET3000/ET4000 + + mov ax, 2Eh ; Basculer Mode Video + int 10h ; Tseng 640*480*256 + + mov dx, 3BFh ; Enable access to extended registers + mov al, 3 ; for ET4000 + out dx, al + mov dl, 0D8h + mov al, 0A0h + out dx, al + + ret + +InitMode endp + +;---------------------------------------------------------------------------- + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef PARADISE + +ListFuncs dd offset InitMode + dd offset NewBank + dd 0 + +;---------------------------------------------------------------------------- +NewBank proc ; Western Digital / + ; Paradise + + mov dx, 03CEh + shl ax, 12 ; 4K banks + mov al, 09h + out dx, ax + + ret + +NewBank endp + +;---------------------------------------------------------------------------- +InitMode proc + + mov ax, 5Fh ; Basculer Mode Video + int 10h ; WD/Paradise 640*480*256 + + mov dx, 03CEh + mov al, 0Fh + out dx, al + inc dx ; 3CFh + in al, dx + and al, 11101000b + or al, 00000101b + out dx, al + + dec dx ; 3CEh + mov al, 0Bh + out dx, al + inc dx ; 3CFh + in al, dx + and al, 11110111b + out dx, al + + mov dl, 0C4h ; 3C4h + mov al, 11h + out dx, al + inc dx ; 3C5h + in al, dx + and al, 01111111b + out dx, al + + ret + +InitMode endp + +;---------------------------------------------------------------------------- + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef GENOA + +ListFuncs dd offset InitMode + dd offset NewBank + dd 0 + +;---------------------------------------------------------------------------- +NewBank proc ; Genoa (not old ET3000 model) + + mov dx, 03C4h + mov ah, al + shl ah, 3 + or ah, al + or ah, 40h + mov al, 06h + out dx, ax + + ret + +NewBank endp + +;---------------------------------------------------------------------------- +InitMode proc ; Genoa (not old ET3000 model) + + mov ax, 5Ch ; Basculer Mode Video + int 10h ; Genoa 640*480*256 + + ret + +InitMode endp + +;---------------------------------------------------------------------------- + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef S3 + +ListFuncs dd 0 + dd offset NewBank + dd offset Enable + +;---------------------------------------------------------------------------- +NewBank proc + + mov dx, 3d4h ; Switch banks + mov ah, al + mov al, 35h + out dx, ax + + ret + +NewBank endp + +;---------------------------------------------------------------------------- +Enable proc + + mov dx, 3d4h ; Enable extended registers + mov al, 38h + out dx, al + inc dx + mov al, 48h + out dx, al + + dec dx ; Enable write to bank registers + mov al, 31h + out dx, al + inc dx + mov al, 89h + in al, dx + mov ah, al + dec dx + mov al, 31h + out dx, al + inc dx + mov al, ah + or al, 9 + out dx, al + + ret + +Enable endp + +;---------------------------------------------------------------------------- + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef CIRRUS + +ListFuncs dd 0 + dd offset NewBank + dd offset Enable + +;---------------------------------------------------------------------------- +NewBank proc + + mov dx, 03CEh + shl ax, 12 + mov al, 09h + out dx, ax + dec al + out dx, al + + ret + +NewBank endp + +;---------------------------------------------------------------------------- +Enable proc + +comment @ + mov dx, 03D4h ; 3D4h + mov al, 0Ch ; Screen A start addr Hi + out dx, al + inc dx ; 3D5h + in al, dx + mov cl, al ; cl = start addr + xor al, al + out dx, al ; write 0 to gain + ; access to Eagle ID + + dec dx ; 3D4h + mov al, 1Fh ; Eagle ID reg + out dx, al + inc dx ; 3D5h + in al, dx ; get Eagle ID + mov ah, al ; ah = Eagle ID + + mov dl, 0C4h ; 3C4h + mov al, 06h ; extension register + mov ah, 12h ; should not be there + out dx, ax ; write Eagle ID to + ; enable extended regs + ; Used to be 12h... + + mov dl, 0D4h ; 3D4h + mov al, 0Ch ; Screen A start addr Hi + mov ah, cl ; old start addr + out dx, ax ; write old value + + @ + mov dx, 3c4h + mov ax, 1206h + out dx, ax + + ret + +Enable endp + +;---------------------------------------------------------------------------- + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef TRIDENT + +ListFuncs dd offset InitMode + dd offset NewBank + dd 0 + +;---------------------------------------------------------------------------- +NewBank proc + + mov dx, 3C4h + xor al, 2 ; (strange chip design) + mov ah, al + mov al, 0Eh + out dx, ax + + ret + +NewBank endp + +;---------------------------------------------------------------------------- +InitMode proc + + mov ax, 5Dh ; Basculer Mode Video + int 10h ; Trident 640*480*256 + + mov dx, 3CEh ; set pagesize to 64k + mov al, 6 + out dx, al + inc dx + in al, dx + or al, 4 + mov ah, al + mov al, 6 + dec dx + out dx, ax + + mov dl, 0C4h ; switch to BPS mode + mov al, 0Bh + out dx, al + inc dx + in al, dx + + ret + +InitMode endp + +;---------------------------------------------------------------------------- + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +ifdef ATI + +ListFuncs dd offset InitMode + dd offset NewBank + dd 0 + +comment @ + +;---------------------------------------------------------------------------- +NewBank proc + + shl ax, 9 + + mov dx, 1CEh + mov al, 0B2h + out dx, al + inc dx + in al, dx + and al, 0E1h + or ah, al + mov al, 0B2h + dec dx + out dx, ax + + ret + +NewBank endp + +;---------------------------------------------------------------------------- +InitMode proc + + mov ax, 62h ; Basculer Mode Video + int 10h ; ATI 640*480*256 + ret + +InitMode endp + +;---------------------------------------------------------------------------- + + @ + +NewBank proc + + shl ax, 9 + +extended_reg equ $+4 + mov dx, 1CEh + mov al, 0B2h + out dx, al + inc dx + in al, dx + and al, 0E1h + or ah, al + mov al, 0B2h + dec dx + out dx, ax + + ret + +NewBank endp + +;---------------------------------------------------------------------------- +InitMode proc + + mov ax, 62h ; Basculer Mode Video + int 10h ; ATI 640*480*256 + + mov ax, [0C0010h] + mov word ptr[extended_reg], ax + + ret + +InitMode endp + +;---------------------------------------------------------------------------- + +endif + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + + End diff --git a/LIB386/LIB_SVGA/DLL.MAK b/LIB386/LIB_SVGA/DLL.MAK new file mode 100644 index 0000000..cf5dc87 --- /dev/null +++ b/LIB386/LIB_SVGA/DLL.MAK @@ -0,0 +1,91 @@ +AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=; +LINKDIR = format os2 lx dll + +dll: realtek.dll oak.dll ncr.dll compaq.dll ati.dll cirrus.dll genoa.dll paradise.dll s3.dll trident.dll tseng.dll + +# +# Svga driver: REALTEK +# + +realtek.dll: dll.asm + ml $(AFLAGS) /DREALTEK dll.asm + wlink n realtek.dll f dll $(LINKDIR) + +# +# Svga driver: OAK +# + +oak.dll: dll.asm + ml $(AFLAGS) /DOAK dll.asm + wlink n oak.dll f dll $(LINKDIR) + +# +# Svga driver: NCR +# + +ncr.dll: dll.asm + ml $(AFLAGS) /DNCR dll.asm + wlink n ncr.dll f dll $(LINKDIR) + +# +# Svga driver: COMPAQ +# + +compaq.dll: dll.asm + ml $(AFLAGS) /DCOMPAQ dll.asm + wlink n compaq.dll f dll $(LINKDIR) + +# +# Svga driver: ATI +# + +ati.dll: dll.asm + ml $(AFLAGS) /DATI dll.asm + wlink n ati.dll f dll $(LINKDIR) + +# +# Svga driver: CIRRUS +# + +cirrus.dll: dll.asm + ml $(AFLAGS) /DCIRRUS dll.asm + wlink n cirrus.dll f dll $(LINKDIR) +# +# Svga driver: GENOA +# + +genoa.dll: dll.asm + ml $(AFLAGS) /DGENOA dll.asm + wlink n genoa.dll f dll $(LINKDIR) + +# +# Svga driver: PARADISE +# + +paradise.dll: dll.asm + ml $(AFLAGS) /DPARADISE dll.asm + wlink n paradise.dll f dll $(LINKDIR) + +# +# Svga driver: S3 +# + +s3.dll: dll.asm + ml $(AFLAGS) /DS3 dll.asm + wlink n s3.dll f dll $(LINKDIR) + +# +# Svga driver: TRIDENT +# + +trident.dll: dll.asm + ml $(AFLAGS) /DTRIDENT dll.asm + wlink n trident.dll f dll $(LINKDIR) + +# +# Svga driver: Tseng Lab ET3000 & ET4000 +# + +tseng.dll: dll.asm + ml $(AFLAGS) /DTSENG dll.asm + wlink n tseng.dll f dll $(LINKDIR) diff --git a/LIB386/LIB_SVGA/DLL_I.ASM b/LIB386/LIB_SVGA/DLL_I.ASM new file mode 100644 index 0000000..c3f7266 --- /dev/null +++ b/LIB386/LIB_SVGA/DLL_I.ASM @@ -0,0 +1,129 @@ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; SAMP_A.ASM 386 +; (c) Adeline 1993 +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*--------------------------------------------------------------------------* + + .386 + jumps + + .model SMALL, SYSCALL + + .DATA + + PUBLIC NoLanguage listfcts + +listfcts dd offset Vesafcts + +Vesafcts dd offset SvgaInitVesa + dd offset SvgaBankVesa + + .CODE + + PUBLIC NoLanguage SvgaInit + PUBLIC NoLanguage SvgaBank + +;---------------------------------------------------------------------------- + +RMI equ $ +RMI_EDI dd 0 +RMI_ESI dd 0 +RMI_EBP dd 0 +RMI_RESERVED dd 0 +RMI_EBX dd 0 +RMI_EDX dd 0 +RMI_ECX dd 0 +RMI_EAX dd 0 +RMI_flags dw 0 +RMI_ES dw 0 +RMI_DS dw 0 +RMI_FS dw 0 +RMI_GS dw 0 +RMI_IP dw 0 +RMI_CS dw 0 +RMI_SP dw 0 +RMI_SS dw 0 + +;---------------------------------------------------------------------------- +NewBankVesa proc + + push ebx + +Shift equ $+3 + shl ax, 0 + mov dx, ax + mov eax, 4F05h ; change bank VESA + xor ebx, ebx ; bh = 0, set bank + int 10h + + pop ebx + + ret + +NewBankVesa endp + +;---------------------------------------------------------------------------- +InitModeVesa proc + + mov eax, 0100h ; DMPI Allocate Dos Mem + mov ebx, 32 ; 512 byte just in case + int 31h ; return dos segment in ax + push edx ; save selector + push eax ; save real-mode segment + + push es ; save es + mov RMI_ES, ax ; buffer segment + xor RMI_EDI, 0 ; buffer offset 0 + mov RMI_EAX, 4F01h ; Vesa information + mov RMI_ECX, 0101h ; mode 101h + mov ax, ds + mov es, ax ; es = ds (just in case) + mov edi, offset RMI ; registers + mov ax, 0300h ; DMPI generate real-mode int + mov bx, 10h ; int 10h + int 31h + pop es ; restore es + + pop eax ; restore real-mode segment + and eax, 0FFFFh ; only segment + shl eax, 4 ; convert to linear + mov ax, [eax+4] ; get granularity + bsr ax, ax ; get higher bit position + neg al ; - position + add al, 6 ; shift = 6 - position + mov byte ptr[Shift], al + + pop edx ; restore selector + mov eax, 0101h ; DPMI return Dos memory + int 31h + + mov ax, 4F02h ; Switch to Video Mode + mov bx, 0101h ; VESA 640*480*256 + int 10h + ret + +InitModeVesa endp + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + +NewBank PROC + + mov eax, dword ptr[listfcts] + jmp dword ptr[eax] + +NewBank ENDP + +;---------------------------------------------------------------------------- + +InitMode PROC + + mov eax, dword ptr[listfcts] + jmp dword ptr[eax+4] + +InitMode ENDP + +;---------------------------------------------------------------------------- + + END diff --git a/LIB386/LIB_SVGA/FONT6X6.ASM b/LIB386/LIB_SVGA/FONT6X6.ASM new file mode 100644 index 0000000..6cf310e --- /dev/null +++ b/LIB386/LIB_SVGA/FONT6X6.ASM @@ -0,0 +1,522 @@ +Font6X6 label byte + + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,00FH,000H,00FH,000H,000H,000H,00FH + db 000H,00FH,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,00FH + db 000H,00FH,000H,000H,00FH,00FH,00FH,00FH,00FH,000H + db 000H,00FH,000H,00FH,000H,000H,00FH,00FH,00FH,00FH + db 00FH,000H,000H,00FH,000H,00FH,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,00FH,00FH,00FH,000H + db 00FH,000H,00FH,000H,000H,000H,00FH,00FH,00FH,00FH + db 00FH,000H,000H,000H,00FH,000H,00FH,000H,00FH,00FH + db 00FH,00FH,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,00FH,000H,000H,00FH,000H,00FH,00FH,000H,00FH + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,00FH + db 000H,00FH,00FH,000H,00FH,000H,000H,00FH,00FH,000H + db 000H,000H,000H,000H,000H,000H,000H,00FH,000H,000H + db 000H,000H,00FH,000H,00FH,000H,000H,000H,000H,00FH + db 00FH,000H,00FH,000H,00FH,000H,000H,00FH,000H,000H + db 00FH,00FH,00FH,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,00FH + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,00FH,000H,000H,000H,000H + db 000H,00FH,000H,000H,000H,000H,000H,00FH,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,000H,00FH,000H,000H,000H,000H,000H,00FH + db 000H,000H,000H,000H,000H,00FH,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,00FH,000H,00FH,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,00FH,000H,00FH,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,00FH,00FH,00FH,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,00FH,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,00FH,00FH,00FH + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,00FH + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,00FH + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,00FH,00FH,00FH + db 000H,000H,00FH,000H,000H,00FH,00FH,000H,00FH,000H + db 00FH,000H,00FH,000H,00FH,00FH,000H,000H,00FH,000H + db 000H,00FH,00FH,00FH,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,00FH + db 00FH,000H,000H,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,00FH,00FH,00FH + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,00FH + db 00FH,00FH,000H,000H,00FH,000H,000H,000H,00FH,000H + db 000H,000H,00FH,00FH,000H,000H,000H,00FH,000H,000H + db 000H,000H,00FH,00FH,00FH,00FH,00FH,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,00FH,00FH,000H,000H + db 00FH,000H,000H,000H,00FH,000H,000H,000H,00FH,00FH + db 000H,000H,00FH,000H,000H,000H,00FH,000H,000H,00FH + db 00FH,00FH,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,00FH,000H,00FH,000H + db 000H,000H,00FH,00FH,00FH,00FH,00FH,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,00FH,00FH,00FH,00FH + db 00FH,000H,00FH,000H,000H,000H,000H,000H,00FH,00FH + db 00FH,00FH,000H,000H,000H,000H,000H,000H,00FH,000H + db 00FH,00FH,00FH,00FH,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,00FH,00FH,00FH,000H,000H,00FH,000H + db 000H,000H,000H,000H,00FH,00FH,00FH,00FH,000H,000H + db 00FH,000H,000H,000H,00FH,000H,000H,00FH,00FH,00FH + db 000H,000H,000H,000H,000H,000H,000H,000H,00FH,00FH + db 00FH,00FH,00FH,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,00FH,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,00FH,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,00FH,00FH,000H,000H + db 00FH,000H,000H,000H,00FH,000H,000H,00FH,00FH,00FH + db 000H,000H,00FH,000H,000H,000H,00FH,000H,000H,00FH + db 00FH,00FH,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,00FH,00FH,00FH,000H,000H,00FH,000H,000H,000H + db 00FH,000H,000H,00FH,00FH,00FH,00FH,000H,000H,000H + db 000H,000H,00FH,000H,00FH,00FH,00FH,00FH,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,00FH,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,00FH,000H,000H,000H,000H,00FH,000H,000H,000H + db 000H,00FH,000H,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,00FH,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,00FH,00FH,00FH,00FH,000H,000H,000H,000H,000H + db 000H,000H,00FH,00FH,00FH,00FH,00FH,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,00FH,000H,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,00FH,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,00FH,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,00FH,00FH,00FH + db 000H,000H,00FH,000H,000H,000H,00FH,000H,000H,000H + db 00FH,00FH,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,00FH,00FH,00FH,000H,000H,00FH,000H + db 00FH,000H,00FH,000H,00FH,000H,00FH,00FH,00FH,000H + db 00FH,000H,000H,000H,000H,000H,000H,00FH,00FH,00FH + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,00FH + db 00FH,00FH,000H,000H,00FH,000H,000H,000H,00FH,000H + db 00FH,00FH,00FH,00FH,00FH,000H,00FH,000H,000H,000H + db 00FH,000H,00FH,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,000H,000H,00FH,00FH,00FH,000H,000H,000H + db 00FH,000H,000H,00FH,000H,000H,00FH,00FH,00FH,00FH + db 00FH,000H,00FH,000H,000H,000H,00FH,000H,00FH,00FH + db 00FH,00FH,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,00FH,00FH,00FH,000H,000H,00FH,000H,000H,000H + db 00FH,000H,00FH,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,00FH,000H,000H,00FH,00FH,00FH,000H,000H + db 000H,000H,000H,000H,000H,000H,00FH,00FH,00FH,00FH + db 000H,000H,00FH,000H,000H,000H,00FH,000H,00FH,000H + db 000H,000H,00FH,000H,00FH,000H,000H,000H,00FH,000H + db 00FH,00FH,00FH,00FH,000H,000H,000H,000H,000H,000H + db 000H,000H,00FH,00FH,00FH,00FH,00FH,000H,00FH,000H + db 000H,000H,000H,000H,00FH,00FH,00FH,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,00FH,00FH,00FH,00FH + db 00FH,000H,000H,000H,000H,000H,000H,000H,00FH,00FH + db 00FH,00FH,00FH,000H,00FH,000H,000H,000H,000H,000H + db 00FH,00FH,00FH,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,00FH,00FH,00FH,000H + db 00FH,000H,000H,000H,000H,000H,00FH,000H,00FH,00FH + db 00FH,000H,00FH,000H,000H,000H,00FH,000H,000H,00FH + db 00FH,00FH,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,00FH,000H,00FH,000H,000H,000H + db 00FH,000H,00FH,00FH,00FH,00FH,00FH,000H,00FH,000H + db 000H,000H,00FH,000H,00FH,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,00FH,00FH,00FH,00FH + db 00FH,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,00FH,000H,000H,000H + db 00FH,00FH,00FH,00FH,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,00FH,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,00FH,000H + db 00FH,000H,000H,000H,00FH,000H,000H,00FH,00FH,00FH + db 000H,000H,000H,000H,000H,000H,000H,000H,00FH,000H + db 000H,00FH,000H,000H,00FH,000H,00FH,000H,000H,000H + db 00FH,00FH,00FH,000H,000H,000H,00FH,000H,000H,00FH + db 000H,000H,00FH,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,00FH,00FH + db 00FH,00FH,00FH,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,00FH,000H,00FH,00FH,000H,00FH + db 00FH,000H,00FH,000H,00FH,000H,00FH,000H,00FH,000H + db 000H,000H,00FH,000H,00FH,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,00FH,000H,000H,000H + db 00FH,000H,00FH,00FH,000H,000H,00FH,000H,00FH,000H + db 00FH,000H,00FH,000H,00FH,000H,000H,00FH,00FH,000H + db 00FH,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,00FH,00FH,00FH,000H,000H,00FH,000H + db 000H,000H,00FH,000H,00FH,000H,000H,000H,00FH,000H + db 00FH,000H,000H,000H,00FH,000H,000H,00FH,00FH,00FH + db 000H,000H,000H,000H,000H,000H,000H,000H,00FH,00FH + db 00FH,00FH,000H,000H,00FH,000H,000H,000H,00FH,000H + db 00FH,00FH,00FH,00FH,000H,000H,00FH,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,00FH,00FH,000H,000H + db 00FH,000H,000H,000H,00FH,000H,00FH,000H,00FH,000H + db 00FH,000H,00FH,000H,000H,00FH,000H,000H,000H,00FH + db 00FH,000H,00FH,000H,000H,000H,000H,000H,000H,000H + db 00FH,00FH,00FH,00FH,000H,000H,00FH,000H,000H,000H + db 00FH,000H,00FH,00FH,00FH,00FH,000H,000H,00FH,000H + db 000H,00FH,000H,000H,00FH,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,000H,00FH,00FH,00FH + db 00FH,000H,00FH,000H,000H,000H,000H,000H,000H,00FH + db 00FH,00FH,000H,000H,000H,000H,000H,000H,00FH,000H + db 00FH,00FH,00FH,00FH,000H,000H,000H,000H,000H,000H + db 000H,000H,00FH,00FH,00FH,00FH,00FH,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,00FH,000H,00FH,000H,000H,000H,00FH,000H + db 00FH,000H,000H,000H,00FH,000H,00FH,000H,000H,000H + db 00FH,000H,000H,00FH,00FH,00FH,000H,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,00FH,000H + db 00FH,000H,000H,000H,00FH,000H,000H,00FH,000H,00FH + db 000H,000H,000H,00FH,000H,00FH,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,00FH,000H,00FH,000H,000H,000H + db 00FH,000H,00FH,000H,00FH,000H,00FH,000H,00FH,00FH + db 000H,00FH,00FH,000H,00FH,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,00FH,000H,000H,000H + db 00FH,000H,000H,00FH,000H,00FH,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,00FH,000H,00FH,000H,000H + db 00FH,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,00FH,000H,000H,00FH + db 000H,00FH,000H,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,00FH,00FH + db 00FH,00FH,00FH,000H,000H,000H,000H,00FH,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,00FH,000H,000H + db 000H,000H,00FH,00FH,00FH,00FH,00FH,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,00FH,000H,000H,000H + db 000H,00FH,000H,000H,000H,000H,000H,00FH,000H,000H + db 000H,000H,000H,00FH,000H,000H,000H,000H,000H,00FH + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,00FH,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,00FH,000H,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,00FH,00FH + db 000H,000H,000H,000H,000H,00FH,000H,000H,000H,000H + db 000H,00FH,000H,000H,000H,000H,000H,00FH,000H,000H + db 000H,000H,00FH,00FH,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,00FH + db 000H,00FH,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,00FH,00FH + db 00FH,00FH,00FH,00FH,000H,00FH,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,00FH,00FH,00FH,000H,000H,00FH,000H,000H,000H + db 00FH,000H,00FH,00FH,00FH,00FH,00FH,000H,00FH,000H + db 000H,000H,00FH,000H,00FH,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,00FH,00FH,00FH,000H + db 000H,000H,00FH,000H,000H,00FH,000H,000H,00FH,00FH + db 00FH,00FH,00FH,000H,00FH,000H,000H,000H,00FH,000H + db 00FH,00FH,00FH,00FH,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,00FH,00FH,00FH,000H,000H,00FH,000H + db 000H,000H,00FH,000H,00FH,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,00FH,000H,000H,00FH,00FH,00FH + db 000H,000H,000H,000H,000H,000H,000H,000H,00FH,00FH + db 00FH,00FH,000H,000H,00FH,000H,000H,000H,00FH,000H + db 00FH,000H,000H,000H,00FH,000H,00FH,000H,000H,000H + db 00FH,000H,00FH,00FH,00FH,00FH,000H,000H,000H,000H + db 000H,000H,000H,000H,00FH,00FH,00FH,00FH,00FH,000H + db 00FH,000H,000H,000H,000H,000H,00FH,00FH,00FH,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,00FH,00FH + db 00FH,00FH,00FH,000H,000H,000H,000H,000H,000H,000H + db 00FH,00FH,00FH,00FH,00FH,000H,00FH,000H,000H,000H + db 000H,000H,00FH,00FH,00FH,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,00FH,00FH,00FH + db 00FH,000H,00FH,000H,000H,000H,000H,000H,00FH,000H + db 00FH,00FH,00FH,000H,00FH,000H,000H,000H,00FH,000H + db 000H,00FH,00FH,00FH,000H,000H,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,00FH,000H,00FH,000H + db 000H,000H,00FH,000H,00FH,00FH,00FH,00FH,00FH,000H + db 00FH,000H,000H,000H,00FH,000H,00FH,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,00FH,00FH + db 00FH,00FH,00FH,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,00FH,00FH,00FH,00FH,00FH,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,00FH,00FH,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 00FH,000H,00FH,000H,000H,000H,00FH,000H,000H,00FH + db 00FH,00FH,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,00FH,000H,000H,00FH,000H,00FH,000H + db 000H,000H,00FH,00FH,00FH,000H,000H,000H,00FH,000H + db 000H,00FH,000H,000H,00FH,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 00FH,00FH,00FH,00FH,00FH,000H,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,00FH,000H,00FH,00FH + db 000H,00FH,00FH,000H,00FH,000H,00FH,000H,00FH,000H + db 00FH,000H,000H,000H,00FH,000H,00FH,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,00FH,000H,00FH,00FH,000H,000H,00FH,000H + db 00FH,000H,00FH,000H,00FH,000H,00FH,000H,000H,00FH + db 00FH,000H,00FH,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,00FH,00FH,000H,000H + db 00FH,000H,000H,000H,00FH,000H,00FH,000H,000H,000H + db 00FH,000H,00FH,000H,000H,000H,00FH,000H,000H,00FH + db 00FH,00FH,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,00FH,00FH,00FH,000H,000H,00FH,000H,000H,000H + db 00FH,000H,00FH,00FH,00FH,00FH,000H,000H,00FH,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,00FH,00FH,00FH + db 000H,000H,00FH,000H,000H,000H,00FH,000H,00FH,000H + db 00FH,000H,00FH,000H,00FH,000H,000H,00FH,000H,000H + db 000H,00FH,00FH,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,00FH,00FH,00FH,00FH,000H,000H,00FH,000H + db 000H,000H,00FH,000H,00FH,00FH,00FH,00FH,000H,000H + db 00FH,000H,000H,00FH,000H,000H,00FH,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,00FH + db 00FH,00FH,00FH,000H,00FH,000H,000H,000H,000H,000H + db 000H,00FH,00FH,00FH,000H,000H,000H,000H,000H,000H + db 00FH,000H,00FH,00FH,00FH,00FH,000H,000H,000H,000H + db 000H,000H,000H,000H,00FH,00FH,00FH,00FH,00FH,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,00FH,000H,00FH,000H,000H,000H + db 00FH,000H,00FH,000H,000H,000H,00FH,000H,00FH,000H + db 000H,000H,00FH,000H,000H,00FH,00FH,00FH,000H,000H + db 000H,000H,000H,000H,000H,000H,00FH,000H,000H,000H + db 00FH,000H,00FH,000H,000H,000H,00FH,000H,000H,00FH + db 000H,00FH,000H,000H,000H,00FH,000H,00FH,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,00FH,000H,00FH,000H + db 000H,000H,00FH,000H,00FH,000H,00FH,000H,00FH,000H + db 00FH,00FH,000H,00FH,00FH,000H,00FH,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,00FH,000H,000H,00FH,000H,00FH,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,00FH,000H,00FH + db 000H,000H,00FH,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,00FH,000H + db 000H,00FH,000H,00FH,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,00FH,00FH,00FH,00FH,000H,000H,000H,000H,00FH + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,00FH + db 000H,000H,000H,000H,00FH,00FH,00FH,00FH,00FH,000H + db 000H,000H,000H,000H,000H,000H,000H,00FH,00FH,000H + db 000H,000H,000H,00FH,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,00FH,000H,000H,000H,000H + db 000H,00FH,00FH,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,00FH,000H,000H,000H,000H,000H,00FH,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,00FH + db 000H,000H,000H,000H,00FH,00FH,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,000H,00FH,000H,000H + db 00FH,000H,00FH,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,00FH,000H,00FH,000H,000H,00FH,000H + db 000H,000H,00FH,000H,00FH,00FH,00FH,00FH,00FH,000H + db 000H,000H,000H,000H,000H,000H,000H,00FH,00FH,00FH + db 00FH,000H,00FH,000H,000H,000H,000H,000H,000H,00FH + db 00FH,00FH,00FH,000H,000H,000H,000H,00FH,000H,000H + db 000H,000H,00FH,00FH,000H,000H,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,00FH,000H + db 00FH,000H,000H,000H,00FH,000H,000H,00FH,00FH,00FH + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,00FH,000H,000H,000H,000H + db 00FH,00FH,00FH,00FH,00FH,000H,00FH,00FH,00FH,000H + db 000H,000H,00FH,00FH,00FH,00FH,00FH,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,00FH,00FH,000H,000H + db 00FH,000H,000H,000H,00FH,000H,000H,00FH,00FH,00FH + db 000H,000H,00FH,00FH,00FH,00FH,00FH,000H,00FH,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,000H,000H + db 00FH,00FH,000H,00FH,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,00FH,00FH,00FH,000H,000H,00FH,00FH + db 00FH,00FH,00FH,000H,00FH,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,000H,00FH,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,00FH + db 00FH,00FH,000H,000H,00FH,00FH,00FH,00FH,00FH,000H + db 00FH,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,00FH,00FH,000H,000H + db 00FH,00FH,00FH,00FH,00FH,000H,00FH,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,00FH + db 00FH,00FH,00FH,000H,00FH,000H,000H,000H,000H,000H + db 000H,00FH,00FH,00FH,00FH,000H,000H,000H,000H,00FH + db 000H,000H,000H,000H,00FH,00FH,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,00FH,000H,000H,000H + db 000H,00FH,000H,00FH,000H,000H,00FH,00FH,00FH,00FH + db 00FH,000H,00FH,00FH,00FH,000H,000H,000H,00FH,00FH + db 00FH,00FH,00FH,000H,000H,000H,000H,000H,000H,000H + db 00FH,00FH,000H,00FH,00FH,000H,000H,000H,000H,000H + db 000H,000H,00FH,00FH,00FH,00FH,00FH,000H,00FH,00FH + db 00FH,000H,000H,000H,00FH,00FH,00FH,00FH,00FH,000H + db 000H,000H,000H,000H,000H,000H,000H,00FH,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,00FH,00FH + db 00FH,00FH,00FH,000H,00FH,00FH,00FH,000H,000H,000H + db 00FH,00FH,00FH,00FH,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,00FH,000H,00FH,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,00FH,000H,00FH,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,00FH,000H,00FH,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,00FH,00FH,00FH,000H,000H,00FH,00FH + db 00FH,00FH,00FH,000H,00FH,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,000H,00FH,00FH,00FH + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,00FH + db 00FH,00FH,000H,000H,00FH,00FH,00FH,00FH,00FH,000H + db 00FH,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,00FH + db 000H,000H,000H,000H,00FH,00FH,00FH,00FH,00FH,000H + db 00FH,00FH,00FH,000H,000H,000H,00FH,00FH,00FH,00FH + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,00FH,00FH,00FH,000H,000H,00FH,000H,000H,000H + db 00FH,000H,000H,00FH,00FH,00FH,000H,000H,000H,00FH + db 000H,00FH,000H,000H,000H,00FH,00FH,00FH,000H,000H + db 000H,000H,000H,000H,000H,000H,00FH,00FH,000H,00FH + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,00FH + db 00FH,00FH,000H,000H,00FH,000H,000H,000H,00FH,000H + db 000H,00FH,00FH,00FH,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,00FH,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,00FH,00FH,00FH,000H,000H + db 00FH,000H,000H,000H,00FH,000H,000H,00FH,00FH,00FH + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,00FH + db 00FH,00FH,000H,000H,00FH,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,00FH,000H,000H,000H + db 00FH,000H,000H,00FH,00FH,00FH,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,00FH,000H,000H,000H + db 00FH,000H,00FH,000H,000H,000H,00FH,000H,000H,00FH + db 00FH,00FH,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,00FH,000H,000H,00FH + db 00FH,00FH,00FH,000H,000H,000H,000H,000H,00FH,000H + db 000H,00FH,00FH,00FH,000H,000H,000H,00FH,00FH,00FH + db 000H,000H,00FH,000H,000H,000H,00FH,000H,000H,00FH + db 00FH,00FH,000H,000H,000H,00FH,000H,00FH,000H,000H + db 000H,00FH,00FH,00FH,000H,000H,000H,000H,000H,000H + db 000H,000H,00FH,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,00FH,000H + db 00FH,000H,000H,000H,00FH,000H,000H,00FH,00FH,00FH + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,00FH,00FH,00FH,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,00FH,00FH,00FH + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,00FH,00FH,000H,000H + db 00FH,000H,000H,000H,00FH,000H,00FH,00FH,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,00FH,00FH + db 00FH,00FH,00FH,000H,000H,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,00FH,000H,000H,00FH,000H,00FH + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,00FH + db 00FH,00FH,000H,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,00FH,00FH,000H,00FH + db 000H,000H,00FH,00FH,000H,00FH,00FH,000H,00FH,000H + db 000H,00FH,000H,000H,00FH,000H,000H,000H,00FH,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,00FH,000H,000H,000H,000H + db 00FH,000H,00FH,000H,000H,00FH,00FH,000H,000H,000H + db 000H,000H,00FH,00FH,000H,000H,00FH,000H,00FH,000H + db 000H,000H,000H,00FH,000H,000H,000H,000H,000H,000H + db 000H,00FH,000H,000H,000H,000H,00FH,000H,000H,000H + db 000H,00FH,00FH,00FH,000H,000H,00FH,00FH,00FH,00FH + db 00FH,000H,00FH,000H,000H,000H,00FH,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,00FH,000H,000H + db 000H,000H,00FH,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,00FH,000H,000H,000H,000H,000H + db 00FH,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,00FH,000H,000H,000H,000H,00FH,000H + db 000H,000H,000H,00FH,00FH,00FH,000H,000H,00FH,000H + db 000H,000H,00FH,000H,000H,00FH,00FH,00FH,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,00FH + db 000H,000H,000H,000H,00FH,000H,000H,000H,00FH,000H + db 000H,000H,00FH,000H,00FH,000H,000H,000H,00FH,000H + db 000H,00FH,00FH,00FH,000H,000H,000H,000H,000H,000H + db 000H,000H,00FH,000H,00FH,000H,000H,000H,000H,00FH + db 000H,00FH,000H,000H,000H,000H,000H,000H,000H,000H + db 00FH,00FH,000H,00FH,000H,000H,00FH,000H,00FH,00FH + db 000H,000H,000H,000H,000H,000H,000H,000H,00FH,000H + db 00FH,000H,000H,000H,000H,00FH,000H,00FH,000H,000H + db 000H,000H,000H,000H,000H,000H,00FH,00FH,000H,00FH + db 000H,000H,00FH,000H,00FH,00FH,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H + db 000H,000H,000H,000H + diff --git a/LIB386/LIB_SVGA/FONT8X8.ASM b/LIB386/LIB_SVGA/FONT8X8.ASM new file mode 100644 index 0000000..e773df6 --- /dev/null +++ b/LIB386/LIB_SVGA/FONT8X8.ASM @@ -0,0 +1 @@ +Font8X8 db 0, 0, 0, 0, 0, 0, 0, 0 db 126, 129, 165, 129, 189, 153, 129, 126 db 126, 255, 219, 255, 195, 231, 255, 126 db 108, 254, 254, 254, 124, 56, 16, 0 db 16, 56, 124, 254, 124, 56, 16, 0 db 56, 124, 56, 254, 254, 146, 16, 124 db 0, 16, 56, 124, 254, 124, 56, 124 db 0, 0, 24, 60, 60, 24, 0, 0 db 255, 255, 231, 195, 195, 231, 255, 255 db 0, 60, 102, 66, 66, 102, 60, 0 db 255, 195, 153, 189, 189, 153, 195, 255 db 15, 7, 15, 125, 204, 204, 204, 120 db 60, 102, 102, 102, 60, 24, 126, 24 db 63, 51, 63, 48, 48, 112, 240, 224 db 127, 99, 127, 99, 99, 103, 230, 192 db 153, 90, 60, 231, 231, 60, 90, 153 db 128, 224, 248, 254, 248, 224, 128, 0 db 2, 14, 62, 254, 62, 14, 2, 0 db 24, 60, 126, 24, 24, 126, 60, 24 db 102, 102, 102, 102, 102, 0, 102, 0 db 127, 219, 219, 123, 27, 27, 27, 0 db 62, 99, 56, 108, 108, 56, 134, 252 db 0, 0, 0, 0, 126, 126, 126, 0 db 24, 60, 126, 24, 126, 60, 24, 255 db 24, 60, 126, 24, 24, 24, 24, 0 db 24, 24, 24, 24, 126, 60, 24, 0 db 0, 24, 12, 254, 12, 24, 0, 0 db 0, 48, 96, 254, 96, 48, 0, 0 db 0, 0, 192, 192, 192, 254, 0, 0 db 0, 36, 102, 255, 102, 36, 0, 0 db 0, 24, 60, 126, 255, 255, 0, 0 db 0, 255, 255, 126, 60, 24, 0, 0 db 0, 0, 0, 0, 0, 0, 0, 0 db 24, 60, 60, 24, 24, 0, 24, 0 db 108, 108, 108, 0, 0, 0, 0, 0 db 108, 108, 254, 108, 254, 108, 108, 0 db 24, 126, 192, 124, 6, 252, 24, 0 db 0, 198, 204, 24, 48, 102, 198, 0 db 56, 108, 56, 118, 220, 204, 118, 0 db 48, 48, 96, 0, 0, 0, 0, 0 db 24, 48, 96, 96, 96, 48, 24, 0 db 96, 48, 24, 24, 24, 48, 96, 0 db 0, 102, 60, 255, 60, 102, 0, 0 db 0, 24, 24, 126, 24, 24, 0, 0 db 0, 0, 0, 0, 0, 24, 24, 48 db 0, 0, 0, 126, 0, 0, 0, 0 db 0, 0, 0, 0, 0, 24, 24, 0 db 6, 12, 24, 48, 96, 192, 128, 0 db 124, 206, 222, 246, 230, 198, 124, 0 db 48, 112, 48, 48, 48, 48, 252, 0 db 120, 204, 12, 56, 96, 204, 252, 0 db 120, 204, 12, 56, 12, 204, 120, 0 db 28, 60, 108, 204, 254, 12, 30, 0 db 252, 192, 248, 12, 12, 204, 120, 0 db 56, 96, 192, 248, 204, 204, 120, 0 db 252, 204, 12, 24, 48, 48, 48, 0 db 120, 204, 204, 120, 204, 204, 120, 0 db 120, 204, 204, 124, 12, 24, 112, 0 db 0, 24, 24, 0, 0, 24, 24, 0 db 0, 24, 24, 0, 0, 24, 24, 48 db 24, 48, 96, 192, 96, 48, 24, 0 db 0, 0, 126, 0, 126, 0, 0, 0 db 96, 48, 24, 12, 24, 48, 96, 0 db 60, 102, 12, 24, 24, 0, 24, 0 db 124, 198, 222, 222, 220, 192, 124, 0 db 48, 120, 204, 204, 252, 204, 204, 0 db 252, 102, 102, 124, 102, 102, 252, 0 db 60, 102, 192, 192, 192, 102, 60, 0 db 248, 108, 102, 102, 102, 108, 248, 0 db 254, 98, 104, 120, 104, 98, 254, 0 db 254, 98, 104, 120, 104, 96, 240, 0 db 60, 102, 192, 192, 206, 102, 58, 0 db 204, 204, 204, 252, 204, 204, 204, 0 db 120, 48, 48, 48, 48, 48, 120, 0 db 30, 12, 12, 12, 204, 204, 120, 0 db 230, 102, 108, 120, 108, 102, 230, 0 db 240, 96, 96, 96, 98, 102, 254, 0 db 198, 238, 254, 254, 214, 198, 198, 0 db 198, 230, 246, 222, 206, 198, 198, 0 db 56, 108, 198, 198, 198, 108, 56, 0 db 252, 102, 102, 124, 96, 96, 240, 0 db 124, 198, 198, 198, 214, 124, 14, 0 db 252, 102, 102, 124, 108, 102, 230, 0 db 124, 198, 224, 120, 14, 198, 124, 0 db 252, 180, 48, 48, 48, 48, 120, 0 db 204, 204, 204, 204, 204, 204, 252, 0 db 204, 204, 204, 204, 204, 120, 48, 0 db 198, 198, 198, 198, 214, 254, 108, 0 db 198, 198, 108, 56, 108, 198, 198, 0 db 204, 204, 204, 120, 48, 48, 120, 0 db 254, 198, 140, 24, 50, 102, 254, 0 db 120, 96, 96, 96, 96, 96, 120, 0 db 192, 96, 48, 24, 12, 6, 2, 0 db 120, 24, 24, 24, 24, 24, 120, 0 db 16, 56, 108, 198, 0, 0, 0, 0 db 0, 0, 0, 0, 0, 0, 0, 255 db 48, 48, 24, 0, 0, 0, 0, 0 db 0, 0, 120, 12, 124, 204, 118, 0 db 224, 96, 96, 124, 102, 102, 220, 0 db 0, 0, 120, 204, 192, 204, 120, 0 db 28, 12, 12, 124, 204, 204, 118, 0 db 0, 0, 120, 204, 252, 192, 120, 0 db 56, 108, 100, 240, 96, 96, 240, 0 db 0, 0, 118, 204, 204, 124, 12, 248 db 224, 96, 108, 118, 102, 102, 230, 0 db 48, 0, 112, 48, 48, 48, 120, 0 db 12, 0, 28, 12, 12, 204, 204, 120 db 224, 96, 102, 108, 120, 108, 230, 0 db 112, 48, 48, 48, 48, 48, 120, 0 db 0, 0, 204, 254, 254, 214, 214, 0 db 0, 0, 184, 204, 204, 204, 204, 0 db 0, 0, 120, 204, 204, 204, 120, 0 db 0, 0, 220, 102, 102, 124, 96, 240 db 0, 0, 118, 204, 204, 124, 12, 30 db 0, 0, 220, 118, 98, 96, 240, 0 db 0, 0, 124, 192, 112, 28, 248, 0 db 16, 48, 252, 48, 48, 52, 24, 0 db 0, 0, 204, 204, 204, 204, 118, 0 db 0, 0, 204, 204, 204, 120, 48, 0 db 0, 0, 198, 198, 214, 254, 108, 0 db 0, 0, 198, 108, 56, 108, 198, 0 db 0, 0, 204, 204, 204, 124, 12, 248 db 0, 0, 252, 152, 48, 100, 252, 0 db 28, 48, 48, 224, 48, 48, 28, 0 db 24, 24, 24, 0, 24, 24, 24, 0 db 224, 48, 48, 28, 48, 48, 224, 0 db 118, 220, 0, 0, 0, 0, 0, 0 db 0, 16, 56, 108, 198, 198, 254, 0 db 124, 198, 192, 198, 124, 12, 6, 124 db 0, 204, 0, 204, 204, 204, 118, 0 db 28, 0, 120, 204, 252, 192, 120, 0 db 126, 129, 60, 6, 62, 102, 59, 0 db 204, 0, 120, 12, 124, 204, 118, 0 db 224, 0, 120, 12, 124, 204, 118, 0 db 48, 48, 120, 12, 124, 204, 118, 0 db 0, 0, 124, 198, 192, 120, 12, 56 db 126, 129, 60, 102, 126, 96, 60, 0 db 204, 0, 120, 204, 252, 192, 120, 0 db 224, 0, 120, 204, 252, 192, 120, 0 db 204, 0, 112, 48, 48, 48, 120, 0 db 124, 130, 56, 24, 24, 24, 60, 0 db 224, 0, 112, 48, 48, 48, 120, 0 db 198, 16, 124, 198, 254, 198, 198, 0 db 48, 48, 0, 120, 204, 252, 204, 0 db 28, 0, 252, 96, 120, 96, 252, 0 db 0, 0, 127, 12, 127, 204, 127, 0 db 62, 108, 204, 254, 204, 204, 206, 0 db 120, 132, 0, 120, 204, 204, 120, 0 db 0, 204, 0, 120, 204, 204, 120, 0 db 0, 224, 0, 120, 204, 204, 120, 0 db 120, 132, 0, 204, 204, 204, 118, 0 db 0, 224, 0, 204, 204, 204, 118, 0 db 0, 204, 0, 204, 204, 124, 12, 248 db 195, 24, 60, 102, 102, 60, 24, 0 db 204, 0, 204, 204, 204, 204, 120, 0 db 24, 24, 126, 192, 192, 126, 24, 24 db 56, 108, 100, 240, 96, 230, 252, 0 db 204, 204, 120, 48, 252, 48, 252, 48 db 248, 204, 204, 250, 198, 207, 198, 195 db 14, 27, 24, 60, 24, 24, 216, 112 db 28, 0, 120, 12, 124, 204, 118, 0 db 56, 0, 112, 48, 48, 48, 120, 0 db 0, 28, 0, 120, 204, 204, 120, 0 db 0, 28, 0, 204, 204, 204, 118, 0 db 0, 248, 0, 184, 204, 204, 204, 0 db 252, 0, 204, 236, 252, 220, 204, 0 db 60, 108, 108, 62, 0, 126, 0, 0 db 56, 108, 108, 56, 0, 124, 0, 0 db 24, 0, 24, 24, 48, 102, 60, 0 db 0, 0, 0, 252, 192, 192, 0, 0 db 0, 0, 0, 252, 12, 12, 0, 0 db 198, 204, 216, 54, 107, 194, 132, 15 db 195, 198, 204, 219, 55, 109, 207, 3 db 24, 0, 24, 24, 60, 60, 24, 0 db 0, 51, 102, 204, 102, 51, 0, 0 db 0, 204, 102, 51, 102, 204, 0, 0 db 34, 136, 34, 136, 34, 136, 34, 136 db 85, 170, 85, 170, 85, 170, 85, 170 db 219, 246, 219, 111, 219, 126, 215, 237 db 24, 24, 24, 24, 24, 24, 24, 24 db 24, 24, 24, 24, 248, 24, 24, 24 db 24, 24, 248, 24, 248, 24, 24, 24 db 54, 54, 54, 54, 246, 54, 54, 54 db 0, 0, 0, 0, 254, 54, 54, 54 db 0, 0, 248, 24, 248, 24, 24, 24 db 54, 54, 246, 6, 246, 54, 54, 54 db 54, 54, 54, 54, 54, 54, 54, 54 db 0, 0, 254, 6, 246, 54, 54, 54 db 54, 54, 246, 6, 254, 0, 0, 0 db 54, 54, 54, 54, 254, 0, 0, 0 db 24, 24, 248, 24, 248, 0, 0, 0 db 0, 0, 0, 0, 248, 24, 24, 24 db 24, 24, 24, 24, 31, 0, 0, 0 db 24, 24, 24, 24, 255, 0, 0, 0 db 0, 0, 0, 0, 255, 24, 24, 24 db 24, 24, 24, 24, 31, 24, 24, 24 db 0, 0, 0, 0, 255, 0, 0, 0 db 24, 24, 24, 24, 255, 24, 24, 24 db 24, 24, 31, 24, 31, 24, 24, 24 db 54, 54, 54, 54, 55, 54, 54, 54 db 54, 54, 55, 48, 63, 0, 0, 0 db 0, 0, 63, 48, 55, 54, 54, 54 db 54, 54, 247, 0, 255, 0, 0, 0 db 0, 0, 255, 0, 247, 54, 54, 54 db 54, 54, 55, 48, 55, 54, 54, 54 db 0, 0, 255, 0, 255, 0, 0, 0 db 54, 54, 247, 0, 247, 54, 54, 54 db 24, 24, 255, 0, 255, 0, 0, 0 db 54, 54, 54, 54, 255, 0, 0, 0 db 0, 0, 255, 0, 255, 24, 24, 24 db 0, 0, 0, 0, 255, 54, 54, 54 db 54, 54, 54, 54, 63, 0, 0, 0 db 24, 24, 31, 24, 31, 0, 0, 0 db 0, 0, 31, 24, 31, 24, 24, 24 db 0, 0, 0, 0, 63, 54, 54, 54 db 54, 54, 54, 54, 255, 54, 54, 54 db 24, 24, 255, 24, 255, 24, 24, 24 db 24, 24, 24, 24, 248, 0, 0, 0 db 0, 0, 0, 0, 31, 24, 24, 24 db 255, 255, 255, 255, 255, 255, 255, 255 db 0, 0, 0, 0, 255, 255, 255, 255 db 240, 240, 240, 240, 240, 240, 240, 240 db 15, 15, 15, 15, 15, 15, 15, 15 db 255, 255, 255, 255, 0, 0, 0, 0 db 0, 0, 118, 220, 200, 220, 118, 0 db 0, 120, 204, 248, 204, 248, 192, 192 db 0, 252, 204, 192, 192, 192, 192, 0 db 0, 0, 254, 108, 108, 108, 108, 0 db 252, 204, 96, 48, 96, 204, 252, 0 db 0, 0, 126, 216, 216, 216, 112, 0 db 0, 102, 102, 102, 102, 124, 96, 192 db 0, 118, 220, 24, 24, 24, 24, 0 db 252, 48, 120, 204, 204, 120, 48, 252 db 56, 108, 198, 254, 198, 108, 56, 0 db 56, 108, 198, 198, 108, 108, 238, 0 db 28, 48, 24, 124, 204, 204, 120, 0 db 0, 0, 126, 219, 219, 126, 0, 0 db 6, 12, 126, 219, 219, 126, 96, 192 db 56, 96, 192, 248, 192, 96, 56, 0 db 120, 204, 204, 204, 204, 204, 204, 0 db 0, 126, 0, 126, 0, 126, 0, 0 db 24, 24, 126, 24, 24, 0, 126, 0 db 96, 48, 24, 48, 96, 0, 252, 0 db 24, 48, 96, 48, 24, 0, 252, 0 db 14, 27, 27, 24, 24, 24, 24, 24 db 24, 24, 24, 24, 24, 216, 216, 112 db 24, 24, 0, 126, 0, 24, 24, 0 db 0, 118, 220, 0, 118, 220, 0, 0 db 56, 108, 108, 56, 0, 0, 0, 0 db 0, 0, 0, 24, 24, 0, 0, 0 db 0, 0, 0, 0, 24, 0, 0, 0 db 15, 12, 12, 12, 236, 108, 60, 28 db 88, 108, 108, 108, 108, 0, 0, 0 db 112, 152, 48, 96, 248, 0, 0, 0 db 0, 0, 60, 60, 60, 60, 0, 0 db 0, 0, 0, 0, 0, 0, 0, 0 \ No newline at end of file diff --git a/LIB386/LIB_SVGA/FONT_A.ASM b/LIB386/LIB_SVGA/FONT_A.ASM new file mode 100644 index 0000000..c8194bd --- /dev/null +++ b/LIB386/LIB_SVGA/FONT_A.ASM @@ -0,0 +1,216 @@ +;---------------------------------------------------------------------------- +; +;' Text_A.ASM 386 +;' (c) Adeline 1994 +;' +; +;---------------------------------------------------------------------------- + .386P + jumps + .model SMALL, SYSCALL +;---------------------------------------------------------------------------- + .data +;---------------------------------------------------------------------------- + include \projet\lib386\lib_svga\svga.ash + +ALIGN 4 + +PtrFont dd 0 +DxFont dd ? + +InterLeave dd 1 +InterSpace dd 10 + +;---------------------------------------------------------------------------- + .code + + public NoLanguage CoulFont + public NoLanguage SetFont + public NoLanguage SizeFont + public NoLanguage CarFont + public NoLanguage Font + + extrn NoLanguage CoulMask :PROC + extrn NoLanguage AffMask_Asm :PROC + +;---------------------------------------------------------------------------- +;' +CoulFont proc ,\ + coul:DWORD + + movzx eax, byte ptr [coul] + push eax + Call CoulMask + add esp, 4 + ret + +CoulFont endp +;---------------------------------------------------------------------------- +;' +SetFont proc ,\ + ptfont:DWORD, inle:DWORD, insp:DWORD + + mov eax, ptfont + mov [PtrFont], eax + + mov eax, inle + mov [InterLeave], eax + + mov eax, insp + mov [InterSpace], eax + + ret + +SetFont endp +;---------------------------------------------------------------------------- +;' +SizeFont proc uses esi edi ,\ + chaine:DWORD + + mov esi, [chaine] + mov edi, [PtrFont] + xor eax, eax + xor edx, edx + mov [DxFont], eax +;' -------------------------------- +NextCar: + lodsb + + or al, al + je short EndSizeFont + + cmp al, 32 + jne PlusLoin0 + + mov edx, [InterSpace] + add [DxFont], edx + jmp short NextCar + +PlusLoin0: + mov edi, [PtrFont] + add edi, [edi+eax*4] + + + mov edx, [InterLeave] + add [DxFont], edx + + mov dl, byte ptr[edi] + + add [DxFont], edx + + jmp short NextCar +;' -------------------------------- +EndSizeFont: + mov eax, [DxFont] + ret +SizeFont endp +;---------------------------------------------------------------------------- +CarFont proc uses esi edi ebx ebp,\ + xcar:DWORD, ycar:DWORD, car:DWORD + + mov eax, car + cmp eax, 32 ;' SPACE + je Space + + mov ebx, xcar + mov ecx, ycar + mov esi, [PtrFont] + + mov edi, [PtrFont] + add edi, [edi+eax*4] + + xor edx, edx + mov dl, [edi+0] + add edx, [InterLeave] + + push edx + + Call AffMask_Asm + + pop eax + + ret +Space: + mov eax, [InterSpace] + ret + +CarFont endp +;---------------------------------------------------------------------------- +;' +Font proc uses esi edi ebx ebp,\ + xfont:DWORD, yfont:DWORD,chaine:DWORD + + cmp dword ptr [PtrFont], 0 + je short EndFont + +;' -------------------------------- + + mov esi, [chaine] + mov edi, [PtrFont] + mov ebx, [xfont] + mov ecx, [yfont] + xor eax, eax + + jmp NextCar + +;' -------------------------------- +Space: + add ebx, [InterSpace] +NextCar: + xor eax, eax + lodsb + + or al, al + je short EndFont + + cmp al, 32 + je Space + +PasSpace: mov edi, [PtrFont] + add edi, [edi+eax*4] + + xor edx, edx + mov dl, byte ptr[edi] + mov [DxFont], edx + + push esi + push ebx + push ecx + mov esi, [PtrFont] + + Call AffMask_Asm + + pop ecx + pop ebx + pop esi + + add ebx, [InterLeave] + add ebx, [DxFont] + + jmp short NextCar +;' -------------------------------- +EndFont: + ret +Font endp +;---------------------------------------------------------------------------- +; The + End + + + + + + + + + + + + + + + + + + + diff --git a/LIB386/LIB_SVGA/GIF.C b/LIB386/LIB_SVGA/GIF.C new file mode 100644 index 0000000..d797815 --- /dev/null +++ b/LIB386/LIB_SVGA/GIF.C @@ -0,0 +1,401 @@ +/* + ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» + º º + º GIF = PROGRAM TO READ .GIF GRAPHICS FILES º + º º + º GIF and 'Graphics Interchange Format' are trademarks (tm) of º + º Compuserve, Incorporated, an H&R Block Company º + º º + º By Roger T. Stevens 12-9-91 º + º º + ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ +*/ + +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_svga\lib_svga.h" + +#include +#include +#include +#include +#include +#include +#include + +/* +struct ffblk { + char ff_reserved[21]; + char ff_attrib; + unsigned ff_ftime; + unsigned ff_fdate; + long ff_fsize; + char ff_name[13]; +}; +*/ + +#define UP_ARROW 328 +#define DOWN_ARROW 336 +#define LEFT_ARROW 331 +#define RIGHT_ARROW 333 +#define BACKSPACE 8 + +void decoder(LONG fd, WORD linewidth); +WORD next_code(LONG fd); + +//union REGS reg; + +struct +{ + char name[3] ; + char version[3] ; + short int xres ; + short int yres ; + unsigned short int packed; + char back_col_index ; + char aspect_ratio ; +} gif_header; + +struct +{ + char red; + char green; + char blue; +} color_table[256], loc_color_table[256]; + +struct +{ + short int start_col ; + short int start_row ; + short int width ; + short int height ; + char packed ; +} image_descriptor; + +char ch, col_tab_flag, interlace_flag ; + +/* +buffer[64], +color_flag, +color_res, +dirbuf[64][13], +filename[32], +loc_sort_flag, +sort_flag; +*/ + +unsigned char bytes = 0, b1, display_line[640/*2049*/], file_buf[512] ; + +//unsigned char last[4096], stack[4096] ; +unsigned char *last, *stack ; + +// unsigned char PALETTE[17]={0,1,2,3,4,5,20,7,56,57,58,59,60,61,62,63,0}; + +short int bits_left = 0, code_size, clear, col_tab_size, + linewidth, loc_col_tab_size, + newcodes, rows, + slot, top ; + +extern short int i, end, index ; +/* +mode, +disp_height, +active_page = 0, +column, +dir_index= 0, +done, +end, +i,index = 0, +j, k, +key, +xres; +*/ + +short unsigned int height, width ; + +//short unsigned int link[4096] ; +short unsigned int *link ; + +//FILE *fin ; +//struct ffblk ffblk ; + +UBYTE *PtBuff ; +extern UBYTE *PtDest; + +/*--------------------------------------------------------------------------*/ +void line_out_gif( char *pt, WORD size ) +{ + WORD i ; + UBYTE *pts ; + + pts = pt ; + + PtDest = PtBuff + (rows*640) ; + + for ( i = 0 ; i < size ; i++ ) *PtDest++ = *pts++ ; + + rows++ ; +/* + Box( 0, 0, 160, 7, 0 ) ; + Text( 0, 0, "Ligne:%d", rows ) ; + CopyBlockPhys( 0, 0, 160, 7 ) ; +*/ +} +/*--------------------------------------------------------------------------*/ +// fd pointe deja sur le debut du gif sur disk +// Faire le Close a plus haut niveau ! + +void Read_Gif( LONG fd, UBYTE *screen, UBYTE *tabcol, UBYTE *buffers ) +{ + char color ; + char dummy ; + short int finished ; + + PtBuff = PtDest = screen ; + + // buffers doit faire au moins 16K + + last = buffers ; // 4096 + stack = buffers + 4096 ; // 4096 + link = buffers + 8192 ; // 8192 + + Read( fd, &gif_header, 13L ) ; + +// color_flag = (gif_header.packed & 0x80) >> 7 ; +// color_res = (gif_header.packed & 0x70) >> 4 ; +// sort_flag = (gif_header.packed & 0x08) >> 3 ; + +// col_tab_size = (WORD)pow(2,(gif_header.packed & 0x07)+1.0); + + col_tab_size = (WORD)(2<<(gif_header.packed & 0x07)) ; + + if (col_tab_size > 0) + Read( fd, tabcol, col_tab_size *3L ) ; +/* Si image en 16 couleurs + for ( i = 0 ; i < 16 ; i++ ) + { + PALETTE[i] = ((color_table[i].red & 0x40) >> 1) | + ((color_table[i].red & 0x80) >> 5) | + ((color_table[i].green & 0x40) >> 2) | + (color_table[i].green & 0x80) >> 6 | + ((color_table[i].blue & 0x40) >> 3) | + ((color_table[i].blue & 0x80) >> 7) ; + } +*/ +/* Decalage en library automatique + for ( i = 0 ; i < 256 ; i++ ) + { + color_table[i].red >>= 2 ; + color_table[i].green >>= 2 ; + color_table[i].blue >>= 2 ; + } +*/ + + rows = 0 ; + finished = 0 ; + + while ( !finished ) + { + Read( fd, &ch, 1L ) ; + + switch ( ch ) + { + case ';': /*End of .GIF data */ + finished = 1 ; + break ; + + case '!': /* .GIF extension block - read and discard */ + + Read( fd, &dummy, 1L ) ; + Read( fd, &i, 2L ) ; + Read( fd, file_buf, (LONG)i ) ; + break ; + + case ',': /* read image description */ + + Read( fd, &image_descriptor, 9L ) ; + width = image_descriptor.width ; + linewidth = min(640,width) ; + height = image_descriptor.height ; + col_tab_flag = (image_descriptor.packed & 0x80) >> 7 ; +// interlace_flag = (image_descriptor.packed & 0x40) >> 6 ; +// loc_sort_flag = (image_descriptor.packed & 0x20) >> 5 ; + loc_col_tab_size = (WORD)pow(2,(image_descriptor.packed + & 0x07) + 1.0); + + if (col_tab_flag == 1) + Read( fd,loc_color_table, loc_col_tab_size * 3L ); + + decoder( fd, width ) ; + break ; + default: + finished = 1 ; + break ; + } + } +} +/*--------------------------------------------------------------------------*/ +/* +ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» +º º +º restore_screen() = Reads and displays a file º +º º +ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ +*/ + +void Load_Gif(char *filename, UBYTE *screen, UBYTE *tabcol) +{ + LONG fd ; + UBYTE *buffers ; + + fd = OpenRead( filename ) ; + + buffers = Malloc( 16384 ) ; + + Read_Gif( fd, screen, tabcol, buffers ) ; + + Free( buffers ) ; + + Close(fd) ; +} +/*--------------------------------------------------------------------------*/ +/* + ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» + º º + º decoder() = .GIF file decode º + º º + ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ +*/ + +void decoder( LONG fd, WORD width ) +{ + short int code, fc=0, old_code=0, counter; + short int ch, size=0, ret ; + short int s_index=0 ; + short int l_index=0 ; + + + Read( fd, &size, 1L ) ; + code_size = size + 1 ; + top = 1 << code_size ; + clear = 1 << size ; + end = clear + 1 ; + + slot = newcodes = end + 1; + counter = width ; + bits_left = 0 ; + b1 = 0 ; + bytes = 0 ; + + while ((ch = next_code(fd)) != end) + { + if (ch == clear) + { + code_size = size + 1 ; + slot = newcodes ; + top = 1 << code_size ; + ch = next_code(fd) ; + old_code = fc = ch ; + display_line[l_index++] = ch; + counter-- ; + } + else + { + code = ch ; + if ( code >= slot ) + { + code = old_code ; + stack[s_index++] = fc ; + } + while ( code >= newcodes ) + { + stack[s_index++] = last[code] ; + code = link[code] ; + } + stack[s_index++] = code ; + if ( slot < top ) + { + fc = code ; + last[slot] = code ; + link[slot++] = old_code ; + old_code = ch ; + } + if ( slot >= top ) + if ( code_size < 12 ) + { + top <<= 1 ; + ++code_size ; + } + while ( s_index > 0 ) + { + display_line[l_index++] = stack[--s_index] ; + if ( --counter == 0 ) + { + line_out_gif( display_line, linewidth ) ; + if ( rows >= height ) + return ; + + l_index = 0 ; + counter = width ; + } + } + } + } + if ( counter != linewidth ) + line_out_gif( display_line, linewidth-counter ); +} + +/*--------------------------------------------------------------------------*/ +/* + ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» + º º + º next_code(fd) = reads next code from file º + º º + ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ + + ULONG code + UBYTE b1 + UBYTE bytes + WORD bits_left +*/ + +WORD next_code( LONG fd ) +{ + short int flag=0 ; + unsigned long int code ; + + if ( bits_left == 0 ) flag = 1; /* BUG */ + + code = (b1 >> (8 - bits_left)) ; + + while ( code_size > bits_left ) + { + if ( bytes <= 0 ) + { + index = 0 ; + Read( fd, &bytes, 1L ) ; + Read( fd, file_buf, (LONG)bytes ); + } + + b1 = file_buf[index++] ; + + if (flag == 1) + { + /* code = (b1 >> (8 - bits_left)) ; SUPER BUG*/ + code = b1 ; + flag = 0 ; /* BUG */ + } + else code |= (b1 << bits_left); + + bits_left += 8 ; + --bytes ; + } + + bits_left -= code_size ; + + code &= ( 0xFFF >> (12 - code_size)) ; + + return((WORD)(code)) ; +} +/*--------------------------------------------------------------------------*/ + diff --git a/LIB386/LIB_SVGA/GRAPHMSK.ASM b/LIB386/LIB_SVGA/GRAPHMSK.ASM new file mode 100644 index 0000000..dc404aa --- /dev/null +++ b/LIB386/LIB_SVGA/GRAPHMSK.ASM @@ -0,0 +1,154 @@ +;---------------------------------------------------------------------------- +; GraphMsk.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386P + jumps + .model SMALL, SYSCALL +;---------------------------------------------------------------------------- + .data +;---------------------------------------------------------------------------- + include \projet\lib386\lib_svga\svga.ash + +comment @ + DWORD TabOffset[] + Brick: + - BYTE Delta X + - BYTE Delta Y + Line(Delta Y): + - BYTE NbBlock + Block: + - 00xxxxxxb xxxxxx zeros to jump + - 01xxxxxxb xxxxxx Copy Pix + - 10xxxxxxb xxxxxx Repeat Pix + - BYTE datas[] +@ + +;---------------------------------------------------------------------------- + .code + + public NoLanguage CalcGraphMsk + +;---------------------------------------------------------------------------- +CalcGraphMsk proc uses esi edi ebx ebp,\ + numbrick:DWORD, bankbrick:DWORD, ptmask:DWORD + + mov eax, numbrick + mov esi, bankbrick + mov edi, ptmask + push edi + add esi, [esi+eax*4]; ESI = Begin Data + +;----------------------------------------------- + xor edx, edx + mov ebx, [esi] ; Get DX, DY, Hot X, Hot Y + mov [edi], ebx ; Stock DX, DY, Hot X, Hot Y + add esi, 4 ; bh = NbLine + add edi, 4 +;----------------------------------------------- + xor ecx, ecx ; Maz Compteur +;----------------------------------------------- Init NbBlock for this line +NextLine: xor dl, dl ; NbBlockDst = 0 + xor ah, ah ; NbData = 0 + mov ebp, edi ; Sauve Pos NbBlockDst + inc edi ; Jump NbBlockDst + mov bl, [esi] ; BL = Nb Block for this line + inc esi + test byte ptr [esi], 11000000b; Jump Zero ? + je SameLine ; Line MUST Begin JumpZero +;----------------------------------------------- Premier Block En Jump Zero + mov byte ptr[edi], 0 + inc edi + inc dl ; NbBlockDst++ +;----------------------------------------------- Manage One Line +SameLine: mov al, [esi] + inc esi ; OpCode + mov cl, al ; Sauve AL + and cl, 00111111b ; AH = Bit 0-5 + inc cl ; One More Please... +;----------------------- + test al, 10000000b + jne RepeatCol + test al, 01000000b + jne CopyCol +;----------------------------------------------- 00 Jump CL Zero + or ah, ah ; NbData + je RienEnCours +;----------------------- + mov [edi], ah + inc edi + inc dl ; NbBlockDst++ + xor ah, ah ; NbData=0 +RienEnCours: mov [edi], cl + inc edi + inc dl ; NbBlockDst++ + jmp EndLoop +;----------------------------------------------- 01 Repeat Nb Col +RepeatCol: add ah, cl ; NbData += Nb + inc esi ; pts++ + jmp EndLoop +;----------------------------------------------- 10 Copy Nb Col +CopyCol: add ah, cl ; NbData += Nb + add esi, ecx ; pts += nb +;----------------------------------------------- End Loop +EndLoop: dec bl ; Nb Block-- + jne SameLine ; Continue Same Line +;----------------------------------------------- Cloture Eventuelle + or ah, ah ; NbData + je PasDeCloture +;----------------------- + mov [edi], ah + inc edi + inc dl ; NbBlockDst++ +;----------------------- +PasDeCloture: mov ds:[ebp], dl ; Write NbBlockDst + dec bh ; NbLine-- + jne NextLine ; Next Line +;----------------------- + mov eax, edi + pop edi + sub eax, edi ; Size Mask + ret +;---------------------- +CalcGraphMsk endp +;---------------------------------------------------------------------------- +; The + End + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LIB386/LIB_SVGA/GRAPH_A.ASM b/LIB386/LIB_SVGA/GRAPH_A.ASM new file mode 100644 index 0000000..4e90e1c --- /dev/null +++ b/LIB386/LIB_SVGA/GRAPH_A.ASM @@ -0,0 +1,358 @@ +;---------------------------------------------------------------------------- +; Graph_A.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386P + jumps + .model SMALL, SYSCALL +;---------------------------------------------------------------------------- + .data +;---------------------------------------------------------------------------- + include \projet\lib386\lib_svga\svga.ash + + +FULL_OPTIMIZE equ 1 + +comment @ + DWORD TabOffset[] + Brick: + - BYTE Delta X + - BYTE Delta Y + Line(Delta Y): + - BYTE NbBlock + Block: + - 00xxxxxxb xxxxxx zeros to jump + - 01xxxxxxb xxxxxx Copy Pix + - 10xxxxxxb xxxxxx Repeat Pix + - BYTE datas[] +@ + +ALIGN 4 + +OffsetBegin dd 0 +NbPix dd 0 +BufferClip db 512 dup(?) + +;---------------------------------------------------------------------------- + .code + + public NoLanguage AffGraph + public NoLanguage GetDxDyGraph + +;---------------------------------------------------------------------------- +AffGraph proc uses esi edi ebx ebp,\ + numbrick:DWORD, xbrick:DWORD, ybrick:DWORD, \ + bankbrick:DWORD + + mov eax, numbrick + mov ebx, xbrick + mov ecx, ybrick + mov esi, bankbrick + + add esi, [esi+eax*4] ; ESI = Begin Data + + xor eax, eax + xor edx, edx + + mov al, byte ptr[esi+2] ; Hot X + add ebx, eax + mov al, byte ptr[esi+3] ; Hot Y + add ecx, eax + mov dl, [esi] ; Delta X + mov al, [esi+1] ; Nb Line ( Delta Y ) + add esi, 4 ; Jump Hot X & Hot Y + +;----------------------------------------------- Test Clipping + + add edx, ebx + add eax, ecx + dec edx + dec eax + + cmp ebx, ClipXmin + jl ClippingGraph + cmp ecx, ClipYmin + jl ClippingGraph + cmp edx, ClipXmax + jg ClippingGraph + cmp eax, ClipYmax + jg ClippingGraph + + inc edx + inc eax + sub edx, ebx + sub eax, ecx + + +;----------------------------------------------- Calcul Offset Ecran + + mov edi, Log + add edi, TabOffLine[ecx*4] + add edi, ebx + mov bh, al ; BH = NbLine + sub edx, Screen_X ; EDX = Offset Screen + neg edx ; EDX = Screen_X-edx + xor ecx, ecx ; Maz Compteur + +;----------------------------------------------- Init NbBlock for this line + +NextLine: mov bl, [esi] ; BL = Nb Block for this line + inc esi + +;----------------------------------------------- Manage One Line + +SameLine: mov al, [esi] ; OpCode + mov cl, al ; Sauve AL + and cl, 00111111b ; AH = Bit 0-5 + test al, 11000000b ; AL = Bit 6-7 + je JumpZero ; Incrust + inc cl ; One More Please... + test al, 01000000b ; AL = 01b + jne WriteDiffPix ; Pix Differents + +;----------------------------------------------- Repeat Same Color + + mov al, [esi+1] ; Color to Repeat + add esi, 2 + shr ecx, 1 + mov ah, al + rep stosw ; Fill + jnc nobytec + mov [edi], al + inc edi +nobytec: dec bl ; Nb Block-- + jne SameLine ; Continue Same Line + add edi, edx ; EDI += Offset Screen + dec bh ; NbLine-- + jne NextLine ; Next Line + ret + +;----------------------------------------------- Copy Diff Pix + +WriteDiffPix: inc esi + shr ecx, 1 + rep movsw ; Copy Pix + jnc nobyted + mov al, [esi] + mov [edi], al + inc esi + inc edi +nobyted: dec bl ; Nb Block-- + jne SameLine ; Continue Same Line + add edi, edx ; EDI += Offset Screen + dec bh ; NbLine-- + jne NextLine ; Next Line + ret + +;----------------------------------------------- Incrust + +JumpZero: inc esi + lea edi, [edi+ecx+1]; Jump Zero (incrust) + dec bl ; Nb Block-- + jne SameLine ; Continue Same Line + add edi, edx ; EDI += Offset Screen + dec bh ; NbLine-- + jne NextLine ; Next Line + ret + +;-------------------------------------------------------------------- Clipping +; Graph : ( EBX, ECX ) ( EDX, EAX ) +ClippingGraph: + cmp ebx, ClipXmax + jg EndGraph + cmp ecx, ClipYmax + jg EndGraph + cmp edx, ClipXmin + jl EndGraph + cmp eax, ClipYmin + jl EndGraph + cmp ecx, ClipYmin + jge PasHaut + +;---------------------- Clipping Haut, Saute ClipYmin-ECX Line(s) + + mov ebp, eax + mov edi, ebx + + mov ebx, ClipYmin + sub ebx, ecx + +NextH: mov bh, [esi] + inc esi +SameH: mov al, [esi] + inc esi + test al, 11000000b + je JumpzH + xor ecx, ecx + test al, 01000000b + je AquiH + and eax, 00111111b + mov ecx, eax +AquiH: lea esi, [esi+ecx+1] +JumpzH: dec bh + jne SameH + dec bl + jne NextH + + mov ecx, ClipYmin ; New Y Haut + + mov eax, ebp + mov ebx, edi + +;---------------------- Clipping Bas +PasHaut: cmp eax, ClipYmax + jle PasBas + mov eax, ClipYmax +;---------------------- Clipping Gauche +Pasbas: xor edi, edi + cmp ebx, ClipXmin + jge PasGauche + mov edi, ClipXmin + sub edi, ebx +PasGauche: mov OffsetBegin, edi +;---------------------- Clipping Droit + lea edi, [edi+ebx-1] + sub edi, edx + neg edi + mov NbPix, edi + + sub edx, ClipXmax + jle PasDroit + sub NbPix, edx +;---------------------- +PasDroit: + + mov edi, Log + add edi, TabOffLine[ecx*4] + add edi, ebx + + + sub eax, ecx + inc al + mov bh, al ; BH NbLine + xor ecx, ecx + mov edx, edi +;---------------------------------------------- + ; ESI = DATAS LINE +NextL: lea edi, BufferClip ; EDI = BUFFERCLIP + mov bl, [esi] + inc esi +SameL: mov al, [esi] + inc esi + mov cl, al + and cl, 00111111b + inc cl + test al, 11000000b + je JumpL + test al, 01000000b + jne WriteDiffL +;---------------------- + mov al, [esi] + inc esi + shr ecx, 1 + mov ah, al + rep stosw + jnc nobyte + mov [edi], al + inc edi + dec bl + jne SameL + jmp NextLine2 +;---------------------- +JumpL: xor ax, ax + shr ecx, 1 + rep stosw + jnc nobyte + mov [edi], al + inc edi + dec bl + jne SameL + jmp NextLine2 +;---------------------- +WriteDiffL: shr ecx, 1 + rep movsw + jnc nobyte + mov al, [esi] + mov [edi], al + inc esi + inc edi +nobyte: dec bl + jne SameL +;---------------------- +NextLine2: mov ebp, esi ; SAVE ESI + mov ecx, OffsetBegin + lea esi, [BufferClip+ecx] ; ESI = BUFFERCLIP + lea edi, [edx+ecx] ; EDI = SCREEN + mov ecx, NbPix +Again: mov al, [esi] + inc esi + or al, al + je Incrust + mov [edi], al +Incrust: inc edi + dec ecx + jnz Again + add edx, 640 + mov esi, ebp + dec bh + jne NextL +;---------------------- +EndGraph: ret +AffGraph endp +;---------------------------------------------------------------------------- +GetDxDyGraph proc uses esi edi ebx,\ + num:DWORD, ptdx:DWORD, ptdy:DWORD, bankgraph:DWORD + + mov esi, bankgraph + mov eax, num + add esi, [esi+eax*4] + mov edi, ptdx + xor eax, eax + mov al, [esi] + mov dword ptr[edi], eax + mov edi, ptdy + mov al, [esi+1] + mov dword ptr[edi], eax + ret +GetDxDyGraph endp +;---------------------------------------------------------------------------- +; The + End + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LIB386/LIB_SVGA/INITMODE.C b/LIB386/LIB_SVGA/INITMODE.C new file mode 100644 index 0000000..beec88d --- /dev/null +++ b/LIB386/LIB_SVGA/INITMODE.C @@ -0,0 +1,50 @@ + +/*--------------------------------------------------------------------------*/ +/* INITGRAFSVGA 386 */ +/* (c) Adeline 1993 */ +/*--------------------------------------------------------------------------*/ + +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" + +#include "\projet\lib386\lib_svga\lib_svga.h" + +#include +#include +#include +#include + +/*--------------------------------------------------------------------------*/ +void InitGraphSvga() +{ + InitSvga(); + + Log = Malloc(640L*480L); /* 307200L */ + MemoLog = Log; +} + +/*--------------------------------------------------------------------------*/ +void ClearGraphSvga() +{ + Free(MemoLog) ; + ClearVideo() ; +} + +/*--------------------------------------------------------------------------*/ +void InitGraphMcga() +{ + InitMcga(); + + Log = Malloc(320L*200L); /* 64000L */ + MemoLog = Log; +} + +/*--------------------------------------------------------------------------*/ +void ClearGraphMcga() +{ + Free(MemoLog) ; + ClearVideo() ; +} + +/*--------------------------------------------------------------------------*/ + diff --git a/LIB386/LIB_SVGA/INITSVGA.ASM b/LIB386/LIB_SVGA/INITSVGA.ASM new file mode 100644 index 0000000..a89036b --- /dev/null +++ b/LIB386/LIB_SVGA/INITSVGA.ASM @@ -0,0 +1,317 @@ +;---------------------------------------------------------------------------- +; INITSVGA.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386p + jumps + .model FLAT, SYSCALL + +;---------------------------------------------------------------------------- + .data + + include vesa.ash + + public NoLanguage Log + public NoLanguage Phys + public NoLanguage Text_Ink + public NoLanguage Text_Paper + public NoLanguage Screen_X + public NoLanguage Screen_Y + public NoLanguage MemoLog + public NoLanguage ClipXmin + public NoLanguage ClipYmin + public NoLanguage ClipXmax + public NoLanguage ClipYmax + public NoLanguage TabOffLine + public NoLanguage OldVideo + public NoLanguage SizeCar + public NoLanguage BankChange + public NoLanguage BankCurrent + + public NoLanguage InitSvgaMode + public NoLanguage NewBank + public NoLanguage Enable + + +ClipXmin dd 0 +ClipYmin dd 0 +ClipXmax dd 639 +ClipYmax dd 479 + +MemoClipXmin dd 0 +MemoClipYmin dd 0 +MemoClipXmax dd 639 +MemoClipYmax dd 479 + +TabOffLine dd 480 dup(?) ; LONG et non pas WORD comme MCGA + +TabOffPhysLine dd 480 dup(?) ; LONG et non pas WORD comme MCGA + +OldVideo db -1 + +Text_Ink db 15 +Text_Paper db -1 + db 0 + +Screen_X dd 640 +Screen_Y dd 480 +SizeCar dw 8 ; 6 old affstring + + ALIGN 2 + +Save_1 dd ? + +Log dd 0 +Phys dd 0A0000h +MemoLog dd 0 +BankChange dd ? +BankCurrent dd ? + +InitSvgaMode dd offset InitModeVesa +NewBank dd offset NewBankVesa +Enable dd 0 + +;---------------------------------------------------------------------------- + .code + + InitModeVesa PROTO + NewBankVesa PROTO + + extrn NoLanguage ScanLine:DWORD + + public NoLanguage InitSvga + public NoLanguage InitMcga + public NoLanguage InitMcgaMode + public NoLanguage SimpleInitSvga + public NoLanguage ClearVideo + + public NoLanguage SetClip + public NoLanguage UnSetClip + public NoLanguage MemoClip + public NoLanguage RestoreClip + + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÛßßß Ûßßßß ÛßßßÛ Ûßßßß Ûßßßß ÛÛÜ Û ÛÜ ÜÛ ÛßßßÛ ÛßßßÜ Ûßßßß +; ßßßßÛ ÛÛ ÛÛßÛß ÛÛßß ÛÛßß ÛÛßÛÛ ÛÛß Û ÛÛ Û ÛÛ Û ÛÛßß +; ßßßßß ßßßßß ßß ß ßßßßß ßßßßß ßß ß ßßßßß ßß ß ßßßßß ßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;---------------------------------------------------------------------------- +InitSvga proc + +;---------------------- Save regs + + pushad + +;---------------------- memo video mode + + mov ah, 0Fh + int 10h + mov [OldVideo], al + +;---------------------- Video Mode + + mov edx, [InitSvgaMode] + or edx, edx + jnz ok + + mov edx, offset InitModeVESA + mov [InitSvgaMode], edx +ok: + mov eax, offset ScanLine + call edx + + mov edx, [Enable] + or edx, edx + jz skip + + call edx +skip: + +;---------------------- Restore regs + + popad + +;---------------------- Table Offset Line + + mov ecx, Screen_Y + xor eax, eax + mov edx, eax +Again: + mov TabOffLine[edx*4], eax + inc edx + add eax, Screen_X + dec ecx + jnz Again + + mov dword ptr[BankCurrent], -1 + + ret + +InitSvga endp + +;---------------------------------------------------------------------------- + +SimpleInitSvga proc uses ebx + + call [InitSvgaMode] + + mov eax, [Enable] + or eax, eax + jz skip + + call eax +skip: + mov dword ptr[BankCurrent], -1 + + ret + +SimpleInitSvga endp + +;---------------------------------------------------------------------------- +ClearSvga proc + + xor ax, ax + mov al, OldVideo + int 10h + ret + +ClearSvga endp + + +;---------------------------------------------------------------------------- +InitMcgaMode proc uses esi edi + + mov ax, 13h + int 10h + ret + +InitMcgaMode endp + +;---------------------------------------------------------------------------- +InitMcga proc + +;---------------------- Save regs + + pushad + +;---------------------- memo video mode + + mov ah, 0Fh + int 10h + mov [OldVideo], al + +;---------------------- Video Mode + + call InitMcgaMode + +;---------------------- Restore regs + + popad + + ret + +InitMcga endp + +;---------------------------------------------------------------------------- +ClearVideo proc + + xor ax, ax + mov al, OldVideo + int 10h + ret + +ClearVideo endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Ûßßßß Û Û ÛßßßÛ ÛßßßÛ Û ÛÛÜ Û Ûßßßß +; ÛÛ ÛÛ ÛÛ ÛÛßßß ÛÛßßß ÛÛ ÛÛßÛÛ ÛÛ ßÛ +; ßßßßß ßßßßß ßß ßß ßß ßß ßß ß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +SetClip proc ,\ + x0:DWORD, y0:DWORD, x1:DWORD, y1:DWORD + + mov eax, x0 + cmp eax, 0 + jge OkLeft + xor eax, eax +OkLeft: mov ClipXmin, eax + + mov eax, y0 + cmp eax, 0 + jge OkUp + xor eax, eax +OkUp: mov ClipYmin, eax + + mov eax, x1 + cmp eax, Screen_X + jl OkRight + mov eax, Screen_X + dec eax +OkRight: mov ClipXmax, eax + + mov eax, y1 + cmp eax, Screen_Y + jl OkDown + mov eax, Screen_Y + dec eax +OkDown: mov ClipYmax, eax + + ret +SetClip endp +;---------------------------------------------------------------------------- +UnSetClip proc + + xor eax, eax + mov ClipXmin, eax + mov ClipYmin, eax + + mov eax, Screen_X + dec eax + mov ClipXmax, eax + + mov eax, Screen_Y + dec eax + mov ClipYmax, eax + + ret + +UnSetClip endp +;---------------------------------------------------------------------------- +MemoClip proc + + mov eax,ClipXmin + mov MemoClipXmin, eax + mov eax,ClipYmin + mov MemoClipYmin, eax + mov eax,ClipXmax + mov MemoClipXmax, eax + mov eax,ClipYmax + mov MemoClipYmax, eax + + ret + +MemoClip endp +;---------------------------------------------------------------------------- +RestoreClip proc + + mov eax,MemoClipXmin + mov ClipXmin, eax + mov eax,MemoClipYmin + mov ClipYmin, eax + mov eax,MemoClipXmax + mov ClipXmax, eax + mov eax,MemoClipYmax + mov ClipYmax, eax + + ret + +RestoreClip endp + +;---------------------------------------------------------------------------- +; The + End diff --git a/LIB386/LIB_SVGA/LBM.C b/LIB386/LIB_SVGA/LBM.C new file mode 100644 index 0000000..1cb80df --- /dev/null +++ b/LIB386/LIB_SVGA/LBM.C @@ -0,0 +1,340 @@ +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_svga\lib_svga.h" + +#include +#include +#include + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û ÛßßÛ ÛÜ ÜÛ + ÛÛ ÛÛßßÛ ÛÛß Û + ßßßßß ßßßßß ßß ß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#define MAXBUFLIGNE 1500 +#define RowByte(w) ((((w)+15)>>4) << 1) + +UWORD Larg ; + +WORD Lbm_Width = 640 ; + +#define BUFLIGNEMAX 720 + +static WORD Handle ; +static ULONG rejet ; +static ULONG len ; +static BYTE head[] = "BMHD" ; +static WORD larg,haut ; +static BYTE nbr_plan ; +static BYTE flgcomp ; /* flg de compression */ +static BYTE Masking ; +//static BYTE bufflig[BUFLIGNEMAX] ; + +static UBYTE tabmsk[8] = { 0x01,0x02,0x04,0x08, + 0x10,0x20,0x40,0x80 } ; + +static LONG CptIff ; +static UBYTE *PtrIff ; +static UBYTE *BufferIff ; + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +UBYTE ReadIff() +{ + if( CptIff == 0 ) + { + Read( Handle, BufferIff, 64000L ) ; + CptIff = 64000L ; + PtrIff =(void *)BufferIff ; + } + CptIff-- ; + return *PtrIff++ ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void WriteIff( void *ptrin, ULONG len ) +{ + Write( Handle, ptrin, len ); +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void WriteIffLong( ULONG data ) +{ + WriteIff( (void*)&((UBYTE*)&data)[3], 1L ); + WriteIff( (void*)&((UBYTE*)&data)[2], 1L ); + WriteIff( (void*)&((UBYTE*)&data)[1], 1L ); + WriteIff( (void*)&((UBYTE*)&data)[0], 1L ); +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void itoml( void *l ) +{ + UBYTE c ; + UBYTE *ptc ; + + ptc = (char*)l ; + c = ptc[0] ; + ptc[0] = ptc[3] ; + ptc[3] = c ; + c = ptc[1] ; + ptc[1] = ptc[2] ; + ptc[2] = c ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void lit_bmhd() +{ + UBYTE a,b ; + + Read( Handle, &a, 1L ) ; + Read( Handle, &b, 1L ) ; + larg = ((unsigned int)a)*256 + b ; + + Read( Handle, &a, 1L ) ; + Read( Handle, &b, 1L ) ; + haut = ((unsigned int)a)*256 + b ; + + Read( Handle, &len, 4L ) ; /* lit 4 octets */ + Read( Handle, &nbr_plan, 1L ); + Read( Handle, &Masking, 1L ) ; + Read( Handle, &flgcomp, 1L ); + Read( Handle, &a, 1L ) ; /* pad */ + Read( Handle, &rejet, 4L ) ; + Read( Handle, &rejet, 4L ) ; + Larg = larg; + if( larg>320 ) larg = 320; + if( haut>200 ) haut = 200; + Masking &= 1; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void lit_bloc() /* on a un bloc inconnu */ +{ + WORD l ; + + for(l = 0 ; l < (int)len ; l++) + Read(Handle, &rejet, 1L ) ; /* a jeter */ +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void lit_ligne( UBYTE *ptdst, WORD nboctet ) +{ + UBYTE *dst; + BYTE o; + WORD nb; + UWORD i; + + dst = ptdst; + if(flgcomp) + { + while(nboctet > 0) + { + o = ReadIff(); + if(o >= 0) + { + nb = o + 1; + nboctet -= nb; + for ( i=0 ; i= 0 ; p--) + { + col <<= 1 ; + if(*(bufligne + p*nboctet + a) & msk) col++ ; + } + *dst++ = col; + } + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void lit_bodyILBM( UBYTE *ptr ) +{ + WORD lig,nboctet ; + UBYTE *bufligne ; + + if ((bufligne = Malloc(MAXBUFLIGNE)) == 0 ) return ; + nboctet = RowByte(Larg) ; + + for(lig = 0 ; lig < 200 ; lig++) + { + memset( bufligne, 0, MAXBUFLIGNE ) ; + if (lig < haut ) + { + lit_ligne( bufligne,nboctet*nbr_plan ) ; + ConvertMCGA(bufligne,ptr,nboctet,nbr_plan ) ; + memset( ptr+nboctet*8,0, 320-nboctet*8 ) ; + } + else + { + memset( ptr, 0, Lbm_Width ) ; + } + ptr += Lbm_Width ; + } + Free( bufligne ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void lit_bodyPBM( UBYTE *ptr ) +{ + WORD lig ; + + for(lig = 0 ; lig < 200 ; lig++) + { + lit_ligne( ptr,larg ) ; + ptr += Lbm_Width ; + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û ÛßßßÛ ÛßßßÛ ÛßßßÜ Û ÛßßÛ ÛÜ ÜÛ + ÛÛ ÛÛ Û ÛÛßßÛ ÛÛ Û ÛÛ ÛÛßßÛ ÛÛß Û + ßßßßß ßßßßß ßß ß ßßßß ßßßßß ßßßßß ßßßßß ßß ß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +LONG Load_Lbm( char *name, UBYTE *ptrscreen, UBYTE *ptrpal ) +{ + ULONG len2 ; + WORD type = 0 ; /* 0 = ILBM; 1 = PBM */ + UBYTE *ptr ; + + CptIff = 0; + Handle = OpenRead( name ) ; + if( !Handle ) return FALSE ; + + BufferIff = Malloc( 64000 ) ; + +/* printf( "%s: ", name ) ; */ + + Read( Handle, head, 4L ) ; + Read( Handle, &len, 4L ) ; /* lit taille */ + Read( Handle, head, 4L ) ; /* lit ILBM */ + if( strcmp( head, "ILBM" )!= 0 ) type = 1; /* PBM */ + + while( TRUE ) + { + len2 = Read( Handle, head, 4L ) ; + if( len2 != 4 ) break ; /* fin de fichier */ + Read( Handle, &len, 4L ) ; /* lit taille du chunk */ + itoml( &len ) ; + if( len&1 ) len++ ; + if(strcmp(head,"BMHD") == 0) lit_bmhd() ; + else + if(strcmp(head,"CMAP") == 0) /* pal */ + Read( Handle, ptrpal, 768 ) ; + else + if(strcmp(head,"BODY") == 0) + { + if( type==0 ) + lit_bodyILBM( ptrscreen ) ; + else + lit_bodyPBM( ptrscreen ) ; + break; + } + else lit_bloc() ;/* bloc inconnu on le saute */ + } + + Free( BufferIff ) ; + Close( Handle ) ; + +/* printf( "converted to VGA " ) ; */ + return TRUE ; +} + + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛÛßßß ÛßßßÛ Û Û Ûßßßß Û ÛßßÛ ÛÜ ÜÛ + ßßßßÛ ÛÛßßÛ ÛÛ Üß ÛÛßß ÛÛ ÛÛßßÛ ÛÛß Û + ßßßßß ßß ß ßßß ßßßßß ßßßßß ßßßßß ßßßßß ßß ß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +LONG Save_Lbm( char *name, UBYTE *ptrscr, UBYTE *ptrpal ) +{ + UWORD nbplan=8,a=0; + UWORD resolx = 320; + UWORD resoly = 200; + UWORD y ; + UWORD ligne,colonne; + + Handle = OpenWrite( name ); + if ( Handle == 0) return 0 ; + WriteIff("FORM",4L); + WriteIffLong(64816L); + WriteIff("PBM ",4L); + WriteIff("BMHD",4L); + WriteIffLong(20L); + WriteIff((void *)&((UBYTE*)&resolx)[1],1L); + WriteIff((void *)&((UBYTE*)&resolx)[0],1L); + WriteIff((void *)&((UBYTE*)&resoly)[1],1L) ; + WriteIff((void *)&((UBYTE*)&resoly)[0],1L) ; + WriteIffLong(0L); /* lit 4 octets avant le, */ + WriteIff(&nbplan,1L); + WriteIff(&a,1L); + a = 0; /* flg non compilee */ + WriteIff(&a,1L); + WriteIff(&a,1L); /* pad */ + WriteIffLong(0L); + WriteIffLong(0L); + + WriteIff("CMAP",4L); /* pal */ + WriteIffLong(3*256L); + WriteIff(ptrpal,3*256L); + + colonne = 40; + ligne = 200; + + WriteIff ("BODY",4L); + WriteIffLong ((LONG)(colonne*nbplan*ligne)); + + for( y=0; y<200; y++ ) + { + Write( Handle, ptrscr, 320 ) ; + ptrscr += Lbm_Width ; + } + +/* Write (Handle, ptrscr, 64000L ); */ + + Close( Handle ); + return TRUE ; +} diff --git a/LIB386/LIB_SVGA/LIB_SVGA.H b/LIB386/LIB_SVGA/LIB_SVGA.H new file mode 100644 index 0000000..9d66b41 --- /dev/null +++ b/LIB386/LIB_SVGA/LIB_SVGA.H @@ -0,0 +1,209 @@ +/*----------------------------------------------------------------------------- +; Extern lib_svga 386 +;-----------------------------------------------------------------------------*/ + +#ifdef WATCOM9 +#pragma library ( "f:\projet\lib386\lib_svga\lb9_svga.lib" ); +#else +#pragma library ( "f:\projet\lib386\lib_svga\lib_svga.lib" ); +#endif + +/*-----------------------------------------------------------------------------*/ + +#define SVGA_VESA 0 /* VESA compliant board at Adress 0xA0000 */ +#define SVGA_TRIDENT 1 /* Trident 8800 & 8900 */ +#define SVGA_ATI 2 /* ATI Chipset */ +#define SVGA_S3 3 /* S3 Boards (expect init with VESA mode 102) */ +#define SVGA_CIRRUS 4 /* Cirrus (some Genoa) (expect init with VESA mode 102) */ +#define SVGA_TSENG 5 /* Tseng ET3000 & ET4000 */ +#define SVGA_WESTERN 6 /* Western Digital / Paradise */ +#define SVGA_GENOA 7 /* REAL Genoa (not Cirrus or ET3000) */ + +/*-----------------------------------------------------------------------------*/ +extern WORD ClipXmin ; +extern WORD ClipYmin ; +extern WORD ClipXmax ; +extern WORD ClipYmax ; + +extern ULONG TabOffLine ; +extern UBYTE *Phys ; +extern UBYTE *Log ; +extern UBYTE *MemoLog ; +extern WORD Screen_X ; +extern WORD Screen_Y ; +extern UBYTE Text_Ink ; +extern UBYTE Text_Paper ; +extern UBYTE OldVideo ; +extern WORD SizeCar ; +/*-----------------------------------------------------------------------------*/ +extern WORD Svga_Card ; +extern void *BankChange ; +extern LONG BankCurrent ; +/*-----------------------------------------------------------------------------*/ + +extern WORD TypePoly ; + +extern WORD NbPolyPoints ; + +extern WORD TabPoly[] ; +extern WORD TabText[] ; + +extern WORD TabVerticG[] ; +extern WORD TabVerticD[] ; +extern WORD Ymin ; +extern WORD Ymax ; + +extern WORD TabCoulG[] ; +extern WORD TabCoulD[] ; + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* MOUSE.C */ +extern volatile LONG Click ; +extern volatile LONG Mouse_X ; +extern volatile LONG Mouse_Y ; +extern LONG Mouse_X_Dep ; +extern LONG Mouse_Y_Dep ; +extern UBYTE *GphMouse ; + +extern void __loadds __far click_handler(int ,int ,int ); +extern void SetMouseBox(long ,long ,long ,long ); +extern void SetMouseSpeed(long ,long ); +extern void SetMousePos(long ,long ); +extern void GetMouseDep(void); +extern void ShowMouse(long ); +extern void AffMouse(void); +extern void SetMouse(short ); +extern void InitMouse(void); +extern void ClearMouse(void); + +/*-----------------------------------------------------------------------------*/ +/* S_PAL.asm */ +void PalOne( UBYTE coul, UBYTE r, UBYTE v, UBYTE b ) ; +void PalMulti( WORD startcoul, WORD nbcoul, UBYTE *pal ) ; +void Palette( void *pal ) ; +/*-----------------------------------------------------------------------------*/ +/* FONT.ASM */ +void CoulFont( LONG couleur ) ; +void SetFont( void *font, LONG interleave, LONG interspace ) ; +LONG SizeFont( void *chaine ) ; +LONG CarFont( LONG xcar, LONG ycar, LONG car ) ; +void Font( LONG xchaine, LONG ychaine, void *chaine ) ; +/*-----------------------------------------------------------------------------*/ +/* GRAPH_A.ASM */ +void AffGraph( LONG num, LONG x, LONG y, void *bank ) ; +void GetDxDyGraph( LONG num, LONG *dx, LONG *dy, void *bank ) ; +/*-----------------------------------------------------------------------------*/ +/* MASK_A.ASM */ +void AffMask( LONG num, LONG x, LONG y, void *bank ) ; +/*-----------------------------------------------------------------------------*/ +/* InitSvga.asm */ +void SetClip( LONG x0, LONG y0, LONG x1, LONG y1 ) ; +void UnSetClip( void ) ; +void MemoClip( void ) ; +void RestoreClip( void ) ; +/*-----------------------------------------------------------------------------*/ +/* Box.asm */ +void Box( LONG x0, LONG y0, LONG x1, LONG y1, LONG couleur ) ; +/*-----------------------------------------------------------------------------*/ +/* Line.asm */ +void Line( LONG x0, LONG y0, LONG x1, LONG y1, LONG couleur ) ; +/*-----------------------------------------------------------------------------*/ +/* Zoom.asm */ +void ScaleLine( LONG xa0, LONG xa1, void *src, LONG xb0, LONG xb1, void *dst ) ; +void ScaleBox( LONG xa0, LONG ya0, LONG xa1, LONG ya1, void *src, + LONG xb0, LONG yb0, LONG xb1, LONG yb1, void *dst ) ; +/*-----------------------------------------------------------------------------*/ +/* CopyMask.asm */ +void CopyMask( LONG num, LONG x, LONG y, void *bank, void* screen ) ; +/*-----------------------------------------------------------------------------*/ +/* Mask_A.asm */ +void CoulMask( LONG coulmask ) ; +void AffMask( LONG num, LONG x, LONG y, void *bank ) ; +void GetDxDyMask( LONG num, LONG *dx, LONG *dy, void *bank ) ; +/*-----------------------------------------------------------------------------*/ +/* S_PLOT.asm.asm */ +void Plot( LONG x, LONG y, LONG couleur ) ; +LONG GetPlot( LONG x, LONG y ) ; +/*-----------------------------------------------------------------------------*/ +/* S_SCREEN.asm */ +void Cls( void ) ; +void CopyScreen( void *src, void *dst ) ; +void Vsync( void ) ; +void Flip( void ) ; +void FlipComp( void ) ; +/*-----------------------------------------------------------------------------*/ +/* S_STRING.asm */ +void AffString( LONG x, LONG y, void *text ) ; +void CoulText( LONG coul0, LONG coul1 ) ; +extern UBYTE Font8X8 ; + +/*-----------------------------------------------------------------------------*/ +/* S_BLOCK2.asm */ +void CopyBlockOnBlack( LONG x0, LONG y0, LONG x1, LONG y1, void *src, void *dst ) ; +/*-----------------------------------------------------------------------------*/ +/* GRAPHMSK.asm */ +LONG CalcGraphMsk( LONG num, void *bank, void *mask ) ; +/*-----------------------------------------------------------------------------*/ +/* S_BLOCK.asm */ +void CopyBlock( LONG x0, LONG y0, LONG x1, LONG y1, void *src, + LONG xd, LONG yd, void *dst ) ; + +/*-----------------------------------------------------------------------------*/ +/* S_BLOCK3.asm */ +void CopyBlockIncrust( LONG x0, LONG y0, LONG x1, LONG y1, void *src, + LONG xd, LONG yd, void *dst ) ; + +/*-----------------------------------------------------------------------------*/ +/* S_PHYS.asm */ +// void CopyBlockIncrust( LONG x0, LONG y0, LONG x1, LONG y1 ) ; +void CopyBlockPhysClip( LONG x0, LONG y0, LONG x1, LONG y1 ) ; +void CopyBlockPhys( LONG x0, LONG y0, LONG x1, LONG y1 ) ; +void SaveBlock( void *screen, void *buffer, LONG x, LONG y, LONG dx, LONG dy ) ; +void RestoreBlock( void *screen, void *buffer, LONG x, LONG y, LONG dx, LONG dy ) ; + +/*-----------------------------------------------------------------------------*/ +/* LBM.c 320*200 */ + +extern WORD Lbm_Width ; // 640 or 320 (for source format) + +extern unsigned char ReadIff(void); +extern void WriteIff(void *,unsigned long ); +extern void WriteIffLong(unsigned long ); +extern void itoml(void *); +extern void lit_bmhd(void); +extern void lit_bloc(void); +extern void lit_ligne(unsigned char *,short ); +extern void ConvertMCGA(unsigned char *,unsigned char *,unsigned short ,short ); +extern void lit_bodyILBM(unsigned char *); +extern void lit_bodyPBM(unsigned char *); +extern long Load_Lbm(char *,unsigned char *,unsigned char *); +extern long Save_Lbm(char *,unsigned char *,unsigned char *); + +/*-----------------------------------------------------------------------------*/ +/* PCX.c 640*480 */ + +extern void line_out(unsigned char *); +extern unsigned char next_char(unsigned long ,unsigned char *); +extern void Load_Pcx(char *,unsigned char *,unsigned char *); +extern void Save_Pcx(char *,unsigned char *,unsigned char *); + +/*-----------------------------------------------------------------------------*/ +/* s_dll.c */ + +extern long SvgaInitDLL(char *); +/*-----------------------------------------------------------------------------*/ +/* s_text.c */ +extern void Text(short ,short ,char * ,... ); + +/*-----------------------------------------------------------------------------*/ +/* s_rect.c */ + +extern void Rect(long ,long ,long ,long ,long ); + +/*-----------------------------------------------------------------------------*/ +/* initmode.c */ + +extern void InitGraphSvga(void); +extern void ClearGraphSvga(void); +extern void InitGraphMcga(void); +extern void ClearGraphMcga(void); diff --git a/LIB386/LIB_SVGA/MAKEFILE b/LIB386/LIB_SVGA/MAKEFILE new file mode 100644 index 0000000..5edc288 --- /dev/null +++ b/LIB386/LIB_SVGA/MAKEFILE @@ -0,0 +1,66 @@ +# name the compiler +!ifdef %HOME +!ifeq WATCOM9 yes +CC = c:\compil\watcom\bin\wcc386p +WL = c:\compil\watcom\binb\wlib +!else +CC = c:\compil\watcom10\binb\wcc386 +WL = c:\compil\watcom10\binb\wlib +!endif +!else +!ifeq WATCOM9 yes +CC = f:\compil\watcom\bin\wcc386p +WL = f:\compil\watcom\binb\wlib +!else +CC = f:\compil\watcom10\binb\wcc386 +WL = f:\compil\watcom10\binb\wlib +!endif +!endif + +ASM = ml + +!ifeq WATCOM9 yes +CFLAGS = /oeaxt /zp2 /4s /zq /s /DWATCOM9 +!else +CFLAGS = /oeaxt /zp2 /5s /zq /s +!endif +LFLAGS = /c /q /b /n +#AFLAGS = /m2 /mx /z /zi /t /jMASM51 /jQUIRKS +AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=; + + +OBJETS1 = InitMode.obj InitSvga.obj Graph_A.obj +OBJETS2 = S_Text.obj S_string.obj S_Mouse.Obj Mask_A.obj Font_A.obj +OBJETS3 = S_Screen.obj S_Block.obj S_Block2.obj S_Pal.obj +OBJETS4 = S_Plot.obj S_Box.obj S_Line.obj S_Poly.obj S_FillV.obj +OBJETS5 = S_MouseA.obj Rect.obj Zoom.obj MaskGph.obj GraphMsk.obj +OBJETS6 = S_Phys.obj texture.obj s_block3.obj Lbm.obj Pcx.obj +OBJETS7 = S_Dll.obj vesa.obj Gif.obj + +!ifeq WATCOM9 yes +LIB = LB9_SVGA +!else +LIB = LIB_SVGA +!endif + +$(LIB).LIB: $(OBJETS1) $(OBJETS2) $(OBJETS3) $(OBJETS4) $(OBJETS5) $(OBJETS6) $(OBJETS7) + + @echo $(OBJETS1) > clibmak.rsp + @echo $(OBJETS2) >> clibmak.rsp + @echo $(OBJETS3) >> clibmak.rsp + @echo $(OBJETS4) >> clibmak.rsp + @echo $(OBJETS5) >> clibmak.rsp + @echo $(OBJETS6) >> clibmak.rsp + @echo $(OBJETS7) >> clibmak.rsp + + @$(WL) $(LIBFLAGS) $(LIB) @clibmak.rsp + @del clibmak.rsp + @prntitre M "$(LIB) OK" + +.asm.obj: + @PRNTITRE M "$*.ASM" + @$(ASM) $(AFLAGS) $*.ASM + +.c.obj: + @PRNTITRE M "$*.C" + @$(CC) $(CFLAGS) $* diff --git a/LIB386/LIB_SVGA/MASKGPH.C b/LIB386/LIB_SVGA/MASKGPH.C new file mode 100644 index 0000000..a24be65 --- /dev/null +++ b/LIB386/LIB_SVGA/MASKGPH.C @@ -0,0 +1,62 @@ + +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_svga\lib_svga.h" + +#include +#include +#include +#include + + +/*-------------------------------------------------------------------------*/ +ULONG CreateMaskGph( UBYTE *ptsrc, UBYTE *ptdst ) +{ + UBYTE *ptd ; + ULONG nbg, off; + ULONG *ptoff ; + ULONG size, i ; + + ptoff = (ULONG*)ptdst ; + + off = *(ULONG *)ptsrc ;/* First Offset Src */ + + *ptoff++ = off ;/* First Offset */ + + ptd = ptdst+off ; + + nbg = (off-4)>>2 ;/* Nombre de Graph */ + + for ( i = 0 ; i < nbg ; i++ ) + { + size = CalcGraphMsk( i, ptsrc, ptd ) ; + + off += size ;/* Maj Offset */ + *ptoff++ = off ;/* Write Offset */ + ptd += size ;/* Maj Pt Dest */ + } + return(off) ; +} +/*-------------------------------------------------------------------------*/ +/*--------------------------------------------------------------------------*/ + + + + + + + + + + + + + + + + + + + + + diff --git a/LIB386/LIB_SVGA/MASK_A.ASM b/LIB386/LIB_SVGA/MASK_A.ASM new file mode 100644 index 0000000..8828053 --- /dev/null +++ b/LIB386/LIB_SVGA/MASK_A.ASM @@ -0,0 +1,318 @@ +;---------------------------------------------------------------------------- +; Mask_A.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386P + jumps + .model SMALL, SYSCALL +;---------------------------------------------------------------------------- + .data +;---------------------------------------------------------------------------- + include \projet\lib386\lib_svga\svga.ash +comment @ + DWORD TabOffset[] + Brick: + - BYTE Delta X + - BYTE Delta Y + Line(Delta Y): + - BYTE NbBlock + Block 0: Nb Zero to Jump + Block 1: Nb Zero to Write + Block 2: Nb Zero to Jump + etc... +@ + +BufferClip db 512 dup(?) + +ColMask db 0 ; Noir par Defaut + +ALIGN 4 + +OffsetBegin dd 0 +NbPix dd 0 + +;---------------------------------------------------------------------------- + .code + + public NoLanguage CoulMask + public NoLanguage AffMask + public NoLanguage AffMask_Asm + public NoLanguage GetDxDyMask + +;---------------------------------------------------------------------------- +CoulMask proc ,\ + coul:DWORD + + mov eax, coul + mov byte ptr [ColMask], al + ret + +CoulMask endp +;---------------------------------------------------------------------------- +AffMask proc uses esi edi ebx ebp,\ + nummask:DWORD, xmask:DWORD, ymask:DWORD, \ + bankmask:DWORD + + mov eax, nummask + mov ebx, xmask + mov ecx, ymask + mov esi, bankmask + + Call AffMask_Asm + + ret + +AffMask endp +;---------------------------------------------------------------------------- +AffMask_Asm proc + + add esi, [esi+eax*4] ; ESI = Begin Data + + xor eax, eax + mov al, [esi+2] + add ebx, eax ; Hot X + mov al, [esi+3] + add ecx, eax ; Hot Y + +;----------------------------------------------- + + xor edx, edx + mov dl, [esi] ; Delta X + mov al, [esi+1] ; Nb Line ( Delta Y ) + add esi, 4 ; Jump HotX & HotY + +;----------------------------------------------- Test Clipping + + add edx, ebx + add eax, ecx + dec edx + dec eax + + cmp ebx, ClipXmin + jl ClippingMask + cmp ecx, ClipYmin + jl ClippingMask + cmp edx, ClipXmax + jg ClippingMask + cmp eax, ClipYmax + jg ClippingMask + + inc edx + inc eax + sub edx, ebx + sub eax, ecx + +;----------------------------------------------- Calcul Offset Ecran + mov edi, Log + add edi, TabOffLine[ecx*4] + add edi, ebx + mov bh, al ; BH = NbLine + sub edx, Screen_X ; EDX = Offset Screen + neg edx ; EDX = Screen_X-edx + xor ecx, ecx ; Maz Compteur + mov ebp, edx ; EBP Offset Next Line + mov al, byte ptr [ColMask]; Couleur du Masque + mov ah, al +;----------------------------------------------- Init NbBlock for this line +NextLine: mov bl, [esi] ; BL = Nb Block for this line + inc esi +;----------------------------------------------- Manage One Line +SameLine: mov cl, [esi] ; Nb Zero to Jump + add edi, ecx ; Incrust + dec bl + je EndBlock + mov cl, [esi+1] ; Nb Zero to Write + add esi, 2 + shr ecx, 1 + rep stosw ; Write Zero + jnc nobyte + stosb +nobyte: dec bl ; Nb Block-- + jne SameLine ; Continue Same Line + add edi, ebp ; EDI += Offset Next Line + dec bh ; NbLine-- + jne NextLine ; Next Line + ret +EndBlock: + inc esi + add edi, ebp ; EDI += Offset Next Line + dec bh ; NbLine-- + jne NextLine ; Next Line + ret + +;-------------------------------------------------------------------- Clipping +; Graph : ( EBX, ECX ) ( EDX, EAX ) +ClippingMask: + cmp ebx, ClipXmax + jg EndMask + cmp ecx, ClipYmax + jg EndMask + cmp edx, ClipXmin + jl EndMask + cmp eax, ClipYmin + jl EndMask + + cmp ecx, ClipYmin + jge PasHaut + +;---------------------- Clipping Haut, Saute ClipYmin-ECX Line(s) + + sub ecx, ClipYmin + neg ecx + + mov ebp, eax +;---------------------- + xor eax, eax + +NextH: mov al, [esi] ; NbBlock + lea esi, [esi+1+eax] ; Jump Data + dec ecx + jnz NextH + + mov eax, ebp + + mov ecx, ClipYmin ; New Y Haut + +;---------------------- Clipping Bas +PasHaut: cmp eax, ClipYmax + jle PasBas + mov eax, ClipYmax +;---------------------- Clipping Gauche +Pasbas: mov OffsetBegin, 0 + cmp ebx, ClipXmin + jge PasGauche + push eax + mov eax, ClipXmin + sub eax, ebx + mov OffsetBegin, eax + pop eax +;---------------------- Clipping Droit +PasGauche: mov ebp, edx + sub ebp, ebx + sub ebp, OffsetBegin + inc ebp + mov NbPix, ebp + + cmp edx, ClipXmax + jle PasDroit + + sub edx, ClipXmax + sub NbPix, edx + mov edx, ClipXmax +;---------------------- +PasDroit: + + mov edi, Log + add edi, TabOffLine[ecx*4] + add edi, ebx + + + sub eax, ecx + inc al + mov bh, al ; BH NbLine + xor ecx, ecx + mov ebp, edi +;---------------------------------------------- + mov dl, byte ptr [ColMask] + mov dh, dl + ; ESI = DATAS LINE +NextL: lea edi, BufferClip ; EDI = BUFFERCLIP + mov bl, [esi] ; NbBlock + inc esi +SameL: mov cl, [esi] + xor ax, ax + shr ecx, 1 + rep stosw + jnc nobyte1 + stosb +nobyte1: dec bl + je EndLine + mov cl, [esi+1] + add esi, 2 + mov ax, dx ; ColMask + shr ecx, 1 + rep stosw + jnc nobyte2 + stosb +nobyte2: dec bl + jne SameL + dec esi +;---------------------- +EndLine: inc esi + push esi ; SAVE ESI + mov ecx, OffsetBegin + lea edi, [ebp+ecx] ; EDI = SCREEN + lea esi, [BufferClip+ecx] ; ESI = BUFFERCLIP + mov ecx, NbPix +Again: lodsb + or al, al + je Incrust + mov [edi], al +Incrust: inc edi + dec ecx + jnz Again + add ebp, 640 + pop esi + dec bh + jne NextL + +;---------------------- +EndMask: ret +AffMask_Asm endp +;---------------------------------------------------------------------------- +GetDxDyMask proc uses esi edi ebx,\ + num:DWORD, ptdx:DWORD, ptdy:DWORD, bankmask:DWORD + + mov esi, bankmask + mov eax, num + add esi, [esi+eax*4] + mov edi, ptdx + xor eax, eax + mov al, [esi] + mov [edi], eax + mov edi, ptdy + mov al, [esi+1] + mov [edi], eax + ret +GetDxDyMask endp +;---------------------------------------------------------------------------- +; The + End + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LIB386/LIB_SVGA/MODEL.INC b/LIB386/LIB_SVGA/MODEL.INC new file mode 100644 index 0000000..037cb29 --- /dev/null +++ b/LIB386/LIB_SVGA/MODEL.INC @@ -0,0 +1,4 @@ + + .model large,c + + diff --git a/LIB386/LIB_SVGA/MOUSE.GPH b/LIB386/LIB_SVGA/MOUSE.GPH new file mode 100644 index 0000000000000000000000000000000000000000..d33c7376a416c92787b8c29e1226a44a9112c8ad GIT binary patch literal 1031 zcmbtTNpjpU3?95 zt%_F&Dz%jmWs-ZYM#>eT6B~(bwK5W0U5!R!n}{T~nMh)LC6d?{B8hG9@eVDzHY2fD z@d{4dN;qHhTn!Rium_QpsCG!b>6;XOqJV$>+O?1uU^T->d>C@((1b7n#E z%raxweEqb?nt?US@pB^!V+W6EptZOqDIO4rlETTSI^xuZ+3GJCi+KKjr_Q!uO9f{k zUmkd!TUYI}P8V6tPNigHwLxU;f?z DJ=A}R literal 0 HcmV?d00001 diff --git a/LIB386/LIB_SVGA/MOUSE.PCX b/LIB386/LIB_SVGA/MOUSE.PCX new file mode 100644 index 0000000000000000000000000000000000000000..d5b5477f6a53c4203976a97b913f94647ee572e5 GIT binary patch literal 12148 zcmeHNEsPsS6#gz!wN+)!4l4*KSP-zl;6Q*uz=8k+g98Qz3k(bj4j3E=*h&Tl1_urV z7%T`lU=U!iz`)Y3ed9YPaV3KQ16RFDu5^_O0?sB;-^lei@f3{*ebXA%!2Um=W0(M z!S)tRSspA8=AN;7uzIk1Fd6tfJ#3K4SIEToNaY*MdHAp zS`u&a_AAJ_%i~j-iInY&`rfPQ=C{I4=E^IGtR&chn@au0g{!0sSEi6cin%VN(cI%^ z;xb+_DT(=BH>nhvOt+cwF|NBEdt6RkIfIy%ghq4+83W8X=-k7u$~)vl=#&a+`r8tA z;YtN@Q4*JhzmySgL*;6c$0w&cRKfglaj9FTqdyADlq)YFR7uQoN12=PyXlF8<0as{ zT?q!7apt!@-exY(CT1m}cCdI!czzC9cM2d>cM2go)17N!)d{3z^TCr*pG>Z z0wRwuW^>wXuvj2Tc7WPwG#F4greH|kfDjW-H;5KEP7ubLhH*|qhr(t~!y|%o7tsG; z^xcX!BU;6@jA$OxIH1I%0jQ5n2a6LVO~gm&K1KU68a@J(P73Km0N2>eu}F}_h`Z<> zquoFw;PE$Wx?a*s(c3XChNRAE9MkBGh8;R@Q`~&_JiIw=tb6rk=V%_)#?Pur`|04@ z;6>|6+^n31k9&>7&QbZK<{wudg@IRp@=dk!FgSczDSz#I?#HgOE8kZ&U!C|W_LcHu s<)0|Orh5;475b{@tHd8DKT`gYD*LM8tFEtxdhAQ(ca&e}v3zI#AEJR@-v9sr literal 0 HcmV?d00001 diff --git a/LIB386/LIB_SVGA/PCX.C b/LIB386/LIB_SVGA/PCX.C new file mode 100644 index 0000000..6a07171 --- /dev/null +++ b/LIB386/LIB_SVGA/PCX.C @@ -0,0 +1,218 @@ +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_svga\lib_svga.h" + +#include +#include +#include +#include +#include +#include +#include + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßßÛ Ûßßßß ßÜ Üß + ÛÛßßß ÛÛ ÜßÜ + ßß ßßßßß ß ß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + + +struct ffblk { + char ff_reserved[21]; + char ff_attrib; + unsigned ff_ftime; + unsigned ff_fdate; + long ff_fsize; + char ff_name[13]; +}; + +union REGS reg; + +struct SREGS segregs; + +static struct { + char password; + char version; + char encoding; + char bits_per_pixel; + short int xmin, ymin, xmax, ymax; + short int xres, yres; + unsigned char palette[48]; + char reserved; + char no_of_planes; + short int bytes_per_line; + short int palette_type; + char filler[58]; + } pcx_header; + +short int srcseg, srcoff, destseg, destoff; +short int xres, yres, active_bank, bank; +short int attr, i, j, k, dir_index= 0, type, length[7]; + +short int column, end, done, level,key, start_x, start_y, start_angle, + cursor_x, cursor_y, mode; + +struct ffblk ffblk; + +long int col,row; + +short int index = 0 ; + +#define SIZE_BUF 2048L + +UBYTE *PtDest ; + +LONG debugline=0 ; + +/*--------------------------------------------------------------------------*/ + +void line_out( UBYTE *pts ) +{ + UBYTE *pt ; + WORD i ; + + pt = pts ; + + for ( i = 0 ; i < 640 ; i++ ) *PtDest++ = *pt++ ; + +/* Box( 0, 0, 160, 7, 0 ) ; + Text( 0, 0, "Ligne:%d", debugline++ ) ; + CopyBlockPhys( 0, 0, 160, 7 ) ; +*/ + +} +/*--------------------------------------------------------------------------*/ +UBYTE next_char( ULONG fd, UBYTE *pt) +{ + if ( index == SIZE_BUF ) + { + index = 0 ; + Read( fd, pt, SIZE_BUF ); + } + + return(pt[index++]) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û ÛßßßÛ ÛßßßÛ ÛßßßÜ ÛßßßÛ Ûßßßß ßÜ Üß + ÛÛ ÛÛ Û ÛÛßßÛ ÛÛ Û ÛÛßßß ÛÛ ÜßÜ + ßßßßß ßßßßß ßß ß ßßßß ßßßßß ßß ßßßßß ß ß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void Load_Pcx(char *file_name, UBYTE *screen, UBYTE *tabcol) +{ + ULONG fd ; + FILE *fsave ; + unsigned char ch,color,buffer[650],file_buf[SIZE_BUF] ; + short int i,j,k,m,pass,col,row,plane ; + + + PtDest = screen ; + + fd = OpenRead( file_name ) ; + + Read( fd, &pcx_header, 128L ) ; + + Seek( fd, -768L, SEEK_END ) ; + + Read( fd, tabcol, 768 ) ; + + Seek( fd, 128L, SEEK_START ) ; + + index = SIZE_BUF ;/* For Load in next_char */ + + for ( row=pcx_header.ymin ; row<=pcx_header.ymax ; row++ ) + { + for ( col=pcx_header.xmin ; col<=pcx_header.xmax ; col++ ) + { + ch = next_char( fd, file_buf ) ; + if ((ch & 0xC0) != 0xC0) + pass = 1 ; + else + { + pass = ch & 0x3F ; + ch = next_char( fd, file_buf ); + } + + for ( m=0 ; m +#include +#include + +void Rect( LONG x0, LONG y0, LONG x1, LONG y1, LONG coul ) +{ + Line( x0, y0, x1, y0, coul ) ; + Line( x0, y1, x1, y1, coul ) ; + Line( x0, y0, x0, y1, coul ) ; + Line( x1, y0, x1, y1, coul ) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ diff --git a/LIB386/LIB_SVGA/SAVEPCX.C b/LIB386/LIB_SVGA/SAVEPCX.C new file mode 100644 index 0000000..0bd7db4 --- /dev/null +++ b/LIB386/LIB_SVGA/SAVEPCX.C @@ -0,0 +1,108 @@ +/* + ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» + º º + º SAVETEST = PROGRAM TO STORE .PCX GRAPHICS FILES º + º º + º º + ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ +*/ +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_svga\lib_svga.h" + +#include +#include +#include +#include +#include + +/* voir pcx.c */ + +static struct { + char password; + char version; + char encoding; + char bits_per_pixel; + short int xmin, ymin, xmax, ymax; + short int xres, yres; + unsigned char palette[48]; + char reserved; + char no_of_planes; + short int bytes_per_line; + short int palette_type; + char filler[58]; + } pcx_header; + + +/* + ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» + º º + º º + ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ +*/ + +void PcxSave( UBYTE *filename, UBYTE *screen, UBYTE *ptrpalette ) + +{ + short int index = 0, i,k,number,num_out ; + unsigned char ch, old_ch, file_buf[640*2]; + ULONG handle ; + UBYTE c ; + + pcx_header.password = 0x0A; + pcx_header.version = 0x05; + pcx_header.encoding = 0x01; + pcx_header.xmin = 0; + pcx_header.ymin = 0; + pcx_header.reserved = 0; + pcx_header.palette_type = 0; + + /* 640 x 480 - 256 colors */ + pcx_header.bits_per_pixel = 0x08; + pcx_header.xmax = 639; + pcx_header.ymax = 479; + pcx_header.xres = 640; + pcx_header.yres = 480; + pcx_header.no_of_planes = 1 ; + pcx_header.bytes_per_line = 640 ; + + handle = OpenWrite( filename ) ; + + Write( handle, &pcx_header, 128 ) ; + + for ( k = pcx_header.ymin ; k <= pcx_header.ymax ; k++ ) + { + number = 1 ; + + old_ch = *( screen + 640*k ) ; + + for ( i = 1 ; i <= 640; i++ ) + { + if ( i == 640 ) ch = old_ch-1 ; + else ch = *( screen + 640*k + i ) ; + + if (( ch == old_ch ) && number < 63 ) number++ ; + else + { + num_out = ((unsigned char) number | 0xC0); + if ((number != 1) || ((old_ch & 0xC0) == 0xC0)) + file_buf[index++] = num_out; + file_buf[index++] = old_ch; + old_ch = ch; + number = 1; + } + } + + Write( handle, file_buf, index ); + index = 0 ; + } + + c = 0x0C ; + Write( handle, &c, 1 ) ; + + Write( handle, ptrpalette ,768 ) ; + + Close( handle ) ; +} + + diff --git a/LIB386/LIB_SVGA/SVGA.ASH b/LIB386/LIB_SVGA/SVGA.ASH new file mode 100644 index 0000000..9fc56b4 --- /dev/null +++ b/LIB386/LIB_SVGA/SVGA.ASH @@ -0,0 +1,36 @@ +;----------------------------------------------------------------------------- +; Extern lib_svga 386 +;----------------------------------------------------------------------------- + .data + + extrn NoLanguage ClipXmin :DWORD + extrn NoLanguage ClipYmin :DWORD + extrn NoLanguage ClipXmax :DWORD + extrn NoLanguage ClipYmax :DWORD + extrn NoLanguage Phys :DWORD + extrn NoLanguage Log :DWORD + extrn NoLanguage MemoLog :DWORD + extrn NoLanguage BankCurrent :DWORD + + extrn NoLanguage Screen_X :DWORD + extrn NoLanguage Screen_Y :DWORD + extrn NoLanguage TabOffLine :DWORD + + extrn NoLanguage SizeCar :WORD + + extrn NoLanguage Text_Ink :BYTE + extrn NoLanguage Text_Paper :BYTE + extrn NoLanguage OldVideo :BYTE + +POLY_TRISTE equ 0 +POLY_COPPER equ 1 +POLY_BOPPER equ 2 +POLY_MARBRE equ 3 +POLY_TELE equ 4 +POLY_TRANS equ 5 +POLY_TRAME equ 6 +POLY_GOURAUD equ 7 +POLY_DITHER equ 8 + + + diff --git a/LIB386/LIB_SVGA/S_BLOCK.ASM b/LIB386/LIB_SVGA/S_BLOCK.ASM new file mode 100644 index 0000000..ef96ef2 --- /dev/null +++ b/LIB386/LIB_SVGA/S_BLOCK.ASM @@ -0,0 +1,285 @@ +;---------------------------------------------------------------------------- +; S_BLOCK.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386P + jumps + .model FLAT, SYSCALL + + .data + + include f:\projet\lib386\lib_svga\svga.ash + +;---------------------------------------------------------------------------- + .code + + public NoLanguage CopyBlock + public NoLanguage SaveBlock + public NoLanguage RestoreBlock + +;---------------------------------------------------------------------------- +; CopyBlock( x0, y0, x1, y1, *src, xd, yd, *dst ) +; +CopyBlock proc uses esi edi ebx ebp,\ + x0:DWORD, y0:DWORD, x1:DWORD, y1:DWORD, src:DWORD,\ + xd:DWORD, yd:DWORD, dst:DWORD + + mov edx, x0 + mov ecx, y0 + mov ebx, x1 + mov eax, y1 +;---------------------- + + mov esi, TabOffLine[ecx*4] + add esi, src + add esi, edx ; SI Offset Src + + mov edi, yd + mov edi, TabOffLine[edi*4] + add edi, dst + add edi, xd ; DI Offset Dst + + sub ebx, edx + inc ebx ; BX Delta Y + + sub eax, ecx + inc eax ; AX Delta X + + mov edx, Screen_X + sub edx, ebx ; DX Delta Screen + + mov ebp, ebx + inc eax + shr ebx, 2 + and ebp, 11b + + shr eax, 1 + jnc short odd +Again: + mov ecx, ebx + rep movsd + mov ecx, ebp + rep movsb + + add esi, edx + add edi, edx +odd: + mov ecx, ebx + rep movsd + mov ecx, ebp + rep movsb + + add esi, edx + add edi, edx + + dec eax + jnz short Again + +CopyBlock_End: ret + +CopyBlock endp + +comment @ + +CopyBlock proc uses esi edi ebx,\ + x0:DWORD, y0:DWORD, x1:DWORD, y1:DWORD, src:DWORD,\ + xd:DWORD, yd:DWORD, dst:DWORD + + mov edx, x0 + mov ecx, y0 + mov ebx, x1 + mov eax, y1 +;---------------------- + + mov esi, TabOffLine[ecx*4] ; y0 + add esi, src + add esi, edx ; SI Offset Src + + mov edi, yd + mov edi, TabOffLine[edi*4] + add edi, dst + add edi, xd ; DI Offset Dst + + sub ebx, edx + inc ebx ; BX Delta Y + + sub eax, ecx + inc eax ; AX Delta X + + mov edx, Screen_X + sub edx, ebx ; DX Delta Screen +Again: + mov ecx, ebx + shr ecx, 2 + rep movsd + mov ecx, ebx + and ecx, 11b + rep movsb + + add esi, edx + add edi, edx + dec eax + jne short Again +CopyBlock_End: ret +CopyBlock endp + + @ + +;---------------------------------------------------------------------------- +; SaveBlock( *screen, *buffer, x0, y0, dx, dy ) +; +; DS:SI *screen +; ES:DI *buffer +; AX x0 +; BX y0 +; CX dx +; dx dy +; + +SaveBlock proc uses esi edi ebx ebp,\ + screen:DWORD, buffer:DWORD,\ + x0:DWORD, y0:DWORD, deltax:DWORD, deltay:DWORD + + mov edi, buffer + mov eax, x0 + mov ebx, y0 + mov ecx, deltax + mov edx, deltay + + sub ecx, eax + sub edx, ebx ; DX = DeltaY + inc ecx + inc edx + mov esi, TabOffLine[ebx*4] + add esi, eax + add esi, screen ; SI Offset Src + + mov ebx, ecx ; BX = DeltaX + + mov eax, Screen_X + sub eax, ebx ; bp Delta Screen + + mov ebp, ebx + inc edx + shr ebx, 2 + and ebp, 11b + + shr edx, 1 + jnc short odd +Again: + mov ecx, ebx ; Delta X + rep movsd + mov ecx, ebp + rep movsb + + add esi, eax +odd: + mov ecx, ebx ; Delta X + rep movsd + mov ecx, ebp + rep movsb + + add esi, eax + + dec edx + jne Again + + ret +SaveBlock endp + +comment @ + +SaveBlock proc uses esi edi ebx ebp,\ + screen:DWORD, buffer:DWORD,\ + x0:DWORD, y0:DWORD, deltax:DWORD, deltay:DWORD,\ + + mov edi, buffer + mov eax, x0 + mov ebx, y0 + mov ecx, deltax + mov edx, deltay + + sub ecx, eax + sub edx, ebx ; DX = DeltaY + inc ecx + inc edx + mov esi, TabOffLine[ebx*4] + add esi, eax ; SI Offset Src + add esi, screen + + mov ebx, ecx ; BX = DeltaX + + mov ebp, Screen_X + sub ebp, ebx ; bp Delta Screen +Again: + mov ecx, ebx ; Delta X + shr ecx, 2 + rep movsd + mov ecx, ebx + and ecx, 11b + rep movsb + + add esi, ebp + dec edx + jne Again + + ret +SaveBlock endp + + @ + +;---------------------------------------------------------------------------- +; RestoreBlock( *buffer, *screen, x0, y0, dx, dy ) +; +; DS:SI *buffer +; ES:DI *screen +; AX x0 +; BX y0 +; CX x1 +; dx y1 +; Already Clipped +; +RestoreBlock proc uses esi edi ebx ebp,\ + screen:DWORD, buffer:DWORD,\ + x0:DWORD, y0:DWORD, deltax:DWORD, deltay:DWORD + + mov esi, buffer + mov eax, x0 + mov ebx, y0 + mov ecx, deltax + mov edx, deltay + + sub ecx, eax + sub edx, ebx ; DX = DeltaY + inc ecx + inc edx + mov edi, TabOffLine[ebx*4] + add edi, eax ; SI Offset Src + add edi, screen + mov ebx, ecx ; BX = DeltaX + + mov ebp, Screen_X + sub ebp, ebx ; bp Delta Screen +Again: + mov ecx, ebx ; Delta X + shr ecx, 2 + rep movsd + mov ecx, ebx + and ecx, 11b + rep movsb + + add edi, ebp + dec edx + jne Again + + ret +RestoreBlock endp +;---------------------------------------------------------------------------- +; The + End + + + + + + diff --git a/LIB386/LIB_SVGA/S_BLOCK2.ASM b/LIB386/LIB_SVGA/S_BLOCK2.ASM new file mode 100644 index 0000000..93608ef --- /dev/null +++ b/LIB386/LIB_SVGA/S_BLOCK2.ASM @@ -0,0 +1,124 @@ +;---------------------------------------------------------------------------- +; S_BLOCK2.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386P + jumps + .model SMALL, SYSCALL + + .data +EVEN + +CptPixl dw 0 +CptLine dw 0 + + include f:\projet\lib386\lib_svga\svga.ash + + +;---------------------------------------------------------------------------- + .code + + public NoLanguage CopyBlockOnBlack + +;---------------------------------------------------------------------------- +; ptsrc -> ptdst +; CopyBlockOnBlack( x0, y0, x1, y1, BufSrc, BufDst ) +; +; Copy datas from BufSrc to Bufdst, but only on Black +; +CopyBlockOnBlack proc uses esi edi ebx ebp,\ + x0:DWORD, y0:DWORD, x1:DWORD, y1:DWORD,\ + ptsrc:DWORD, ptdst:DWORD + + mov edx, x0 + mov ecx, y0 + mov ebx, x1 + mov eax, y1 +;---------------------- Compute Delta X & Y + sub ebx, edx ; EBX Delta X + sub eax, ecx ; EAX Delta Y + inc ebx ; EBX = Delta X + 1 + inc eax ; EAX = Delta Y + 1 + mov word ptr [CptPixl], bx + mov word ptr [CptLine], ax +;---------------------- Compute Adresse + mov eax, TabOffLine[ecx*4] + mov esi, ptsrc + mov edi, ptdst + add eax, edx + add esi, eax + add edi, eax + xor eax, eax ; Je cherche != 0 + + mov edx, Screen_X + sub edx, ebx ; DX Delta Screen +;---------------------- +NewLine: + xor ebx, ebx + mov bx, [CptPixl] +;----------------------------------------------------------------------------- +ScanAgain: + mov ecx, ebx ; EBX Bytes to Scan + repne scasb ; Arret quand != 0 + jne EndLine2 ; c'est fini! + + dec edi ; EDI un peu trop loin + inc ecx ; ECX trop Petit + + sub ebx, ecx ; EBX = Bytes Parcourus + add esi, ebx ; Maj ESI + + mov ebx, ecx ; EBX = Bytes Restant + rep scasb ; Combien != 0 ? + je short UntilEnd ; Tous jusqu'a fin (Quick! + + inc ecx ; Maj ECX + dec edi ; Maj EDI + sub ebx, ecx ; EBX = Nb Same Bytes + sub edi, ebx ; Recule EDI + + xchg ecx, ebx +;----------------------- + mov ebp, ecx + shr ecx, 2 + rep movsd ; movsD Plus Tard! + mov ecx, ebp + and ecx, 11b + rep movsb +;----------------------- + jmp short ScanAgain +UntilEnd: + sub edi, ebx + mov ecx, ebx + shr ecx, 2 + rep movsd + mov ecx, ebx + and ecx, 11b + rep movsb +EndLine: +;----------------------------------------------------------------------------- + add edi, edx + add esi, edx + dec word ptr [CptLine] + jne short NewLine +;---------------------- + ret +EndLine2: + add esi, ebx + add edi, edx + add esi, edx + dec word ptr [CptLine] + jne short NewLine +;---------------------- + ret + +CopyBlockOnBlack endp +;---------------------------------------------------------------------------- +; The + End + + + + + + diff --git a/LIB386/LIB_SVGA/S_BLOCK3.ASM b/LIB386/LIB_SVGA/S_BLOCK3.ASM new file mode 100644 index 0000000..2649a69 --- /dev/null +++ b/LIB386/LIB_SVGA/S_BLOCK3.ASM @@ -0,0 +1,75 @@ +;---------------------------------------------------------------------------- +; S_BLOCK.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386P + jumps + .model SMALL, SYSCALL + + .data + + include f:\projet\lib386\lib_svga\svga.ash + +;---------------------------------------------------------------------------- + .code + + public NoLanguage CopyBlockIncrust + +;---------------------------------------------------------------------------- +; CopyBlockIncrust( x0, y0, x1, y1, *src, xd, yd, *dst ) +; +CopyBlockIncrust proc uses esi edi ebx ebp,\ + x0:DWORD, y0:DWORD, x1:DWORD, y1:DWORD, src:DWORD,\ + xd:DWORD, yd:DWORD, dst:DWORD + + mov edx, x0 + mov ecx, y0 + mov ebx, x1 + mov eax, y1 +;---------------------- + + mov esi, TabOffLine[ecx*4] ; y0 + add esi, src + add esi, edx ; SI Offset Src + + mov edi, yd + mov edi, TabOffLine[edi*4] + add edi, dst + add edi, xd ; DI Offset Dst + + sub ebx, edx + inc ebx ; BX Delta Y + + sub eax, ecx + inc eax ; AX Delta X + mov ebp, eax + + mov edx, Screen_X + sub edx, ebx ; DX Delta Screen +Again: + mov ecx, ebx + +loopx: lodsb + or al, al + jz incrust + mov byte ptr[edi], al +incrust: inc edi + dec ecx + jnz loopx + + add esi, edx + add edi, edx + dec ebp + jne short Again +CopyBlock_End: ret +CopyBlockIncrust endp + +;---------------------------------------------------------------------------- +; The + End + + + + + + diff --git a/LIB386/LIB_SVGA/S_BOX.ASM b/LIB386/LIB_SVGA/S_BOX.ASM new file mode 100644 index 0000000..46bdc46 --- /dev/null +++ b/LIB386/LIB_SVGA/S_BOX.ASM @@ -0,0 +1,93 @@ +; S_BOX.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386p + jumps + .model SMALL, SYSCALL + + .data + + include svga.ash + + .code + + public NoLanguage Box + +;---------------------------------------------------------------------------- +; Box( x0, y0, x1, y1, col ) +; +; +Box proc uses edi ebp ebx,\ + X0:DWORD, Y0:DWORD, X1:DWORD, Y1:DWORD, Col:DWORD + +;---------------------- + mov eax, X0 + mov ebx, Y0 + mov ecx, X1 + mov edx, Y1 + + cmp eax, ClipXmax + jg Box_End + cmp ecx, ClipXmin + jl Box_End + cmp ebx, ClipYmax + jg Box_End + cmp edx, ClipYmin + jl Box_End +TestLeft: + cmp eax, ClipXmin + jge TestRight + mov eax, ClipXmin +TestRight: + cmp ecx, ClipXmax + jle TestUp + mov ecx, ClipXmax +TestUp: + cmp ebx, ClipYmin + jge TestDown + mov ebx, ClipYmin +TestDown: + cmp edx, ClipYmax + jle OkNoClip + mov edx, ClipYmax +OkNoClip: +;---------------------- + mov edi, ebx ; Y0 + mov edi, TabOffLine[edi*4] + add edi, Log + add edi, eax ; EDI Offset Src +;---------------------- + sub edx, ebx ; Init Delta Y + mov ebx, edx + inc ebx + + mov edx, ecx ; Init Delta X + sub edx, eax + inc edx +;---------------------- + mov al, byte ptr [Col] + mov ah, al ; Init Color + mov cx, ax + shl eax, 16 + mov ax, cx +;---------------------- + mov ebp, Screen_X + sub ebp, edx ; ebp Delta Screen +Again: + mov ecx, edx + shr ecx, 2 + rep stosd + mov ecx, edx + and ecx, 11b + rep stosb + + add edi, ebp + dec ebx + jne Again +Box_End: + ret +Box endp +;---------------------------------------------------------------------------- +; The + End + diff --git a/LIB386/LIB_SVGA/S_CPYBOX.ASM b/LIB386/LIB_SVGA/S_CPYBOX.ASM new file mode 100644 index 0000000..876f9fe --- /dev/null +++ b/LIB386/LIB_SVGA/S_CPYBOX.ASM @@ -0,0 +1,346 @@ + .model SMALL, SYSCALL + + + .code LIB_SVGA + + .386 + jumps + +OSEG equ FS: + + extrn curbk:WORD + extrn newbank:PROC + + +TestSVGA proc uses es ds si di,\ + ptrlog:PTR + + lds si, ptrlog + + xor ax,ax + call newbank + + mov ax,0A000h + mov es,ax + + xor di,di + mov dx,100 + +b1: + mov ecx,80 + rep movsd + + + add di,320 + dec dx + jnz b1 + + mov ax,1 + call newbank + + xor di,di + mov dx,100 + +b2: + mov ecx,80 + rep movsd + + + add di,320 + dec dx + jnz b2 + + ret + +TestSVGA endp + +TestSVGA2 proc uses es ds si di,\ + ptrlog:PTR + + lds si, ptrlog + + xor ax,ax + call newbank + + mov ax,0A000h + mov es,ax + + xor di,di + + mov dx,200 + +b1: + mov bx,di + add bx,320 + jnc ok1 + + mov cx,320 + sub cx,bx + rep movsb + + mov ax, OSEG[curbk] + inc ax + call newbank + + mov cx,bx + rep movsb + + jmp nxt + +ok1: + mov ecx,80 + rep movsd + + +nxt: mov di,bx + add di,320 + + dec dx + jnz b1 + + ret + +TestSVGA2 endp + +opt_stos_line macro + + mov ax,cx + shr ecx, 2 + rep movsd + and ax,3 + mov cx,ax + +;shr cx,1 +;rep movsw +;rcl cx,1 + + rep movsb + + endm + +; CopyBox de MCGA vers SVGA + + +TestSVGA3 proc uses es ds si di,\ + sox:WORD,soy:WORD,sol:WORD,soh:WORD,soptr:PTR,\ + dex:WORD,dey:WORD + + + + lds si, soptr + + mov ax, soy + mov bx,ax + shl ax,2 ; *4 + add ax,bx ; *5 + shl ax,6 ; *320 + add ax, sox + + add si,ax + + + + xor eax,eax + mov ax, dey + mov ebx,eax + shl eax,2 ; *4 + add eax,ebx ; *5 + shl eax,7 ; *640 + + mov bx, dex + add eax,ebx + + mov bx,ax + shr eax,16 ; ax start bank + call newbank + + mov di,bx + xor ebx,ebx + + mov ax,0A000h + mov es,ax + + mov ax, sol + mov cs:word ptr[patch_larg1],ax + mov cs:word ptr[patch_larg2],ax + mov cs:word ptr[patch_larg3],ax + neg ax + add ax,640 + mov cs:word ptr[patch_deoff],ax + + mov ax,320 + sub ax, sol + mov cs:word ptr[patch_sooff],ax + + jmp $+2 + + mov dx, soh + +b1: mov bx,di +patch_larg1 equ $+2 + add bx,1234h + jnc ok1 + +patch_larg2 equ $+1 + mov cx,1234h + sub cx,bx + opt_stos_line + + mov ax, OSEG[curbk] + inc ax + call newbank + + mov cx,bx + opt_stos_line + + jmp nxt + +ok1: xor ecx,ecx +patch_larg3 equ $+1 + mov cx,1234h + opt_stos_line + +nxt: mov di,bx +patch_deoff equ $+2 + add di,1234h + jnc ok2 + + mov ax, OSEG[curbk] + inc ax + call newbank + +ok2: +patch_sooff equ $+2 + add si,1234h + + dec dx + jnz b1 + + + + ret + +TestSVGA3 endp + +; CopyBox de MCGA vers SVGA en incrustation coul 0 + +inc_line macro + local lbl1,lbl2,lbl3 + + jcxz lbl3 +lbl1: lodsb + or al,al + jz lbl2 + stosb + loop lbl1 + jmp short lbl3 +lbl2: inc di + loop lbl1 +lbl3: + endm + + +TestSVGA4 proc uses es ds si di,\ + sox:WORD,soy:WORD,sol:WORD,soh:WORD,soptr:PTR,\ + dex:WORD,dey:WORD + + + + lds si, soptr + + mov ax, soy + mov bx,ax + shl ax,2 ; *4 + add ax,bx ; *5 + shl ax,6 ; *320 + add ax, sox + + add si,ax + + + + xor eax,eax + mov ax, dey + mov ebx,eax + shl eax,2 ; *4 + add eax,ebx ; *5 + shl eax,7 ; *640 + + mov bx, dex + add eax,ebx + + mov bx,ax + shr eax,16 ; ax start bank + call newbank + + mov di,bx + xor ebx,ebx + + mov ax,0A000h + mov es,ax + + mov ax, sol + mov cs:word ptr[patch_larg1b],ax + mov cs:word ptr[patch_larg2b],ax + mov cs:word ptr[patch_larg3b],ax + neg ax + add ax,640 + mov cs:word ptr[patch_deoffb],ax + + mov ax,320 + sub ax, sol + mov cs:word ptr[patch_sooffb],ax + + jmp $+2 + + mov dx, soh + +b1: mov bx,di +patch_larg1b equ $+2 + add bx,1234h + jnc ok1 + +patch_larg2b equ $+1 + mov cx,1234h + sub cx,bx + inc_line + + mov ax, OSEG[curbk] + inc ax + call newbank + + mov cx,bx + inc_line + + jmp nxt + +ok1: xor ecx,ecx +patch_larg3b equ $+1 + mov cx,1234h + inc_line + +nxt: mov di,bx +patch_deoffb equ $+2 + add di,1234h + jnc ok2 + + mov ax, OSEG[curbk] + inc ax + call newbank + +ok2: +patch_sooffb equ $+2 + add si,1234h + + dec dx + jnz b1 + + + + ret + +TestSVGA4 endp + + + + end diff --git a/LIB386/LIB_SVGA/S_DLL.C b/LIB386/LIB_SVGA/S_DLL.C new file mode 100644 index 0000000..f2c873d --- /dev/null +++ b/LIB386/LIB_SVGA/S_DLL.C @@ -0,0 +1,57 @@ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + SAMP.C 386 + (c) Adeline 1993 + *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include +#include +#include +#include + +extern void *NewBank; +extern void *InitSvgaMode; +extern void *Enable; + +char *SvgaError = "Error SvgaDriver:"; + +/*-------------------------------------------------------------------------*/ +LONG SvgaInitDLL(char *driverpathname) +{ + char *dll, *drvr; + void **funcs; + + // + // Load driver file + // + + dll = FILE_read(driverpathname, NULL); + if (dll==NULL) + { + printf("%s Could not load driver '%s'.\n", SvgaError, driverpathname ); + return FALSE ; + } + + drvr = DLL_load(dll, DLLMEM_ALLOC | DLLSRC_MEM, NULL); + + Free(dll); + + if (drvr==NULL) + { + printf("%s Invalid DLL image.\n", SvgaError ); + return FALSE ; + } + + funcs = *(void ***)drvr; + + InitSvgaMode = funcs[0]; + NewBank = funcs[1]; + Enable = funcs[2]; + + printf("%s", drvr+4); + + return TRUE; +} + +/*-------------------------------------------------------------------------*/ diff --git a/LIB386/LIB_SVGA/S_FILLV.ASM b/LIB386/LIB_SVGA/S_FILLV.ASM new file mode 100644 index 0000000..c96de53 --- /dev/null +++ b/LIB386/LIB_SVGA/S_FILLV.ASM @@ -0,0 +1,1118 @@ +;---------------------------------------------------------------------------- +; S_FILLV.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386P + jumps + .model FLAT, SYSCALL + .data + + include \projet\lib386\lib_svga\svga.ash + + extrn NoLanguage TabVerticG :WORD + extrn NoLanguage TabCoulG :WORD + extrn NoLanguage Ymin :WORD + extrn NoLanguage Ymax :WORD + +ALIGN 4 + +Save1 dd 0000 +newloop dd 0000 + +MAX_TYPE_POLY equ 9 + +TabJumpPoly dd SVGAPolyTriste ;S + dd SVGAPolyTele + dd SVGAPolyCopper + dd SVGAPolyBopper + dd SVGAPolyMarbre + dd SVGAPolyTrans + dd SVGAPolyTrame + dd SVGAPolyGouraud + dd SVGAPolyDith + +TabPoly_0 dd SVGAPolyTriste ;S + dd SVGAPolyTriste ;S + dd SVGAPolyCopper + dd SVGAPolyBopper + dd SVGAPolyMarbre + dd SVGAPolyTrans + dd SVGAPolyTrame + dd SVGAPolyTriche + dd SVGAPolyTriche + +TabPoly_1 dd SVGAPolyTriste ;S + dd SVGAPolyTele + dd SVGAPolyCopper + dd SVGAPolyBopper + dd SVGAPolyMarbre + dd SVGAPolyTrans + dd SVGAPolyTrame + dd SVGAPolyGouraud + dd SVGAPolyGouraud + +TabPoly_2 dd SVGAPolyTriste ;S + dd SVGAPolyTele + dd SVGAPolyCopper + dd SVGAPolyBopper + dd SVGAPolyMarbre + dd SVGAPolyTrans + dd SVGAPolyTrame + dd SVGAPolyGouraud + dd SVGAPolyDith + +;---------------------------------------------------------------------------- + .code + + public NoLanguage FillVertic + public NoLanguage FillVertic_A + public NoLanguage SetFillDetails + +;---------------------------------------------------------------------------- + + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +FillVertic proc uses esi edi ebx ebp,\ + typepoly:DWORD, coulpoly:DWORD + + mov ecx, typepoly + mov edi, coulpoly + + call FillVertic_A + + ret +FillVertic endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +SetFillDetails proc uses esi edi,\ + level:DWORD + + mov eax, level + cmp eax, 2 + jbe ok + mov eax, 2 +ok: imul eax, MAX_TYPE_POLY*4 + mov edi, offset TabJumpPoly + mov esi, offset TabPoly_0 + add esi, eax + mov ecx, MAX_TYPE_POLY + rep movsd + ret + +SetFillDetails endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ; cx type polygone + ; di coul polygone + +FillVertic_A proc + + xor eax, eax + xor edx, edx + mov ax, [Ymin] + mov dx, [Ymax] + + mov ebp, [Log] + add ebp, TabOffLine[eax*4] + + lea esi, TabVerticG[eax*2] + lea ebx, TabCoulG[eax*2] + + sub edx, eax ; delta Y + inc edx + + mov eax, edi ; coul + + ; EAX coul(s) + ; EBP debut 1 ere ligne + ; EDX delta Y + ; ESI TabVerticG + ; EBX TabCoulG + + jmp dword ptr TabJumpPoly[ecx*4] + +FillVertic_A endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ßßÛßß ÛßßßÛ Û ÛÛßßß ßßÛßß Ûßßßß +; ÛÛ ÛÛßÛß ÛÛ ßßßßÛ ÛÛ ÛÛßß +; ßß ßß ß ßß ßßßßß ßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +comment @ + +SVGAPolyTristeS proc + + ; al coul + + mov bl, al + +blig: xor ecx, ecx + xor eax, eax + mov cx, word ptr[esi+960] ; xD + mov ax, [esi] + add esi, 2 ; XG + + sub ecx, eax ; cx = DeltaX + jc nextlig + inc ecx + + mov edi, ebp ; Debut Ligne ecran + add edi, eax ; Debut Line + + mov al, bl + rep stosb + +nextlig: add ebp, 640 + dec dx + jnz blig + + ret + +SVGAPolyTristeS endp + + @ + +SVGAPolyTriste proc + + ; al coul + + mov ah, al + mov bx, ax + shl eax, 16 + mov ax, bx + + xor ecx, ecx + xor ebx, ebx + +blig: mov cx, word ptr[esi+960] ; xD + mov bx, word ptr[esi] ; XG + add esi, 2 + + sub cx, bx ; cx = DeltaX + jc nextlig + inc cx + + lea edi, [ebp+ebx] ; Debut Ligne ecran + Debut Line + + mov bl, cl + shr ecx, 2 + rep stosd + + mov cl, bl + and cl, 3 + rep stosb + +nextlig: add ebp, 640 + dec edx + jnz blig + + ret + +SVGAPolyTriste endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Ûßßßß ÛßßßÛ ÛßßßÛ ÛßßßÛ Ûßßßß ÛßßßÛ +; ÛÛ ÛÛ Û ÛÛßßß ÛÛßßß ÛÛßß ÛÛßÛß +; ßßßßß ßßßßß ßß ßß ßßßßß ßß ß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +SVGAPolyCopper proc + + ; AL couleur + + mov bl,al ; coul + xor ecx, ecx + +blig: xor eax, eax + mov cx, [esi+960] ; xD + mov ax, [esi] ; xG + add esi, 2 + + sub cx, ax ; cx = DeltaX + jc sensdown + inc cx + + lea edi, [ebp+eax] ; Debut Ligne ecran + Debut Line + + mov bh, bl + mov ax, bx + shl eax, 16 + mov ax, bx + + test edi, 1 + jz aligne + mov byte ptr[edi], al + inc edi + dec ecx +aligne: mov bh, cl + shr ecx, 2 ; By Word + rep stosd + mov cl, bh + and cl, 2 + rep stosb + + inc bl + test bl, 15 + jz sensup + +sensdown: add ebp, 640 + dec edx + jnz blig + + ret + +;------------------------------------------------ + +blig2: xor eax, eax + mov cx, [esi+960] ; xD + mov ax, [esi] ; xG + add esi, 2 + + sub cx, ax ; cx = DeltaX + jc sensup + inc cx + + lea edi, [ebp+eax] ; Debut Ligne ecran + Debut Line + + mov bh, bl + mov ax, bx + shl eax, 16 + mov ax, bx + + test edi,1 + jz aligne1 + mov byte ptr[edi], al + inc edi + dec ecx +aligne1: mov bh, cl + shr ecx, 2 ; By Word + rep stosd + mov cl, bh + and cl, 2 + rep stosb + +sensup: dec bl + test bl, 15 + jz sensdown + + add ebp, 640 + dec edx + jnz blig2 + +fin_poly: ret + +SVGAPolyCopper endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßÛ Û Ûßßßß Ûßßßß ÛßßßÛ ÛßßßÛ ÛßßßÛ Ûßßßß ÛßßßÛ +; ÛÛßßÛ ÛÛ ÛÛ ßÛ ÛÛ ÛÛ Û ÛÛßßß ÛÛßßß ÛÛßß ÛÛßÛß +; ßßßßß ßß ßßßßß ßßßßß ßßßßß ßßßßß ßß ßß ßßßßß ßß ß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +SVGAPolyBopper proc + + mov bl, al + mov bh, 2 + +blig: xor ecx, ecx + xor eax, eax + mov cx,word ptr[esi+960] ; xD + mov ax, [esi] + add esi, 2 ; xG + + sub ecx, eax ; cx = DeltaX + jc sensdown + inc ecx + + mov edi, ebp ; Debut Ligne ecran + add edi, eax ; Debut Line + + mov al, bl + mov ah, bl + + test edi, 1 + jz aligne + mov byte ptr[edi], al + inc edi + dec ecx +aligne: shr ecx, 1 ; By Word + rep stosw + rcl ecx, 1 + rep stosb + + dec bh + jnz sensdown + mov bh, 2 + inc bl + test bl, 15 + jz sensup + +sensdown: add ebp, 640 + dec edx + jnz blig + + ret + +;----------------------------------------------- + +blig2: xor ecx, ecx + xor eax, eax + mov cx,word ptr[esi+960] ; xD + mov ax, [esi] + add esi, 2 ; xG + + sub ecx, eax ; cx = DeltaX + jc sensup + inc ecx + + mov edi, ebp ; Debut Ligne ecran + add edi, eax ; Debut Line + + mov al, bl + mov ah, bl + + test edi, 1 + jz aligne1 + mov byte ptr[edi], al + inc edi + dec ecx +aligne1: shr ecx, 1 ; By Word + rep stosw + rcl ecx, 1 + rep stosb + + dec bh + jnz plusloin +sensup: mov bh, 2 + dec bl + test bl, 15 + jz sensdown + +plusloin: add ebp, 640 + dec edx + jnz blig2 + +fin_poly: ret + +SVGAPolyBopper endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÜ ÜÛ ÛßßßÛ ÛßßßÛ ÛßßÛ ÛßßßÛ Ûßßßß +; ÛÛß Û ÛÛßßÛ ÛÛßÛß ÛÛßßÛ ÛÛßÛß ÛÛßß +; ßß ß ßß ß ßß ß ßßßßß ßß ß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +SVGAPolyMarbre proc + + ; ax 2 couls: al start ah end + + mov bx, ax + shl ebx, 16 + + mov [newloop], edx ; delta Y +blig0: +; push ecx + + xor ecx, ecx + xor eax, eax + mov cx, word ptr[esi+960] ; xD + mov ax, [esi] + add esi, 2 ; xG + + sub ecx, eax + jz justone + jc nextlig + inc ecx ; CX deltax + + shld edi, ebx, 16 + mov bx, di + + mov edi, ebp + add edi, eax ; offset lig + x min + + mov ah, bh ; AH = intensite 2 + shl bx, 8 ; BH = intensite 1 et BL = 0 + mov al, bl ; Maz AL + + sub ax, bx ; delta intensite + + inc ax + cwd + idiv cx ; AX step intensite + + xchg al, ah + mov dx, ax ; DX step intensite + + mov al, bh ; AL intensite start + + inc ecx + shr ecx, 1 + jnc xloop1 + clc ; init Carry + EVEN +xloop: mov byte ptr[edi], al + inc edi + adc ax, dx ; cumul step +xloop1: mov byte ptr[edi], al + inc edi + adc ax, dx ; cumul step + dec ecx + jnz xloop + +nextlig: +; pop ecx + add ebp, 640 + dec dword ptr[newloop] + jnz blig0 + + ret + +justone: mov edi, ebp + add edi, eax ; offset lig + x min + mov eax, ebx + shr eax, 16+8 + mov byte ptr[edi], al + inc edi +; pop ecx + add ebp, 640 + + dec dword ptr[newloop] + jnz blig0 + + ret + +SVGAPolyMarbre endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ Û Ûßßßß ÛßßßÛ ÛßßßÛ Ûßßßß +; ÛÛßßß ÛÛ ÛÛßß ÛÛßÛß ÛÛßÛß ÛÛßß +; ßß ßß ßßßßß ßß ß ßß ß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +SVGAPolyTele proc + + mov [newloop], edx ; ecx = delta + mov dl, al ; DL = couleur + mov dh, 3 ; Pour AND + mov bx, 17371 + + EVEN +blig: +; push ecx + xor ecx, ecx + xor eax, eax + mov cx, word ptr[esi+960] ; xD + mov ax, [esi] + add esi, 2 ; xG + + sub ecx, eax ; cx = DeltaX + jc nextlig + inc ecx + + mov edi, ebp ; Debut Ligne ecran + add edi, eax ; Debut Line + + inc ecx + shr ecx, 1 + jnc bcol1 + EVEN +bcol: add ax, bx + and al, dh + add al, dl + mov byte ptr[edi], al + inc edi + rol bx, 2 + inc bx +bcol1: add ax, bx + and al, dh + add al, dl + mov byte ptr[edi], al + inc edi + rol bx, 2 + inc bx + dec ecx + jnz bcol + +nextlig: add ebp, 640 ; lig++ +; pop ecx + dec dword ptr[newloop] + jnz blig + + ret + +SVGAPolyTele endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ßßÛßß ÛßßßÛ ÛßßßÛ ÛÛÜ Û ÛÛßßß ÛßßßÛ ÛßßßÛ ÛßßßÛ Ûßßßß ÛÛÜ Û ßßÛßß +; ÛÛ ÛÛßÛß ÛÛßßÛ ÛÛßÛÛ ßßßßÛ ÛÛßßß ÛÛßßÛ ÛÛßÛß ÛÛßß ÛÛßÛÛ ÛÛ +; ßß ßß ß ßß ß ßß ß ßßßßß ßß ßß ß ßß ß ßßßßß ßß ß ßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +SVGAPolyTrans proc + + and al, 0F0h ; AL = couleur & 0xF0 + mov bl, al ; BL BH = newcouleur + mov bh, al + xor eax, eax + +blig: mov cx, word ptr[esi+960] ; xD + mov ax, [esi] ; xG + add esi, 2 + + sub cx, ax ; cx = DeltaX + jc boul ; neg => next line + inc cx + + lea edi, [ebp+eax] ; Debut Ligne ecran + Debut Line + + shr cx, 1 + jnc bcol + + mov al, [edi] + and al, 0Fh + or al, bl + mov [edi], al + + or cx, cx ; anymore ? + jz boul + + inc edi + +bcol: mov ax, [edi] + and ax, 0F0Fh + or ax, bx + mov [edi], ax + add edi, 2 + dec cx + jnz bcol +boul: + add ebp, 640 ; lig++ + dec edx + jnz blig + + ret + +SVGAPolyTrans endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ßßÛßß ÛßßßÛ ÛßßßÛ ÛÜ ÜÛ Ûßßßß +; ÛÛ ÛÛßÛß ÛÛßßÛ ÛÛß Û ÛÛßß +; ßß ßß ß ßß ß ßß ß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +SVGAPolyTrame proc + + mov bl, al ; BL = couleur + xor bh, bh + xor eax, eax + EVEN +blig: mov cx, word ptr[esi+960] ; xD + mov ax, [esi] ; xG + add esi, 2 + + sub cx, ax ; cx = DeltaX + jc nextlig + inc cx + + lea edi, [ebp+eax] ; Debut Ligne ecran + Debut Line + + shr cx, 1 ; /2 + jz nextlig + + xor bh, 1 ; paire/impair + mov ax, di + and ax, 1 + xor al, bh + jz paire + inc edi +paire: + mov al, bl + + inc cx + shr cx, 1 + jnc bcol1 + EVEN +bcol: mov byte ptr[edi], al + add edi, 2 +bcol1: mov byte ptr[edi], al + add edi, 2 + dec cx + jnz bcol + +nextlig: add ebp, 640 ; lig++ + dec edx + jnz blig + + ret + +SVGAPolyTrame endp + + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Ûßßßß ÛßßßÛ Û Û ÛßßßÛ ÛßßßÛ Û Û ÛßßßÜ +; ÛÛ ßÛ ÛÛ Û ÛÛ Û ÛÛßÛß ÛÛßßÛ ÛÛ Û ÛÛ Û +; ßßßßß ßßßßß ßßßßß ßß ß ßß ß ßßßßß ßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +SVGAPolyTriche proc + + xor ecx, ecx + xor eax, eax + +blig: mov cx, [esi+960] ; xD + mov ax, [esi] ; XG + add esi, 2 + + sub cx, ax ; cx = DeltaX + jc nextlig + inc ecx + + lea edi, [ebp+eax] ; Debut Ligne ecran + Debut Line + + mov al, [ebx+1] ; intensite 1 *256: F.f + add ebx, 2 + + rep stosb + +nextlig: add ebp, 640 + dec dx + jnz blig + + ret + +SVGAPolyTriche endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +comment @ + +SVGAPolyGouraudS proc + + mov [newloop], edx ; delta Y + EVEN +blig0: +; push ecx + + xor ecx, ecx + xor eax, eax + mov cx, word ptr [esi+960] ; xD + mov ax, [esi] + add esi, 2 ; xG + + mov edi, ebp ; offset lig + x min + add edi, eax ; col start + + sub ecx, eax ; ECX delta x + jz l0 + jc nextlig + + mov ax, [ebx+960] ; intensite 2 *256: F.f + mov dx, [ebx] ; intensite 1 *256: F.f + sub ax, dx ; delta intensite + jc GouraudInverse + +gouraud: xor dx, dx + div cx ; AX step intensite + + xchg dx, ax ; DX step intensite, AX reste + xchg dl, dh ; inverse pour addition + shr ax, 1 + add ax, [ebx] ; intensite 1 start + reste + xchg al, ah ; inverse pour coul dans AL + inc ebx + inc ebx + + inc ecx + add ah, dh ; init Carry + EVEN +xloop: mov byte ptr[edi], al + inc edi + adc ax, dx ; cumul step + dec ecx + jnz xloop + +nextlig: +; pop ecx + add ebp, 640 + dec dword ptr[newloop] + jnz blig0 + + ret + +GouraudNormal: neg ax + jmp short gouraud + +l0: mov al, [ebx+961] + add ebx, 2 + mov byte ptr[edi], al + inc edi +; pop ecx + add ebp, 640 + dec dword ptr[newloop] + jnz blig0 + ret + +GouraudInverse: neg ax + jmp short igouraud + +il0: mov al, [ebx+961] + add ebx, 2 + mov byte ptr[edi], al + inc edi +; pop ecx + add ebp, 640 + dec dword ptr[newloop] + jnz iblig0 + ret + + EVEN +iblig0: ; push ecx + + xor ecx, ecx + xor eax, eax + mov cx, word ptr [esi+960] ; xD + mov ax, [esi] + add esi, 2 ; xG + + mov edi, ebp ; offset lig + x min + add edi, eax ; col start + + sub ecx, eax ; ECX delta x + jz il0 + jc inextlig + + mov dx, [ebx+960] ; intensite 2 *256: F.f + mov ax, [ebx] ; intensite 1 *256: F.f + sub ax, dx ; delta intensite + jc GouraudNormal +igouraud: xor dx, dx + div cx ; AX step intensite + + xchg dx, ax ; DX step intensite, AX reste + xchg dl, dh ; inverse pour addition + shr ax, 1 ; + neg ax ; - reste / 2 + add ax, [ebx] ; intensite 1 start + reste + xchg al, ah ; inverse pour coul dans AL + add ebx, 2 + + inc ecx + sub ah, dh ; init Carry + EVEN +ixloop: mov byte ptr[edi], al + inc edi + sbb ax, dx ; cumul step + dec ecx + jnz ixloop + +inextlig: ; pop ecx + add ebp, 640 + dec dword ptr[newloop] + jnz iblig0 + + ret + +SVGAPolyGouraudS endp + + @ + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +SVGAPolyGouraud proc + + mov [newloop], edx ; delta Y + xor eax, eax + xor ecx, ecx + xor edx, edx + +blig0: mov cx, [esi+960] ; xD + mov ax, [esi] ; xG + add esi, 2 + + lea edi, [ebp+eax] ; offset lig + x min + col start + + sub cx, ax ; CX delta x + mov ax, [ebx+960] ; intensite 2 *256: F.f + mov dx, [ebx] ; intensite 1 *256: F.f + jz l0 + jc nextlig + + sub ax, dx + jc GouraudInverse ; delta intensite + + cmp cx, 2 + jbe opt + +gouraud: xor dx, dx + div cx ; AX step intensite + + mov dx, [ebx] ; intensite 1 start + add ebx, 2 + + inc cx + shr cx, 1 ; divise par 2 + jnc start ; impair ? + mov byte ptr[edi], dh + jz nextlig + inc edi + jmp start2 + ALIGN 4 +xloop: add edi, 2 +start2: add dx, ax ; cumul step +start: mov [edi], dh + add dx, ax ; cumul step + mov [edi+1], dh + dec cx + jnz xloop + +nextlig: add ebp, 640 + dec dword ptr[newloop] + jnz blig0 + + ret + +GouraudNormal: cmp cx, 2 + jbe opt0 + neg ax + jmp short gouraud + +opt0: mov dx, [ebx] +opt: mov ax, [ebx+960] + add ebx, 2 + mov [edi+ecx], ah + dec cx + jz opt2 + add eax, edx + shr eax, 1 + mov [edi+1], ah +opt2: mov [edi], dh + add ebp, 640 + dec dword ptr[newloop] + jnz blig0 + + ret + +l0: add eax, edx + add ebx, 2 + shr eax, 1 + add ebp, 640 + mov [edi], ah + dec dword ptr[newloop] + jnz blig0 + + ret + +GouraudInverse: cmp cx, 2 + jbe iopt0 + neg ax + jmp short igouraud + +iopt0: mov dx, [ebx+960] +iopt: mov ax, [ebx] + add ebx, 2 + mov [edi+ecx], dh + dec cx + jz iopt2 + add edx, eax + shr edx, 1 + mov [edi+1], dh +iopt2: mov [edi], ah + add ebp, 640 + dec dword ptr[newloop] + jnz iblig0 + + ret + +il0: add eax, edx + add ebx, 2 + shr eax, 1 + add ebp, 640 + mov [edi], ah + dec dword ptr[newloop] + jnz iblig0 + + ret + + ALIGN 4 +iblig0: + mov cx, [esi+960] ; xD + mov ax, [esi] ; xG + add esi, 2 + + lea edi, [ebp+eax] ; offset lig + x min + col start + + sub cx, ax ; CX delta x + mov ax, [ebx] ; intensite 1 *256: F.f + mov dx, [ebx+960] ; intensite 2 *256: F.f + jz il0 + jc inextlig + + sub ax, dx + jc GouraudNormal ; delta intensite + + cmp cx, 2 + jbe iopt + +igouraud: xor dx, dx + div cx ; AX step intensite + + mov dx, [ebx] ; intensite 1 start + add ebx, 2 + + inc cx + shr cx, 1 ; divise par 2 + jnc istart ; impair ? + mov byte ptr[edi], dh + jz nextlig + inc edi + jmp istart2 + ALIGN 4 +ixloop: add edi, 2 +istart2: sub dx, ax ; cumul step +istart: mov [edi], dh + sub dx, ax ; cumul step + mov [edi+1], dh + dec cx + jnz ixloop + +inextlig: add ebp, 640 + dec dword ptr[newloop] + jnz iblig0 + + ret + +SVGAPolyGouraud endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÜ Û ßßÛßß Û Û Ûßßßß ÛßßßÛ Û ÛÛÜ Û Ûßßßß +; ÛÛ Û ÛÛ ÛÛ ÛÛßßÛ ÛÛßß ÛÛßÛß ÛÛ ÛÛßÛÛ ÛÛ ßÛ +; ßßßß ßß ßß ßß ß ßßßßß ßß ß ßß ßß ß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +SVGAPolyDith proc + + mov [newloop], edx ; delta Y + xor eax, eax + +blig0: mov cx, word ptr [esi+960] ; xD + mov ax, [esi] ; xG + add esi, 2 + + + sub cx, ax ; cx = delta X + jc nextlig + + lea edi, [ebp + eax] ; offset lig + x min + col start + mov [Save1], esi + mov ax, [ebx+960] ; intensite 2 + mov si, [ebx] ; intensite 1 + + jz cx0 + + add ebx, 2 + sub ax, si ; delta intensite + + cmp cx, 2 + jbe opt + + cwd + idiv cx ; AX step intensite + + mov dx, si + + inc cx + shr cx, 1 + jnc start + + xor dh, dh + rol dl, cl + add dx, si + or cx, cx + mov [edi], dh + jz endloop + inc edi + jmp start2 + + ALIGN 4 +xloop: add edi, 2 +start2: add si, ax +start: xor dh, dh + add dx, si + mov [edi], dh ; start + xor dh, dh + add si, ax + rol dl, cl + add dx, si + dec cx + mov [edi+1], dh + jnz xloop +endloop: + mov esi, [Save1] +nextlig: + add ebp, 640 + dec dword ptr[newloop] + jnz blig0 + + ret + +cx0: add ax, si + mov esi, [Save1] + rcr ax, 1 + add ebx, 2 + mov [edi], ah + add ebp, 640 + dec dword ptr[newloop] + jnz blig0 + + ret + +opt: inc cx + mov dx, si + shr cx, 1 + jnc two + + xor dh, dh + sar ax, 1 + rol dl, cl + inc edi + add dx, si + mov [edi-1], dh + add si, ax +two: + xor dh, dh + add dx, si + mov [edi], dh + xor dh, dh + add si, ax + rol dl, cl + add ebp, 640 + add dx, si + mov esi, [Save1] + mov [edi+1], dh + dec dword ptr[newloop] + jnz blig0 + + ret + +SVGAPolyDith endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; The + End + + + + + diff --git a/LIB386/LIB_SVGA/S_FIND.ASM b/LIB386/LIB_SVGA/S_FIND.ASM new file mode 100644 index 0000000..5d11bee --- /dev/null +++ b/LIB386/LIB_SVGA/S_FIND.ASM @@ -0,0 +1,1567 @@ + + .model SMALL, SYSCALL + + include vesa.inc +; +; VGAKIT Version 5.2b +; +; Copyright 1988,89,90,91,92 John Bridges +; Free for use in commercial, shareware or freeware applications +; +; BANKS.ASM +; + .data + + public curbk + +curbk dw ? + + public vgamem,bksize + +vgamem dw ? ;amount of memory on VGA card in K +bksize dw ? ;size of memory banks in K + + public cirrus,everex,acumos,paradise,tseng,trident,t8900 + public ativga,aheada,aheadb,oaktech,video7 + public chipstech,tseng4,genoa,ncr,compaq,vesa,dactype + +cirrus dw ? +everex dw ? +acumos dw ? +paradise dw ? +tseng dw ? +trident dw ? +t8900 dw ? +ativga dw ? +aheada dw ? +aheadb dw ? +oaktech dw ? ;Oak Technology Inc OTI-067 and OTI-077 +video7 dw ? +chipstech dw ? +tseng4 dw ? +genoa dw ? +ncr dw ? +compaq dw ? +vesa dw ? + +dactype dw ? ; 0 = Normal DAC + ; 1 = Sierra SC11481, SC11486, SC11488 + ; 2 = Sierra SC11485, SC11487, SC11489 + ; 3 = AT&T ATT20C491 + ; 4 = ACUMOS ADAC1 + +first dw ? ;flag so whichvga() is only called once +retval dw ? ;first return value from whichvga() + + .data + + .386 +OSEG equ FS: ;segment override for variable access + + public bankadr + +bankadr dw offset _nobank + dw seg _nobank + + public vesafunc + +vesafunc dw 0 + dw 0 + +vesamodes label word + dw 100h, 640, 400, 8 + dw 101h, 640, 480, 8 + dw 102h, 800, 600, 4 + dw 103h, 800, 600, 8 + dw 104h, 1024, 768, 4 + dw 105h, 1024, 768, 8 + dw 106h, 1280,1024, 4 + dw 107h, 1280,1024, 8 + dw 10Dh, 320, 200,16 + dw 10Eh, 320, 200,16 + dw 10Fh, 320, 200,24 + dw 110h, 640, 480,16 + dw 111h, 640, 480,16 + dw 112h, 640, 480,24 + dw 113h, 800, 600,16 + dw 114h, 800, 600,16 + dw 115h, 800, 600,24 + dw 116h, 1024, 768,16 + dw 117h, 1024, 768,16 + dw 118h, 1024, 768,24 + dw 119h, 1280,1024,16 + dw 11Ah, 1280,1024,16 + dw 11Bh, 1280,1024,24 + dw 0 + + .code LIB_SVGA + + public newbank + public whichvga + + .386 + +newbank proc ;bank number is in AX + jmp dword ptr OSEG[bankadr] + +_tseng:: ;Tseng 3000 series + push ax + push dx + cli + mov OSEG[curbk],ax + and al,7 + mov ah,al + shl al,1 + shl al,1 + shl al,1 + or al,ah + or al,01000000b + mov dx,3cdh + out dx,al + sti + pop dx + pop ax + ret + + +_tseng4:: ;Tseng 4000 series + push ax + push dx + cli + mov OSEG[curbk],ax + mov ah,al + mov dx,3bfh ;Enable access to extended registers + mov al,3 + out dx,al + mov dl,0d8h + mov al,0a0h + out dx,al + and ah,15 + mov al,ah + shl al,1 + shl al,1 + shl al,1 + shl al,1 + or al,ah + mov dl,0cdh + out dx,al + sti + pop dx + pop ax + ret + + +_trident:: ;Trident + push ax + push dx + push ax + cli + mov OSEG[curbk],ax + mov dx,3ceh ;set pagesize to 64k + mov al,6 + out dx,al + inc dl + in al,dx + dec dl + or al,4 + mov ah,al + mov al,6 + out dx,ax + + mov dl,0c4h ;switch to BPS mode + mov al,0bh + out dx,al + inc dl + in al,dx + dec dl + + pop ax + mov ah,al + xor ah,2 + mov dx,3c4h + mov al,0eh + out dx,ax + sti + pop dx + pop ax + ret + + +_video7:: ;Video 7 + push ax + push dx + push cx + cli + mov OSEG[curbk],ax + and ax,15 + mov ch,al + mov dx,3c4h + mov ax,0ea06h + out dx,ax + mov ah,ch + and ah,1 + mov al,0f9h + out dx,ax + mov al,ch + and al,1100b + mov ah,al + shr ah,1 + shr ah,1 + or ah,al + mov al,0f6h + out dx,al + inc dx + in al,dx + dec dx + and al,not 1111b + or ah,al + mov al,0f6h + out dx,ax + mov ah,ch + mov cl,4 + shl ah,cl + and ah,100000b + mov dl,0cch + in al,dx + mov dl,0c2h + and al,not 100000b + or al,ah + out dx,al + sti + pop cx + pop dx + pop ax + ret + + +_paradise:: ;Paradise + push ax + push dx + push ax + cli + mov OSEG[curbk],ax + mov dx,3ceh + mov ax,50fh ;turn off write protect on VGA registers + out dx,ax + pop ax + mov ah,al + mov al,9 + out dx,ax + sti + pop dx + pop ax + ret + +_acumos:: ;AcuMos + push ax + push dx + push ax + cli + mov OSEG[curbk],ax + mov dx,3c4h ;Sequencer index 6 + mov ax,1206h ;turn off write protect on VGA registers + out dx,ax + mov dx,3ceh + pop ax + mov ah,al + mov al,9 + out dx,ax + sti + pop dx + pop ax + ret + + +_chipstech:: ;Chips & Tech + push ax + push dx + push ax + cli + mov OSEG[curbk],ax + mov dx,46e8h ;place chip in setup mode + mov ax,1eh + out dx,ax + mov dx,103h ;enable extended registers + mov ax,0080h + out dx,ax + mov dx,46e8h ;bring chip out of setup mode + mov ax,0eh + out dx,ax + pop ax + mov ah,al + mov al,10h + mov dx,3d6h + out dx,ax + sti + pop dx + pop ax + ret + + +_ativga:: ;ATI VGA Wonder + push ax + push dx + cli + mov OSEG[curbk],ax + mov ah,al + mov dx,1ceh + mov al,0b2h + out dx,al + inc dl + in al,dx + shl ah,1 + and al,0e1h + or ah,al + mov al,0b2h + dec dl + out dx,ax + sti + pop dx + pop ax + ret + + +_everex:: ;Everex + push ax + push dx + push cx + cli + mov OSEG[curbk],ax + mov cl,al + mov dx,3c4h + mov al,8 + out dx,al + inc dl + in al,dx + dec dl + shl al,1 + shr cl,1 + rcr al,1 + mov ah,al + mov al,8 + out dx,ax + mov dl,0cch + in al,dx + mov dl,0c2h + and al,0dfh + shr cl,1 + jc nob2 + or al,20h +nob2: out dx,al + sti + pop cx + pop dx + pop ax + ret + + +_aheada:: ;Ahead Systems Ver A + push ax + push dx + push cx + cli + mov OSEG[curbk],ax + mov ch,al + mov dx,3ceh ;Enable extended registers + mov ax,200fh + out dx,ax + mov dl,0cch ;bit 0 + in al,dx + mov dl,0c2h + and al,11011111b + shr ch,1 + jnc skpa + or al,00100000b +skpa: out dx,al + mov dl,0cfh ;bits 1,2,3 + mov al,0 + out dx,al + inc dx + in al,dx + dec dx + and al,11111000b + or al,ch + mov ah,al + mov al,0 + out dx,ax + sti + pop cx + pop dx + pop ax + ret + + +_aheadb:: ;Ahead Systems Ver A + push ax + push dx + push cx + cli + mov OSEG[curbk],ax + mov ch,al + mov dx,3ceh ;Enable extended registers + mov ax,200fh + out dx,ax + mov ah,ch + mov cl,4 + shl ah,cl + or ah,ch + mov al,0dh + out dx,ax + sti + pop cx + pop dx + pop ax + ret + + +_oaktech:: ;Oak Technology Inc OTI-067 and OTI-077 + push ax + push dx + cli + mov OSEG[curbk],ax + and al,15 + mov ah,al + shl al,1 + shl al,1 + shl al,1 + shl al,1 + or ah,al + mov al,11h + mov dx,3deh + out dx,ax + sti + pop dx + pop ax + ret + +_genoa:: ;GENOA GVGA + push ax + push dx + cli + mov OSEG[curbk],ax + mov ah,al + shl al,1 + shl al,1 + shl al,1 + or ah,al + mov al,6 + or ah,40h + mov dx,3c4h + out dx,ax + sti + pop dx + pop ax + ret + +_ncr:: ;NCR 77C22E + push ax + push dx + cli + mov OSEG[curbk],ax + mov ah,al + mov al,18h + mov dx,3c4h + out dx,ax + mov ax,19h + out dx,ax + sti + pop dx + pop ax + ret + +_compaq:: ;Compaq + push ax + push dx + push ax + cli + mov OSEG[curbk],ax + mov dx,3ceh + mov ax,50fh ;unlock extended registers + out dx,ax + pop ax + mov ah,al + mov al,45h + out dx,ax + sti + pop dx + pop ax + ret + +_vesa:: ;Vesa SVGA interface + push ax + push bx + push dx + cli + mov OSEG[curbk],ax + mov dx,ax + xor bx,bx + call dword ptr OSEG[vesafunc] + mov dx,OSEG[curbk] + mov bx,1 + call dword ptr OSEG[vesafunc] + sti + pop dx + pop bx + pop ax + ret + +_nobank:: + cli + mov OSEG[curbk],ax + sti + ret + +newbank endp + +bkadr macro func + mov [func],1 + mov word ptr [bankadr],offset _&func + mov word ptr [bankadr+2],seg _&func + endm + +nojmp macro + local lbl + jmp lbl +lbl: + endm + +dummyvesa proc far + ret +dummyvesa endp + + + + + + + + + + + +whichvga proc uses si di es ds + local vesabuf[512]:byte ; extra large to make up for + ; bugs in some VESA VBE's + + cmp [first],'FI' + jnz gotest + mov ax,[retval] + ret + + + + + + + +gotest: mov word ptr [bankadr],offset _nobank + mov word ptr [bankadr+2],seg _nobank + + + mov [vgamem],256 + mov [bksize],64 + xor ax,ax + mov [curbk],ax + mov [cirrus],ax + mov [everex],ax + mov [paradise],ax + mov [tseng],ax + mov [trident],ax + mov [t8900],ax + mov [ativga],ax + mov [aheada],ax + mov [aheadb],ax + mov [oaktech],ax + mov [video7],ax + mov [chipstech],ax + mov [tseng4],ax + mov [genoa],ax + mov [ncr],ax + mov [compaq],ax + mov [vesa],ax + mov [dactype],ax + mov [first],'FI' + + + + + + + mov si,1 ;flag for SVGA found + + + + + mov ax,ss + mov es,ax + lea di,vesabuf[0] + mov ax,4f00h + int 10h + cmp ax,4fh +;— + jnz novesa + + mov [bksize],64 ; (for now) + mov [vesafunc],offset dummyvesa + mov [vesafunc+2],cs + bkadr vesa + mov si,offset vesamodes + cld +vesalp: lodsw + mov cx,ax + jcxz endvesa + mov ax,ss + mov es,ax + lea di,vesabuf[0] + mov ax,4f01h ;is mode available? + int 10h + or ah,ah + jnz notmode + test byte ptr es:[di],1 + jz notmode ;if mode not available skip mem size + lodsw + mov cx,ax + lodsw + mov bx,ax + lodsw + mul cx ;multiple by bits per pixel + shr dx,1 ;shift right 3 times to get # of bytes + rcr ax,1 + shr dx,1 + rcr ax,1 + shr dx,1 + rcr ax,1 + mul bx ;multiply by number of scanlines + mov bx,1024 + add ax,bx ;round up to nearest kilobyte + dec ax + adc dx,0 + div bx + cmp ax,[vgamem] ;if mode requires more memory + jbe vesalp + mov [vgamem],ax ;increase amount of vga memory + mov ax,vesabuf.vesamode.WinSize + mov [bksize],ax + jmp short vesalp +notmode: + add si,6 ;skip to next mode in list + jmp short vesalp +endvesa: + mov ax,[vgamem] + inc ah + dec ax + mov al,0 ;round up to nearest 256k + cmp ax,1024 + jb nomegs + add ax,1023 ;round up to nearest megabyte + and ax,not 1023 +nomegs: mov [vgamem],ax + +; jmp fini ;uncomment to disable other tests if VESA VBE found + + + + + + + + + + + +novesa: mov ax,0c000h ;ATI VGA detect (largely from ATI example code) + mov es,ax + cmp word ptr es:[40h],'13' ;ATI Signiture on the Video BIOS + jnz noati + bkadr ativga + mov [bksize],64 ; 64k bank size + mov dx,es:[10h] ; Get value of ATI extended register + mov bl,es:[43h] ; Get value of ATI chip version + cmp bl,'3' + jae v6up ; Use different method to determine + mov al,0bbh ; memory size of chip version is 3 or higher + cli + out dx,al + inc dx + in al,dx ; Get ramsize byte for chip versions 1 & 2 + sti + test al,20h + jz no512 + mov [vgamem],512 + jmp short no512 + +v6up: mov al,0b0h ; Method used for newer ATI chip versions + cli + out dx,al + inc dx + in al,dx ; Get ramsize byte for versions 3-5 + sti + test al,10h ; Check if ramsize byte indicates 256K or 512K bytes + jz v7up + mov [vgamem],512 +v7up: cmp bl,'4' ; Check for ramsize for ATI chip versions 4 & 5 + jb no512 + test al,8 ; Check if version 5 ATI chip has 1024K + jz no512 + mov [vgamem],1024 +no512: jmp fini + + + + + + + + + + + + + + + + + +noati: mov ax,7000h ;Test for Everex + xor bx,bx + cld + int 10h + cmp al,70h + jnz noev + bkadr everex + mov [bksize],64 ; 64k bank size + and ch,11000000b ;how much memory on board + jz skp + mov [vgamem],512 +skp: ;fall through for Everex boards using Trident or Tseng4000 + + + + + + + + + +noev: mov ax,0bf03h ;Test for Compaq + xor bx,bx + mov cx,bx + int 10h + cmp ax,0bf03h + jnz nocp + test cl,40h ;is 640x480x256 available? + jz nocp + bkadr compaq + mov [bksize],4 ; 4k bank size + mov [vgamem],512 + jmp fini + + + + + + + + + +nocp: mov dx,3c4h ;Test for NCR 77C22E + mov ax,0ff05h + call _isport2 + jnz noncr + mov ax,5 ;Disable extended registers + out dx,ax + mov ax,0ff10h ;Try to write to extended register 10 + call _isport2 ;If it writes then not NCR + jz noncr + mov ax,105h ;Enable extended registers + out dx,ax + mov ax,0ff10h + call _isport2 + jnz noncr ;If it does NOT write then not NCR + bkadr ncr + mov [bksize],16 ; 16k bank size + mov [vgamem],512 + jmp fini + + + + + + + + + + + + + + + + +noncr: mov dx,3c4h ;Test for Trident + mov al,0bh + out dx,al + inc dl + in al,dx + and al,0fh + cmp al,06h + ja notri + cmp al,2 + jb notri + bkadr trident + mov [bksize],64 ; 64k bank size + cmp al,3 + jb no89 + mov [t8900],1 + mov dx,3d4h + mov al,1fh + out dx,al + inc dx + in al,dx + and ax,3 + inc al + xchg al,ah + mov [vgamem],ax + jmp fini + +no89: mov [vgamem],512 + jmp fini + + + + + + + + + + + + + + + + + + + +notri: mov ax,6f00h ;Test for Video 7 + xor bx,bx + cld + int 10h + cmp bx,'V7' + jnz nov7 + bkadr video7 + mov [bksize],64 ; 64k bank size + mov ax,6f07h + cld + int 10h + and ah,7fh + cmp ah,1 + jbe skp2 + mov [vgamem],512 +skp2: cmp ah,3 + jbe skp3 + mov [vgamem],1024 +skp3: jmp fini + + + + + + + + + + + + + + + + + + + + + + + +nov7: mov dx,3d4h ;Test for GENOA GVGA + mov al,2eh ;check for Herchi Register top 6 bits + out dx,al + inc dx + in al,dx + dec dx + test al,11111100b ;top 6 bits should be zero + jnz nogn + mov ax,032eh ;check for Herchi Register + call _isport2 + jnz nogn + mov dx,3c4h + mov al,7 + out dx,al + inc dx + in al,dx + dec dx + test al,10001000b + jnz nogn + mov al,10h + out dx,al + inc dx + in al,dx + dec dx + and al,00110000b + cmp al,00100000b + jnz nogn + mov dx,3ceh + mov ax,0ff0bh + call _isport2 + jnz nogn + mov dx,3c4h ;check for memory segment register + mov ax,3f06h + call _isport2 + jnz nogn + mov dx,3ceh + mov ax,0ff0ah + call _isport2 + jnz nogn + bkadr genoa + mov [bksize],64 ; 64k bank size + mov [vgamem],512 + jmp fini + + + + + + + + + + + + + + + + + +nogn: call _cirrus ;Test for Cirrus + cmp [cirrus],0 + je noci + jmp fini + + + + + + + + + + + + + + + + + + +noci: mov dx,3ceh ;Test for Paradise + mov al,9 ;check Bank switch register + out dx,al + inc dx + in al,dx + dec dx + or al,al + jnz nopd + + mov ax,50fh ;turn off write protect on VGA registers + out dx,ax + mov dx,offset _paradise + mov cx,1 + call _chkbk + jc nopd ;if bank 0 and 1 same not paradise + bkadr paradise + mov [bksize],4 ; 4k bank size + mov dx,3ceh + mov al,0bh ;512k detect from Bob Berry + out dx,al + inc dx + in al,dx + test al,80h ;if top bit set then 512k + jz nop512 + test al,40h + jz nop1024 + mov [vgamem],1024 + jmp fini +nop1024: + mov [vgamem],512 +nop512: jmp fini + + + + + + + + + + + + + + + + + + + + + +nopd: mov ax,5f00h ;Test for Chips & Tech + xor bx,bx + cld + int 10h + cmp al,5fh + jnz noct + bkadr chipstech + mov [bksize],16 ; 16k bank size + cmp bh,1 + jb skp4 + mov [vgamem],512 +skp4: jmp fini + + + + + + + + + + + + + + + + + + + + + + + + +noct: mov dx,3dah ;Test for Tseng 4000 & 3000 + in al,dx ;bit 8 is opposite of bit 4 + mov ah,al ;(vertical retrace bit) + shr ah,1 + shr ah,1 + shr ah,1 + shr ah,1 + xor al,ah + test al,00001000b +;— + jz nots + + mov dx,3d4h ;check for Tseng 4000 series + mov ax,0f33h + call _isport2 +;— + jnz not4 + + mov ax,0ff33h ;top 4 bits should not be there + call _isport2 +;— + jz nots + + + mov dx,3bfh ;Enable access to extended registers + mov al,3 + out dx,al + mov dx,3d8h + mov al,0a0h + out dx,al + mov al,0ffh + mov dx,3cdh ;test bank switch register + call _isport1 + jnz not4 + bkadr tseng + mov [bksize],64 ; 64k bank size + mov ax,10f1h ;Extended BIOS call to get DAC type on Tseng4000 + int 10h + cmp ax,10h + jnz nodac + mov bh,0 + mov [dactype],bx +nodac: mov dx,3d4h ;Tseng 4000 memory detect 1meg + mov al,37h + out dx,al + inc dx + in al,dx + test al,1000b ;if using 64kx4 RAMs then no more than 256k + jz nomem + and al,3 + cmp al,1 ;if 8 bit wide bus then only two 256kx4 RAMs + jbe nomem + mov [vgamem],512 + cmp al,2 ;if 16 bit wide bus then four 256kx4 RAMs + je nomem + mov [vgamem],1024 ;full meg with eight 256kx4 RAMs +nomem: bkadr tseng4 + mov [bksize],64 ; 64k bank size + jmp fini + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +not4: mov dx,3d4h ;Test for Tseng 3000 + mov ax,1f25h ;is the Overflow High register there? + call _isport2 + jnz nots + mov al,03fh ;bottom six bits only + mov dx,3cdh ;test bank switch register + call _isport1 + jnz nots + bkadr tseng + mov [bksize],64 ; 64k bank size + call _t3memchk + jmp fini + + + + + + + + + + + + + + + + + + + +nots: mov dx,3ceh ;Test for Ahead A or B chipsets + mov ax,0ff0fh ;register should not be fully available + call _isport2 + jz noab + mov ax,200fh + out dx,ax + inc dx + nojmp + in al,dx + cmp al,21h + jz verb + cmp al,20h + jnz noab + bkadr aheada + mov [bksize],64 ; 64k bank size + mov [vgamem],512 + jmp fini + +verb: bkadr aheadb + mov [bksize],64 ; 64k bank size + mov [vgamem],512 + jmp fini + + + + + + + + + + + + + + + + + + + + + + + + + + +noab: mov dx,3c4h ;Test for AcuMos chipsets + mov ax,0006h ;disable extended registers + out dx,ax + mov ax,0ff09h + call _isport2 ;is scratchpad at index 9 writeable ? + jz noacu + mov ax,0ff0ah + call _isport2 ;is scratchpad at index 10 writable ? + jz noacu + mov ax,1206h + out dx,ax + mov ax,0ff09h + call _isport2 + jnz noacu + mov ax,0ff0ah + call _isport2 + jnz noacu + mov dx,offset _acumos + mov cx,1 + call _chkbk + jc noacu ;if bank 0 and 1 same not acumos + bkadr acumos + mov [bksize],4 ; 4k bank size + mov dx,3c4h + mov al,0ah + out dx,al + inc dx + in al,dx ;get scratchpad index 10 + and al,3 + cmp al,1 + jb noamem + mov [vgamem],512 + cmp al,2 + jb noamem + mov [vgamem],1024 + cmp al,3 + jb noamem + mov [vgamem],2048 +noamem: jmp short fini + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +noacu: mov dx,3deh ;Test for Oak Technology Inc OTI-067 and OTI-077 + mov ax,0ff11h ;look for bank switch register + call _isport2 + jnz nooak + bkadr oaktech + mov [bksize],64 ; 64k bank size + mov al,0dh + out dx,al + inc dx + nojmp + in al,dx + test al,11000000b + jz no4ram + mov [vgamem],512 + test al,01000000b + jz no4ram + mov [vgamem],1024 +no4ram: jmp short fini + +nooak: + + + + + + + + + + + + + + + + + + + + + + mov si,0 + +fini: cmp [vesa],0 + jz novbank + bkadr vesa ; Always use VESA bank switch + ; even if we have detected chipset +novbank: + mov ax,si + mov [retval],ax + ret + + + +whichvga endp + + +;Segment to access video buffer (based on GR[6]) +buftbl dw 0A000h,0A000h,0B000h,0B800h + +_t3memchk proc ;[Charles Marslett -- ET3000 memory ck] + mov dx,3dah + in al,dx ;Reset the attribute flop (read 0x3DA) + mov dx,03c0h + mov al,36h + out dx,al + inc dx + in al,dx ;Save contents of ATTR[0x16] + push ax + or al,10h + dec dx + out dx,al + mov dx,3ceh ;Find the RAM buffer... + mov al,6 + out dx,al + inc dx + in al,dx + and ax,000Ch + shr ax,1 + + mov bx,ax + push es + mov es,cs:buftbl[bx] + mov ax,09C65h + mov bx,1 + mov es:[bx],ax + mov es:[bx+2],ax + inc bx + mov ax,es:[bx] + pop es + cmp ax,0659Ch + jne et3k_256 + mov [vgamem],512 +et3k_256: + mov dx,3c0h + mov al,36h + out dx,al + pop ax + out dx,al ;Restore ATTR[16h] + ret +_t3memchk endp + +_cirrus proc near + mov dx,3d4h ; assume 3dx addressing + mov al,0ch ; screen a start address hi + out dx,al ; select index + inc dx ; point to data + mov ah,al ; save index in ah + in al,dx ; get screen a start address hi + xchg ah,al ; swap index and data + push ax ; save old value + push dx ; save crtc address + xor al,al ; clear crc + out dx,al ; and out to the crtc + + mov al,1fh ; Eagle ID register + dec dx ; back to index + out dx,al ; select index + inc dx ; point to data + in al,dx ; read the id register + mov bh,al ; and save it in bh + + mov cl,4 ; nibble swap rotate count + mov dx,3c4h ; sequencer/extensions + mov bl,6 ; extensions enable register + + ror bh,cl ; compute extensions disable value + mov ax,bx ; extensions disable + out dx,ax ; disable extensions + inc dx ; point to data + in al,dx ; read enable flag + or al,al ; disabled ? + jnz exit ; nope, not an cirrus + + ror bh,cl ; compute extensions enable value + dec dx ; point to index + mov ax,bx ; extensions enable + out dx,ax ; enable extensions + inc dx ; point to data + in al,dx ; read enable flag + cmp al,1 ; enabled ? + jne exit ; nope, not an cirrus + mov [cirrus],1 + mov word ptr [bankadr],offset _nobank + mov word ptr [bankadr+2],seg _nobank +exit: pop dx ; restore crtc address + dec dx ; point to index + pop ax ; recover crc index and data + out dx,ax ; restore crc value + ret +_cirrus endp + +_chkbk proc near ;bank switch check routine + mov di,0b800h + mov es,di + xor di,di + mov bx,1234h + call _gochk + jnz badchk + mov bx,4321h + call _gochk + jnz badchk + clc + ret +badchk: stc + ret +_chkbk endp + +calldx macro + push cs + call dx + endm + +_gochk proc near + push si + mov si,bx + + mov al,cl + calldx + xchg bl,es:[di] + mov al,ch + calldx + xchg bh,es:[di] + + xchg si,bx + + mov al,cl + calldx + xor bl,es:[di] + mov al,ch + calldx + xor bh,es:[di] + + xchg si,bx + + mov al,ch + calldx + mov es:[di],bh + mov al,cl + calldx + mov es:[di],bl + + mov al,0 + calldx + or si,si + pop si + ret +_gochk endp + +_isport2 proc near ;check for valid indexed i/o port, al is index, ah is bit mask + push bx + mov bx,ax + out dx,al + mov ah,al + inc dx + in al,dx + dec dx + xchg al,ah + push ax + mov ax,bx + out dx,ax + out dx,al + mov ah,al + inc dx + in al,dx + dec dx + and al,bh + cmp al,bh + jnz noport + mov al,ah + mov ah,0 + out dx,ax + out dx,al + mov ah,al + inc dx + in al,dx + dec dx + and al,bh + cmp al,0 +noport: pop ax + out dx,ax + pop bx + ret +_isport2 endp + +_isport1 proc near ;check for valid i/o port, al is bit mask + mov ah,al + in al,dx + push ax + mov al,ah + out dx,al + in al,dx + and al,ah + cmp al,ah + jnz noport + mov al,0 + out dx,al + in al,dx + and al,ah + cmp al,0 +noport: pop ax + out dx,al + ret +_isport1 endp + + end + diff --git a/LIB386/LIB_SVGA/S_LINE.ASM b/LIB386/LIB_SVGA/S_LINE.ASM new file mode 100644 index 0000000..d966ba8 --- /dev/null +++ b/LIB386/LIB_SVGA/S_LINE.ASM @@ -0,0 +1,289 @@ +;---------------------------------------------------------------------------- +; S_LINE.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386p + jumps + .model FLAT, SYSCALL + + .data + + include svga.ash + +EVEN + +couleur dw 00 + + .code + + public NoLanguage Line + public NoLanguage Line_A + +;---------------------------------------------------------------------------- +; Line( x0, y0, x1, y1, coul ) +; +Line proc uses esi edi ebp ebx,\ + x0:DWORD, y0:DWORD,\ + x1:DWORD, y1:DWORD,\ + coul:DWORD + +; X0:ax Y0:bx +; X1:cx Y1:DX +; couleur: bp + + mov eax, x0 + mov ebx, y0 + mov ecx, x1 + mov edx, y1 + + mov ebp, coul + + call Line_A + + ret + +Line endp + +Line_A proc + +; X0:eax Y0:ebx +; X1:ecx Y1:edx + + mov [couleur], bp + + cmp eax, ecx ; x0 < x1 + jle sensok + xchg eax, ecx + xchg ebx, edx +sensok: + ; XY 0 + +onceagain: xor bp, bp + + cmp eax, [ClipXmin] ; x0 + jge ncxi + or bp, 1 + jmp short ncxg + +ncxi: cmp eax, [ClipXmax] + jg notseen + +ncxg: cmp ebx, [ClipYmin] + jge ncyi + or bp, 8 + jmp short ncya + +ncyi: cmp ebx, [ClipYmax] + jle ncya + or bp, 4 +ncya: + ; XY 1 + + shl bp, 8 + + cmp ecx, [ClipXmin] + jl notseen + + cmp ecx, [ClipXmax] + jle ncx2a + or bp, 2 +ncx2a: + cmp edx, [ClipYmin] + jge ncy2i + or bp, 8 + jmp short ncy2a + +ncy2i: cmp edx, [ClipYmax] + jle ncy2a + or bp, 4 +ncy2a: + + ; test + + mov si, bp + shr si, 8 + test si, bp + jnz notseen + or si, bp + and si, 0FFh + jz draw + + mov edi, ecx + sub edi, eax ; edi delta x + + mov esi, edx + sub esi, ebx ; esi delta y + + + test bp, 100h + jz c0 + + mov ebp, edx + + sub eax, [ClipXmin] ; xmin - x0 + neg eax + imul si ; * dy + idiv di ; / dx + movsx eax, ax + add ebx, eax ; y0 += + mov eax, [ClipXmin] ; x0 = xmin + + mov edx, ebp + + jmp onceagain +c0: + test bp, 800h + jz c1 + + mov ebp, edx + + xchg eax, ebx + sub eax, [ClipYmin] ; ymin - y0 + neg eax + imul di ; * dx + idiv si ; / dy + movsx eax, ax + add eax, ebx ; x0 += + mov ebx, [ClipYmin] ; y0 = ymin + + mov edx, ebp + + jmp onceagain +c1: + test bp, 400h + jz c2 + + mov ebp, edx + + xchg eax, ebx + sub eax, [ClipYmax] ; ymax - y0 + neg eax + imul di ; * dx + idiv si ; / dy + movsx eax, ax + add eax, ebx ; x0 += + mov ebx, [ClipYmax] ; y0 = ymax + + mov edx, ebp + + jmp onceagain + + + +c2: + test bp, 2 + jz c3 + + mov ecx, eax ; save x0 + mov eax, [ClipXmax] + sub eax, ecx ; xmax - x0 + imul si ; * dy + idiv di ; / dx + movsx edx, ax + add edx, ebx ; + y0 + mov eax, ecx ; restore x0 + mov ecx, [ClipXmax] + + jmp onceagain + +c3: + test bp, 8 + jz c4 + + mov ecx, eax + mov eax, ebx + sub eax, [ClipYmin] ; ymin - y0 + neg eax + imul di ; * dx + idiv si ; / dy + movsx edx, ax + mov eax, ecx + add ecx, edx ; x0 += + mov edx, [ClipYmin] + + jmp onceagain + +c4: + test bp, 4 + jz onceagain + + mov ecx, eax + mov eax, ebx + sub eax, [ClipYmax] ; ymax - y0 + neg eax + imul di ; * dx + idiv si ; / dy + movsx edx, ax + mov eax, ecx + add ecx, edx + mov edx, [ClipYmax] + + jmp onceagain + +notseen: ret + +;---------------------------------------------------------------------------- + +draw: mov esi, 640 + sub ecx, eax + sub edx, ebx + jns descend + + neg esi + neg edx + +descend: mov edi, Log + add edi, TabOffLine[ ebx * 4 ] + add edi, eax + + mov ax, [couleur] + + cmp ecx, edx + jl vertical + +horizontal: mov ebp, ecx + shl ebp, 1 + mov ebx, ecx + shl edx, 1 + inc ecx + jmp loopX + +noovfy: dec ecx + jz exit +loopX: mov byte ptr[edi], al + inc edi + sub ebx, edx + jnc noovfy + add ebx, ebp + add edi, esi + dec ecx + jnz loopX + + ret + +vertical: xchg ecx, edx + mov ebp, ecx + shl ebp, 1 + mov ebx, ecx + shl edx, 1 + inc ecx + jmp loopY + +noovfx: add edi, esi + dec ecx + jz exit +loopY: mov byte ptr[edi], al + sub ebx, edx + jnc noovfx + add ebx, ebp + adc edi, esi + dec ecx + jnz loopY + +exit: + ret + +Line_A endp + + + end diff --git a/LIB386/LIB_SVGA/S_MODE.ASM b/LIB386/LIB_SVGA/S_MODE.ASM new file mode 100644 index 0000000..c6a0123 --- /dev/null +++ b/LIB386/LIB_SVGA/S_MODE.ASM @@ -0,0 +1,217 @@ + + + .model SMALL, SYSCALL + + + include vesa.inc + +; +; VGAKIT Version 5.2b +; +; Copyright 1988,89,90,91,92 John Bridges +; Free for use in commercial, shareware or freeware applications +; +; SVGAMODE.ASM +; +; +.data + extrn cirrus:byte,everex:byte,paradise:byte,tseng:byte,trident:byte + extrn t8900:byte,ativga:byte,aheada:byte,aheadb:byte + extrn oaktech:byte,video7:byte,chipstech:byte,tseng4:byte,genoa:byte + extrn ncr:byte,compaq:byte,acumos:byte,vesa:byte + + extrn curbk:word,bksize:word + + extrn vesafunc:dword + + public maxx,maxy,scanline,ourseg + +maxx dw ? ;scanline of screen in pixels +maxy dw ? ;height of screen in pixels +scanline dw ? ;actual width screen in bytes +ourseg dw ? ;segment of screen buffer + + + public adrtbl + +adrtbl dd 1024 dup (?) ;offset and bank for each scanline + + .code LIB_SVGA + + public mkadrtbl + public svgamode + public txtmode + public setmany + +mkadrtbl proc uses di si + mov di,offset adrtbl + mov ax,ds + mov es,ax + mov bx,[maxy] + + mov ax,[bksize] + cmp ax,64 + jz nobnk + mov cl,10 + shl ax,cl + dec ax + mov si,ax + mov cl,9 + mov ax,[bksize] +shlp: inc cl + shr ax,1 + jnz shlp + xor ax,ax + xor dx,dx +lp: push ax + shr ax,cl + add dx,ax + pop ax + and ax,si + stosw + xchg ax,dx + stosw + xchg ax,dx + add ax,[scanline] + dec bx + jnz lp + ret + +nobnk: xor ax,ax + xor dx,dx + mov si,[scanline] + mov cx,bx +nlp: stosw + xchg ax,dx + stosw + xchg ax,dx + add ax,si + adc dx,0 + loop nlp + ret + +mkadrtbl endp + +svgamode proc ;Set 640x480x256 on most SVGA cards + mov [ourseg],0a000h + mov ax,640 + mov [maxx],ax ;default width to 640 for now + mov [scanline],ax + + cmp [vesa],0 + jz novs + mov bx,101h + call vesaset + jmp godo2 +novs: cmp [compaq],0 + jz nocp + mov [scanline],1024 + mov ax,2eh + jmp godo +nocp: cmp [genoa],0 + jz nogn + mov ax,5ch + jmp godo +nogn: cmp [ncr],0 + jz noncr + mov ax,5fh + jmp godo +noncr: cmp [oaktech],0 + jz noak + mov ax,53h + jmp short godo +noak: cmp [aheada],0 + jnz @f + cmp [aheadb],0 + jz noab +@@: mov ax,61h + jmp short godo +noab: cmp [everex],0 + jz noev + mov ax,70h + mov bl,30h + jmp short godo +noev: cmp [ativga],0 + jz noati + mov ax,62h + jmp short godo +noati: cmp [trident],0 + jz notr + mov ax,5dh + jmp short godo +notr: cmp [video7],0 + jz nov7 + mov ax,6f05h + mov bl,67h + jmp short godo +nov7: cmp [chipstech],0 + jz noct + mov ax,79h + jmp short godo +noct: cmp [acumos],0 + jnz dopd + cmp [paradise],0 + jz nopd +dopd: mov ax,5fh + jmp short godo +nopd: cmp [tseng],0 + jz nots + mov ax,2eh +godo: int 10h + +godo2: mov [curbk],-1 + mov ax,40h + mov es,ax + mov al,es:[84h] ;get height of screen + inc al + mul byte ptr es:[85h] + mov [maxy],ax + call mkadrtbl +nots: ret +svgamode endp + +vesaset proc near uses di + local modebuf[260]:byte ; extra large to make up for + ; bugs in some VESA VBE's + + push bx + mov ax,4f02h ; set the VESA videomode + int 10h + pop cx + mov ax,ss + mov es,ax + lea di,modebuf[0] ; get the mode information + mov ax,4f01h + int 10h + mov ax,modebuf.vesamode.WinGranularity + mov [bksize],ax ; bank size from vesamode structure + mov ax,modebuf.vesamode.BytesPerLine + mov [scanline],ax ; scan line byte width from vesamode + mov ax,word ptr modebuf.vesamode.WinFuncPtr + mov word ptr [vesafunc],ax + mov ax,word ptr modebuf.vesamode.WinFuncPtr+2 + mov word ptr [vesafunc+2],ax + ret +vesaset endp + +txtmode proc + mov ax,3 + int 10h + ret +txtmode endp + +setmany proc uses es,\ + palbuf:ptr byte,begcol:word,numcol:word + + les dx,[palbuf] + mov bx,[begcol] + mov cx,[numcol] + mov ax,1012h + int 10h + ret + +setmany endp + + + end + diff --git a/LIB386/LIB_SVGA/S_MOUSE.C b/LIB386/LIB_SVGA/S_MOUSE.C new file mode 100644 index 0000000..23067d8 --- /dev/null +++ b/LIB386/LIB_SVGA/S_MOUSE.C @@ -0,0 +1,238 @@ + +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_svga\lib_svga.h" + +#include +#include +#include + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛÜ ÜÛ ÛßßßÛ Û Û ÛÛßßß Ûßßßß + ÛÛß Û ÛÛ Û ÛÛ Û ßßßßÛ ÛÛßß + ßß ß ßßßßß ßßßßß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +volatile LONG Click = 0 ; +volatile LONG Mouse_X = 0 ; +volatile LONG Mouse_Y = 0 ; +LONG Mouse_X_Dep = 0 ; +LONG Mouse_Y_Dep = 0 ; + +LONG OldX0Mouse=-1, OldY0Mouse, OldX1Mouse, OldY1Mouse ; +WORD DefMouse = 0 ; +LONG FlagMouse = TRUE ; + +UBYTE *GphMouse ; +UBYTE *BufferMouse ; + + extern UBYTE *Log ; + extern UBYTE BinGphMouse ; + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +#pragma off (check_stack) +void _loadds far click_handler (int max, int mcx, int mdx) +{ +#pragma aux click_handler parm [EAX] [ECX] [EDX] + Mouse_X = mcx>>3 ; + Mouse_Y = mdx>>3 ; + if( max & 0x02 ) Click |= 1 ; + if( max & 0x04 ) Click &= ~1 ; + if( max & 0x08 ) Click |= 2 ; + if( max & 0x10 ) Click &= ~2 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void SetMouseBox( LONG x0, LONG y0, LONG x1, LONG y1 ) +{ + struct SREGS sregs ; + union REGS inregs, outregs ; + + inregs.w.ax = 0x07 ; + inregs.w.cx = x0<<3 ; + inregs.w.dx = x1<<3 ; + int386 (0x33, &inregs, &outregs); + + inregs.w.ax = 0x08 ; + inregs.w.cx = y0<<3 ; + inregs.w.dx = y1<<3 ; + int386 (0x33, &inregs, &outregs); +} +/*--------------------------------------------------------------------------*/ +void SetMouseSpeed( LONG dx, LONG dy ) +{ + struct SREGS sregs ; + union REGS inregs, outregs ; + + inregs.w.ax = 0x0F ; + inregs.w.cx = (UWORD)dx ; + inregs.w.dx = (UWORD)dy ; + int386 (0x33, &inregs, &outregs); +} +/*--------------------------------------------------------------------------*/ +void SetMousePos( LONG x, LONG y ) +{ + struct SREGS sregs ; + union REGS inregs, outregs ; + + inregs.w.ax = 0x04 ; + inregs.w.cx = (UWORD)x<<3 ; + inregs.w.dx = (UWORD)y<<3 ; + int386 (0x33, &inregs, &outregs); + + inregs.w.ax = 0x01 ; + int386 (0x33, &inregs, &outregs); + + Mouse_X = x ; + Mouse_Y = y ; +} + +/*--------------------------------------------------------------------------*/ +void GetMouseDep() +{ + struct SREGS sregs ; + union REGS inregs, outregs ; + + inregs.w.ax = 0x0B ; + int386 (0x33, &inregs, &outregs); + + Mouse_X_Dep = (LONG)((WORD)outregs.w.cx) ; + Mouse_Y_Dep = (LONG)((WORD)outregs.w.dx) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void ShowMouse( LONG flag ) +{ + if( !flag ) + { + if( FlagMouse ) + { + if( OldX0Mouse != -1 ) + { + CopyBlockPhys( OldX0Mouse,OldY0Mouse, OldX1Mouse, OldY1Mouse ) ; + OldX0Mouse = -1 ; + } + FlagMouse = FALSE ; + } + } + else + { + if( !FlagMouse ) + { + OldX0Mouse = -1 ; /* force aff et evite restore */ + AffMouse() ; + FlagMouse = TRUE ; + } + } +} + +/*--------------------------------------------------------------------------*/ + +void AffMouse() +{ + LONG dx, dy ; + LONG x0, y0 ; + LONG x1, y1 ; + + if( FlagMouse ) + { + x0 = Mouse_X ; + y0 = Mouse_Y ; + + if( (OldX0Mouse == x0) AND (OldY0Mouse == y0) ) return ; + + GetDxDyGraph( DefMouse, &dx, &dy, GphMouse ) ; + x1 = x0 + dx - 1 ; + y1 = y0 + dy - 1 ; + + MemoClip() ; + + SetClip( x0,y0,x1,y1 ) ; + + if( OldX0Mouse != -1 ) + CopyBlockPhys( OldX0Mouse,OldY0Mouse, OldX1Mouse, OldY1Mouse ) ; + + SaveBlock( Log, BufferMouse, x0,y0, ClipXmax,ClipYmax ) ; + + AffGraph( DefMouse, x0, y0, GphMouse ) ; + + CopyBlockPhys( x0,y0, ClipXmax,ClipYmax ) ; + + RestoreBlock( Log, BufferMouse, x0,y0, ClipXmax,ClipYmax ) ; + + OldX0Mouse = x0 ; + OldY0Mouse = y0 ; + OldX1Mouse = ClipXmax ; + OldY1Mouse = ClipYmax ; + + RestoreClip() ; + } +} +/*--------------------------------------------------------------------------*/ + +void SetMouse( WORD num ) +{ + DefMouse = num ; + OldX0Mouse = -1 ; + AffMouse() ; +} + + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void InitMouse() +{ + struct SREGS sregs ; + union REGS inregs, outregs ; + + int installed = 0 ; + int orig_mode = 0 ; + int far *ptr ; + int (far *function_ptr)() ; + + segread(&sregs) ; + + /* check for mouse driver */ + inregs.w.ax = 0 ; + int386 (0x33, &inregs, &outregs); + if( installed = (outregs.w.ax != -1) ) return ; + + SetMouseBox( 0, 0, 639, 479 ) ; + SetMouseSpeed( 4, 4 ) ; + + GphMouse = &BinGphMouse ; + + BufferMouse = Malloc( 48*48 ) ; /* max size mouse ! */ + + Click = 0 ; + FlagMouse = TRUE ; + + /* install click watcher */ + + inregs.w.ax = 0xC ; + inregs.w.cx = 0x01 | 0x02 | 0x04 | 0x08 |0x10 ; + function_ptr = click_handler ; + inregs.x.edx = FP_OFF( function_ptr ) ; + sregs.es = FP_SEG( function_ptr ) ; + int386x( 0x33, &inregs, &outregs, &sregs ); +} +/*--------------------------------------------------------------------------*/ +void ClearMouse() +{ + struct SREGS sregs ; + union REGS inregs, outregs ; + + inregs.w.ax = 0 ; + int386( 0x33, &inregs, &outregs ); + + FlagMouse = FALSE ; + + Free( BufferMouse ) ; +} +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ diff --git a/LIB386/LIB_SVGA/S_MOUSEA.ASM b/LIB386/LIB_SVGA/S_MOUSEA.ASM new file mode 100644 index 0000000..9afc060 --- /dev/null +++ b/LIB386/LIB_SVGA/S_MOUSEA.ASM @@ -0,0 +1,153 @@ +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + .386p + + .model SMALL, SYSCALL + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + .data + + public NoLanguage BinGphMouse + +BinGphMouse LABEL WORD + +db 28, 0, 0, 0, 149, 0, 0, 0, 14, 1, 0, 0, 194, 1, 0, 0 +db 132, 2, 0, 0, 57, 3, 0, 0, 235, 3, 0, 0, 10, 15, 0, 0 +db 2, 130, 16, 6, 2, 67, 16, 15, 15, 16, 5, 4, 64, 16, 130, 15 +db 64, 16, 4, 4, 64, 16, 131, 15, 64, 16, 3, 4, 64, 16, 132, 15 +db 64, 16, 2, 4, 64, 16, 133, 15, 64, 16, 1, 4, 64, 16, 134, 15 +db 64, 16, 0, 3, 64, 16, 135, 15, 64, 16, 3, 64, 16, 135, 15, 64 +db 16, 4, 64, 16, 133, 15, 65, 16, 16, 0, 4, 67, 16, 15, 15, 16 +db 130, 15, 64, 16, 1, 5, 0, 130, 16, 131, 15, 64, 16, 0, 5, 3 +db 64, 16, 130, 15, 64, 16, 0, 5, 3, 64, 16, 130, 15, 64, 16, 0 +db 3, 4, 130, 16, 1, 10, 15, 0, 0, 2, 130, 14, 6, 2, 67, 14 +db 12, 12, 14, 5, 4, 64, 14, 130, 12, 64, 14, 4, 4, 64, 14, 131 +db 12, 64, 14, 3, 4, 64, 14, 132, 12, 64, 14, 2, 4, 64, 14, 133 +db 12, 64, 14, 1, 4, 64, 14, 134, 12, 64, 14, 0, 3, 64, 14, 135 +db 12, 64, 14, 3, 64, 14, 135, 12, 64, 14, 4, 64, 14, 133, 12, 65 +db 14, 14, 0, 4, 67, 14, 12, 12, 14, 130, 12, 64, 14, 1, 5, 0 +db 130, 14, 131, 12, 64, 14, 0, 5, 3, 64, 14, 130, 12, 64, 14, 0 +db 5, 3, 64, 14, 130, 12, 64, 14, 0, 3, 4, 130, 14, 1, 14, 17 +db 0, 0, 3, 3, 65, 16, 16, 7, 3, 2, 67, 16, 15, 15, 16, 6 +db 3, 1, 69, 16, 15, 16, 16, 15, 16, 5, 3, 1, 69, 16, 15, 16 +db 16, 15, 16, 5, 3, 1, 69, 16, 15, 16, 16, 15, 16, 5, 3, 1 +db 70, 16, 15, 16, 16, 15, 16, 16, 4, 5, 1, 67, 16, 15, 16, 16 +db 130, 15, 130, 16, 1, 5, 1, 70, 16, 15, 16, 16, 15, 16, 16, 130 +db 15, 64, 16, 0, 2, 0, 76, 16, 15, 15, 16, 16, 15, 16, 16, 15 +db 16, 16, 15, 16, 3, 67, 16, 15, 16, 15, 132, 16, 68, 15, 16, 16 +db 15, 16, 3, 67, 16, 15, 16, 15, 135, 16, 65, 15, 16, 3, 65, 16 +db 15, 137, 16, 65, 15, 16, 3, 65, 16, 15, 137, 16, 65, 15, 16, 3 +db 65, 16, 15, 137, 16, 65, 15, 16, 4, 0, 65, 16, 15, 136, 16, 65 +db 15, 16, 5, 1, 65, 16, 15, 134, 16, 65, 15, 16, 0, 3, 2, 136 +db 16, 1, 15, 16, 0, 0, 3, 1, 138, 16, 1, 5, 0, 64, 16, 138 +db 15, 64, 16, 0, 5, 67, 16, 15, 16, 15, 134, 16, 64, 15, 0, 65 +db 15, 16, 5, 67, 16, 15, 16, 15, 134, 16, 64, 15, 0, 65, 15, 16 +db 3, 67, 16, 15, 16, 15, 134, 16, 67, 15, 16, 15, 16, 3, 67, 16 +db 15, 16, 15, 134, 16, 67, 15, 16, 15, 16, 3, 67, 16, 15, 16, 15 +db 134, 16, 67, 15, 16, 15, 16, 3, 67, 16, 15, 16, 16, 134, 15, 67 +db 16, 16, 15, 16, 3, 65, 16, 15, 138, 16, 65, 15, 16, 3, 65, 16 +db 15, 138, 16, 65, 15, 16, 5, 65, 16, 15, 130, 16, 132, 15, 130, 16 +db 65, 15, 16, 1, 78, 16, 15, 16, 16, 15, 16, 15, 15, 16, 16, 15 +db 16, 16, 15, 16, 1, 78, 16, 15, 16, 16, 15, 16, 15, 15, 16, 16 +db 15, 16, 16, 15, 16, 2, 0, 77, 16, 15, 16, 15, 16, 15, 15, 16 +db 16, 15, 16, 16, 15, 16, 5, 1, 64, 16, 137, 15, 64, 16, 0, 3 +db 2, 137, 16, 1, 19, 13, 0, 0, 5, 0, 131, 16, 8, 131, 16, 0 +db 7, 65, 16, 16, 130, 14, 65, 16, 16, 4, 65, 16, 16, 130, 14, 65 +db 16, 16, 3, 67, 16, 14, 16, 14, 138, 16, 67, 14, 16, 14, 16, 7 +db 66, 16, 16, 14, 130, 16, 65, 14, 14, 130, 16, 65, 14, 14, 130, 16 +db 66, 14, 16, 16, 7, 0, 66, 16, 14, 14, 130, 16, 68, 14, 14, 16 +db 14, 14, 130, 16, 66, 14, 14, 16, 0, 5, 1, 68, 16, 14, 16, 14 +db 16, 132, 14, 68, 16, 14, 16, 14, 16, 1, 5, 1, 68, 16, 16, 14 +db 16, 16, 132, 14, 68, 16, 16, 14, 16, 16, 1, 5, 2, 64, 16, 138 +db 14, 64, 16, 2, 5, 2, 64, 16, 138, 14, 64, 16, 2, 7, 2, 64 +db 16, 131, 14, 130, 16, 131, 14, 64, 16, 2, 7, 3, 64, 16, 131, 14 +db 64, 16, 131, 14, 64, 16, 3, 5, 4, 66, 16, 14, 14, 130, 16, 66 +db 14, 14, 16, 4, 3, 5, 134, 16, 5, 19, 13, 0, 0, 5, 0, 131 +db 16, 8, 131, 16, 0, 7, 65, 16, 16, 130, 14, 65, 16, 16, 4, 65 +db 16, 16, 130, 14, 65, 16, 16, 3, 67, 16, 14, 16, 14, 138, 16, 67 +db 14, 16, 14, 16, 7, 66, 16, 16, 14, 130, 16, 65, 14, 14, 130, 16 +db 65, 14, 14, 130, 16, 66, 14, 16, 16, 7, 0, 67, 16, 14, 14, 16 +db 131, 14, 64, 16, 131, 14, 67, 16, 14, 14, 16, 0, 5, 1, 66, 16 +db 14, 16, 136, 14, 66, 16, 14, 16, 1, 7, 1, 66, 16, 16, 14, 130 +db 16, 130, 14, 130, 16, 66, 14, 16, 16, 1, 5, 2, 64, 16, 138, 14 +db 64, 16, 2, 5, 2, 64, 16, 138, 14, 64, 16, 2, 7, 2, 64, 16 +db 131, 14, 130, 16, 131, 14, 64, 16, 2, 7, 3, 64, 16, 131, 14, 64 +db 16, 131, 14, 64, 16, 3, 5, 4, 66, 16, 14, 14, 130, 16, 66, 14 +db 14, 16, 4, 5, 5, 130, 16, 0, 130, 16, 5, 0, 0, 0, 0, 0 +db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +db 0, 0, 0, 0, 0, 0, 0 + +comment # +db 28, 0, 0, 0, 150, 0, 0, 0, 16, 1, 0, 0, 203, 1, 0, 0 +db 143, 2, 0, 0, 70, 3, 0, 0, 250, 3, 0, 0, 10, 15, 2, 130 +db 16, 6, 2, 67, 16, 15, 15, 16, 5, 4, 64, 16, 130, 15, 64, 16 +db 4, 4, 64, 16, 131, 15, 64, 16, 3, 4, 64, 16, 132, 15, 64, 16 +db 2, 5, 64, 16, 133, 15, 64, 16, 0, 0, 4, 64, 16, 134, 15, 64 +db 16, 0, 3, 64, 16, 135, 15, 64, 16, 3, 64, 16, 135, 15, 64, 16 +db 4, 64, 16, 133, 15, 65, 16, 16, 0, 5, 67, 16, 15, 15, 16, 130 +db 15, 64, 16, 0, 0, 5, 0, 130, 16, 131, 15, 64, 16, 0, 5, 3 +db 64, 16, 130, 15, 64, 16, 0, 5, 3, 64, 16, 130, 15, 64, 16, 0 +db 4, 4, 130, 16, 0, 0, 10, 15, 2, 130, 14, 6, 2, 67, 14, 12 +db 12, 14, 5, 4, 64, 14, 130, 12, 64, 14, 4, 4, 64, 14, 131, 12 +db 64, 14, 3, 4, 64, 14, 132, 12, 64, 14, 2, 5, 64, 14, 133, 12 +db 64, 14, 0, 0, 4, 64, 14, 134, 12, 64, 14, 0, 3, 64, 14, 135 +db 12, 64, 14, 3, 64, 14, 135, 12, 64, 14, 4, 64, 14, 133, 12, 65 +db 14, 14, 0, 5, 67, 14, 12, 12, 14, 130, 12, 64, 14, 0, 0, 5 +db 0, 130, 14, 131, 12, 64, 14, 0, 5, 3, 64, 14, 130, 12, 64, 14 +db 0, 5, 3, 64, 14, 130, 12, 64, 14, 0, 4, 4, 130, 14, 0, 0 +db 14, 17, 3, 3, 65, 16, 16, 7, 3, 2, 67, 16, 15, 15, 16, 6 +db 4, 0, 0, 69, 16, 15, 16, 16, 15, 16, 5, 4, 0, 0, 69, 16 +db 15, 16, 16, 15, 16, 5, 4, 0, 0, 69, 16, 15, 16, 16, 15, 16 +db 5, 4, 0, 0, 70, 16, 15, 16, 16, 15, 16, 16, 4, 7, 0, 0 +db 67, 16, 15, 16, 16, 130, 15, 130, 16, 0, 0, 6, 0, 0, 70, 16 +db 15, 16, 16, 15, 16, 16, 130, 15, 64, 16, 0, 2, 0, 76, 16, 15 +db 15, 16, 16, 15, 16, 16, 15, 16, 16, 15, 16, 3, 67, 16, 15, 16 +db 15, 132, 16, 68, 15, 16, 16, 15, 16, 3, 67, 16, 15, 16, 15, 135 +db 16, 65, 15, 16, 3, 65, 16, 15, 137, 16, 65, 15, 16, 3, 65, 16 +db 15, 137, 16, 65, 15, 16, 3, 65, 16, 15, 137, 16, 65, 15, 16, 4 +db 0, 65, 16, 15, 136, 16, 65, 15, 16, 6, 0, 0, 65, 16, 15, 134 +db 16, 65, 15, 16, 0, 4, 2, 136, 16, 0, 0, 15, 16, 5, 0, 0 +db 138, 16, 0, 0, 5, 0, 64, 16, 138, 15, 64, 16, 0, 5, 67, 16 +db 15, 16, 15, 134, 16, 64, 15, 0, 65, 15, 16, 5, 67, 16, 15, 16 +db 15, 134, 16, 64, 15, 0, 65, 15, 16, 3, 67, 16, 15, 16, 15, 134 +db 16, 67, 15, 16, 15, 16, 3, 67, 16, 15, 16, 15, 134, 16, 67, 15 +db 16, 15, 16, 3, 67, 16, 15, 16, 15, 134, 16, 67, 15, 16, 15, 16 +db 3, 67, 16, 15, 16, 16, 134, 15, 67, 16, 16, 15, 16, 3, 65, 16 +db 15, 138, 16, 65, 15, 16, 3, 65, 16, 15, 138, 16, 65, 15, 16, 5 +db 65, 16, 15, 130, 16, 132, 15, 130, 16, 65, 15, 16, 1, 78, 16, 15 +db 16, 16, 15, 16, 15, 15, 16, 16, 15, 16, 16, 15, 16, 1, 78, 16 +db 15, 16, 16, 15, 16, 15, 15, 16, 16, 15, 16, 16, 15, 16, 2, 0 +db 77, 16, 15, 16, 15, 16, 15, 15, 16, 16, 15, 16, 16, 15, 16, 6 +db 0, 0, 64, 16, 137, 15, 64, 16, 0, 4, 2, 137, 16, 0, 0, 19 +db 13, 5, 0, 131, 16, 8, 131, 16, 0, 7, 65, 16, 16, 130, 14, 65 +db 16, 16, 4, 65, 16, 16, 130, 14, 65, 16, 16, 3, 67, 16, 14, 16 +db 14, 138, 16, 67, 14, 16, 14, 16, 7, 66, 16, 16, 14, 130, 16, 65 +db 14, 14, 130, 16, 65, 14, 14, 130, 16, 66, 14, 16, 16, 7, 0, 66 +db 16, 14, 14, 130, 16, 68, 14, 14, 16, 14, 14, 130, 16, 66, 14, 14 +db 16, 0, 7, 0, 0, 68, 16, 14, 16, 14, 16, 132, 14, 68, 16, 14 +db 16, 14, 16, 0, 0, 7, 0, 0, 68, 16, 16, 14, 16, 16, 132, 14 +db 68, 16, 16, 14, 16, 16, 0, 0, 5, 2, 64, 16, 138, 14, 64, 16 +db 2, 5, 2, 64, 16, 138, 14, 64, 16, 2, 7, 2, 64, 16, 131, 14 +db 130, 16, 131, 14, 64, 16, 2, 7, 3, 64, 16, 131, 14, 64, 16, 131 +db 14, 64, 16, 3, 5, 4, 66, 16, 14, 14, 130, 16, 66, 14, 14, 16 +db 4, 3, 5, 134, 16, 5, 19, 13, 5, 0, 131, 16, 8, 131, 16, 0 +db 7, 65, 16, 16, 130, 14, 65, 16, 16, 4, 65, 16, 16, 130, 14, 65 +db 16, 16, 3, 67, 16, 14, 16, 14, 138, 16, 67, 14, 16, 14, 16, 7 +db 66, 16, 16, 14, 130, 16, 65, 14, 14, 130, 16, 65, 14, 14, 130, 16 +db 66, 14, 16, 16, 7, 0, 67, 16, 14, 14, 16, 131, 14, 64, 16, 131 +db 14, 67, 16, 14, 14, 16, 0, 7, 0, 0, 66, 16, 14, 16, 136, 14 +db 66, 16, 14, 16, 0, 0, 9, 0, 0, 66, 16, 16, 14, 130, 16, 130 +db 14, 130, 16, 66, 14, 16, 16, 0, 0, 5, 2, 64, 16, 138, 14, 64 +db 16, 2, 5, 2, 64, 16, 138, 14, 64, 16, 2, 7, 2, 64, 16, 131 +db 14, 130, 16, 131, 14, 64, 16, 2, 7, 3, 64, 16, 131, 14, 64, 16 +db 131, 14, 64, 16, 3, 5, 4, 66, 16, 14, 14, 130, 16, 66, 14, 14 +db 16, 4, 5, 5, 130, 16, 0, 130, 16, 5, 0, 0, 0, 0, 0, 0 +db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +db 0, 0, 0, 0, 0, 0 + # + .code + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ +; The + End + + diff --git a/LIB386/LIB_SVGA/S_PAL.ASM b/LIB386/LIB_SVGA/S_PAL.ASM new file mode 100644 index 0000000..ffd28ac --- /dev/null +++ b/LIB386/LIB_SVGA/S_PAL.ASM @@ -0,0 +1,142 @@ +;---------------------------------------------------------------------------- +; S_PAL.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386p + jumps + .model SMALL, SYSCALL +;---------------------------------------------------------------------------- + .data + + include svga.ash + +MyTab db 768 dup(0) + +;---------------------------------------------------------------------------- + .code + + public NoLanguage Palette + public NoLanguage PalMulti + public NoLanguage PalOne + +;---------------------------------------------------------------------------- +; Palette( (UBYTE*)PalColor ) +; +Palette proc uses esi edi,\ + PalColor:DWORD +;---------------------- + mov esi, PalColor + lea edi, MyTab + mov ecx, 256 +;---------------------- +Again: mov al, [esi] + shr al, 2 + mov [edi], al + mov al, [esi+1] + shr al, 2 + mov [edi+1], al + mov al, [esi+2] + shr al, 2 + mov [edi+2], al + add esi, 3 + add edi, 3 + dec ecx + jnz Again +;---------------------- + lea esi, MyTab + + mov dx, 03c8h + xor ax, ax + out dx, al + inc dx + mov ecx, 256 +Encore: + outsb ; R + outsb ; G + outsb ; B + + dec ecx + jnz Encore +;---------------------- + ret + +Palette endp + +;---------------------------------------------------------------------------- +; Palette( (UBYTE*)PalColor ) +; +PalMulti proc uses esi edi ebx,\ + colstart:DWORD, nbcol:DWORD, PalColor:DWORD +;---------------------- + mov esi, PalColor + lea edi, MyTab + + mov ecx, nbcol +;---------------------- +Again: mov al, [esi] + shr al, 2 + mov [edi], al + mov al, [esi+1] + shr al, 2 + mov [edi+1], al + mov al, [esi+2] + shr al, 2 + mov [edi+2], al + add esi, 3 + add edi, 3 + dec ecx + jnz Again +;---------------------- + lea esi, MyTab ; Mytab + start col + + mov dx, 03c8h + mov ax, word ptr[colstart] + out dx, al + inc dx + mov ecx, nbcol +Encore: + outsb ; R + outsb ; G + outsb ; B + + dec ecx + jnz Encore +;---------------------- + ret + +PalMulti endp +;---------------------------------------------------------------------------- +; PalOne( col, red, green, blue ) +; ax col +; bx red +; cx, green +; dx, blue +; +PalOne proc uses ebx,\ + col:DWORD, red:DWORD, green:DWORD, blue:DWORD +;---------------------- + mov eax, col + mov ebx, red + mov ecx, green + mov edx, blue + + shr bl, 2 ; Red >> 2 + shr cl, 2 ; Green >> 2 + shr dl, 2 ; Blue >> 2 + mov ch, dl ; Save Blue + + mov dx, 03c8h + out dx, al ; al=Num Color + inc dx + mov al, bl + out dx, al ; Red + mov al, cl + out dx, al ; Green + mov al, ch + out dx, al ; Blue +;---------------------- + ret +PalOne endp +;---------------------------------------------------------------------------- +; The + End diff --git a/LIB386/LIB_SVGA/S_PHYS.ASM b/LIB386/LIB_SVGA/S_PHYS.ASM new file mode 100644 index 0000000..787baf2 --- /dev/null +++ b/LIB386/LIB_SVGA/S_PHYS.ASM @@ -0,0 +1,929 @@ +;---------------------------------------------------------------------------- +; S_PHYS.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386p + jumps + .model SMALL, SYSCALL +;---------------------------------------------------------------------------- + .data + + include svga.ash + + extrn NoLanguage NewBank : DWORD + + public NoLanguage ScanLine + public NoLanguage BankSize + public NoLanguage BankOver + public NoLanguage BankShift + public NoLanguage NonStdVESA + +ALIGN 4 + +Diff dd ? +SaveEAX dd ? +SaveEBX dd ? +SaveEDX dd ? +DeltaLog dd ? + +ScanLine dd 640 +BankSize dd 00000FFFFh +BankOver dd 0FFFF0000h +NonStdVESA db 0 +BankShift db 16 + + +CptLine dw 0 + + +;---------------------------------------------------------------------------- + .code + + public NoLanguage CopyBlockPhysClip + public NoLanguage CopyBlockPhys + public NoLanguage Flip + public NoLanguage Vsync + +;---------------------------------------------------------------------------- +; Vsync() +; +Vsync proc + mov dx, 03DAh +NotReady: in al, dx + jmp $+2 + test al, 08h + jnz short NotReady +Ready: in al, dx + jmp $+2 + test al, 08h + jz short Ready + ret +Vsync endp +;---------------------------------------------------------------------------- +SuperMovsD macro + + shr ecx, 2 + rep movsd + mov ecx, ebx + and ecx, 11b + rep movsb + + endm + + +SwitchBank macro + local noswitch + + cmp eax, BankCurrent + je noswitch + mov BankCurrent, eax + call [NewBank] +noswitch: + endm + + +SwitchBankNoTest macro + + mov BankCurrent, eax + call [NewBank] + + endm + + +SwitchBankDirect macro + + call [NewBank] + + endm + + +ChangeVideoBank macro + + mov [SaveEAX], eax + mov eax, BankCurrent + mov [SaveEDX], edx + inc eax + mov BankCurrent, eax + call [NewBank] + mov eax, [SaveEAX] + mov edx, [SaveEDX] + + endm + +;---------------------------------------------------------------------------- +; CopyBlockClip( x0, y0, x1, y1 ) +; +CopyBlockPhysClip proc uses esi edi ebx ebp,\ + x0:DWORD, y0:DWORD, x1:DWORD, y1:DWORD + + mov edx, x0 + mov ecx, y0 + mov ebx, x1 + mov eax, y1 + +;---------------------- Clipping Source Part 1 + + cmp edx, ClipXmax + jg CopyBlockPhysClip_End + cmp ebx, ClipXmin + jl CopyBlockPhysClip_End + cmp ecx, ClipYmax + jg CopyBlockPhysClip_End + cmp eax, ClipYmin + jl CopyBlockPhysClip_End + +;---------------------- Clipping Source Part 2 + + cmp edx, ClipXmin ; X0 < ClipXmin ? + jge Ok_X0_L ; A plus tart + mov edx, ClipXmin ; X0 = ClipXmin +Ok_X0_L: cmp ebx, ClipXmax ; X1 > ClipXmax + jle Ok_X1_R ; Goodbye + mov ebx, ClipXmax ; X1 = ClipXmax +Ok_X1_R: cmp ecx, ClipYmin ; Y0 < ClipYmin + jge Ok_Y0_U ; On se casse + mov ecx, ClipYmin ; Y0 = ClipYmin +Ok_Y0_U: cmp eax, ClipYmax ; Y1 > ClipYMax + jle Ok_Y1_D ; A priori non + mov eax, ClipYmax ; Y1 = ClipYmax +Ok_Y1_D: +;---------------------- Compute Delta X & Y + + sub ebx, edx ; EBX Delta X + sub eax, ecx ; EAX Delta Y + inc ebx ; EBX = Delta X + 1 + inc eax ; EAX = Delta Y + 1 + + mov esi, TabOffLine[ecx*4] ; y0 + add esi, edx ; SI Offset Src + mov edi, esi + + mov ebp, eax + mov eax, edi + shr eax, 16 + SwitchBank ; Change Bank 64Kb + mov eax, ebp + + xor ebp, ebp + add esi, Log + and edi, 0FFFFh ; 64Kb bank + or edi, 0A0000h ; EDI = Phys + mov bp, di ; BP For Bank + + mov edx, Screen_X + sub edx, ebx ; DX Delta Screen +;---------------------- +Again: add bp, bx + jc NewBankNear0c + mov ecx, ebx + + SuperMovsD ; Macro + + add esi, edx + add edi, edx + add bp, dx + jc NewBankNear1c + dec eax + jne short Again +;---------------------- +CopyBlockPhysClip_End: ret +;----------------------------------------------------------------------------- +NewBankNear0c: mov ecx, ebx + sub ecx, ebp + push ebx ; Sauve EBX + mov ebx, ecx + + SuperMovsD ; Macro + + ChangeVideoBank : Macro + + mov edi, 0A0000h ; Begin Phys + mov ecx, ebp + mov ebx, ebp + + SuperMovsD ; Macro + + pop ebx ; Restore EBX + + add esi, edx + add edi, edx + add bp, dx + jc NewBankNear1c + dec eax + jne Again + ret +;---------------------- +NewBankNear1c: ChangeVideoBank ; Macro + sub edi, 010000h ; Stay in Phys + dec eax + jne Again + ret +CopyBlockPhysClip endp +;---------------------------------------------------------------------------- +; CopyBlockPhys( x0, y0, x1, y1 ) +; +CopyBlockPhys proc uses esi edi ebx ebp,\ + x0:DWORD, y0:DWORD, x1:DWORD, y1:DWORD + + cmp [NonStdVESA], 0 + jne CopyBlockPhys2 + + mov edx, x0 + mov ecx, y0 + mov ebx, x1 + mov eax, y1 +;---------------------- Compute Delta X & Y + sub ebx, edx ; EBX Delta X + sub eax, ecx ; EAX Delta Y + inc ebx ; EBX = Delta X + 1 + inc eax ; EAX = Delta Y + 1 +;---------------------- Compute Adresse + mov esi, TabOffLine[ecx*4] + add esi, edx + mov edi, esi + + mov ebp, eax + mov eax, edi + shr eax, 16 + SwitchBank ; Change Bank 64Kb + mov eax, ebp + + add esi, Log + + xor ebp, ebp + and edi, 0FFFFh ; 64Kb bank + or edi, 0A0000h ; EDI = Phys + mov bp, di ; BP For Bank + + mov edx, Screen_X + sub edx, ebx ; DX Delta Screen +;---------------------- +Again: add bp, bx + jc NewBankNear0p + mov ecx, ebx + + SuperMovsD ; Macro + + add esi, edx + add edi, edx + add bp, dx + jc NewBankNear1p + dec eax + jne short Again +;---------------------- + ret +;----------------------------------------------------------------------------- +NewBankNear0p: mov ecx, ebx + sub ecx, ebp + mov [SaveEBX], ebx ; Sauve EBX + mov ebx, ecx + + SuperMovsD ; Macro + + ChangeVideoBank : Macro + + mov edi, 0A0000h ; Begin Phys + mov ecx, ebp + mov ebx, ebp + + SuperMovsD ; Macro + + mov ebx, [SaveEBX] ; Restore EBX + + add esi, edx + add edi, edx + add bp, dx + jc NewBankNear1p + dec eax + jne Again + ret +;---------------------- +NewBankNear1p: ChangeVideoBank ; Macro + sub edi, 010000h ; Stay in Phys + dec eax + jne Again + ret +;---------------------------------------------------------------------------- +; CopyBlockPhys( x0, y0, x1, y1 ) +; +CopyBlockPhys2: mov edx, x0 + mov ecx, y0 + mov ebx, x1 + mov eax, y1 + +;---------------------- Compute Delta X & Y + sub ebx, edx ; EBX Delta X + sub eax, ecx ; EAX Delta Y + inc ebx ; EBX = Delta X + 1 + inc eax ; EAX = Delta Y + 1 + +;---------------------- Compute Adresse + mov edi, ecx + imul edi, [ScanLine] + add edi, edx + + mov [SaveEDX], edx + mov ebp, eax + mov esi, ecx + + mov eax, edi + mov cl, [BankShift] + shr eax, cl + SwitchBank ; Change Bank + + mov ecx, esi + mov eax, ebp + mov edx, [SaveEDX] + + mov esi, TabOffLine[ecx*4] + add esi, edx + add esi, Log + + and edi, [BankSize] ; bank size + mov ebp, edi ; BP For Bank + or edi, 0A0000h ; EDI = Phys + + mov edx, Screen_X + sub edx, ebx ; DX Delta Log + mov [DeltaLog], edx + + mov edx, [ScanLine] + sub edx, ebx ; DX Delta Phys +;---------------------- +Again2: add ebp, ebx + test ebp, [BankOver] + jnz NewBankNear0p2 + mov ecx, ebx + + SuperMovsD ; Macro + + add esi, [DeltaLog] + add edi, edx + add ebp, edx + test ebp, [BankOver] + jnz NewBankNear1p2 + dec eax + jne Again2 +;---------------------- + ret + +;----------------------------------------------------------------------------- + +NewBankNear0p2: and ebp, [BankSize] + + mov ecx, ebx + sub ecx, ebp + mov [SaveEBX], ebx ; Sauve EBX + mov ebx, ecx + + SuperMovsD ; Macro + + ChangeVideoBank : Macro + + mov edi, 0A0000h ; Begin Phys + mov ecx, ebp + mov ebx, ebp + + SuperMovsD ; Macro + + mov ebx, [SaveEBX] ; Restore EBX + + add esi, [DeltaLog] + add edi, edx + add ebp, edx + test ebp, [BankOver] + jnz NewBankNear1p2 + dec eax + jne Again2 + ret +;---------------------- +NewBankNear1p2: ChangeVideoBank ; Macro + sub edi, [BankSize] ; Stay in Phys + and ebp, [BankSize] + dec edi + dec eax + jne Again2 + + ret + +CopyBlockPhys endp + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- +; Flip() +; +; Attention: de Log (m‚moire) vers Phys (vid‚o ram) … modifier +; +Flip proc + + cmp [NonStdVESA], 0 + jne flip2 + + push esi + push edi + + mov esi, Log + + mov eax, 0 + SwitchBank + + mov edi, Phys + mov ecx, 04000h + rep movsd + + mov eax, 1 + SwitchBankDirect + + mov edi, Phys + mov ecx, 04000h + rep movsd + + mov eax, 2 + SwitchBankDirect + + mov edi, Phys + mov ecx, 04000h + rep movsd + + mov eax, 3 + SwitchBankDirect + + mov edi, Phys + mov ecx, 04000h + rep movsd + + mov eax, 4 + SwitchBankNoTest + + mov edi, Phys + mov ecx, 02C00h + rep movsd + + pop edi + pop esi + + ret + +flip2: push 479 + push 639 + push 0 + push 0 + call CopyBlockPhys + add esp, 16 + + ret + +Flip endp + +;---------------------------------------------------------------------------- +comment @ +{' EN COMMENTAIRE + +SuperIncrust MACRO + local Again, OkCopy, EndLine, UntilEnd + + push ebx + xor eax, eax ; Je cherche != 0 +Again: + xchg esi, edi + rep scasb ; Arret quand != 0 + jne OkCopy ; Ok Data Rencontr‚e(s) +;----------------------- + add esi, ebx + xchg esi, edi + jmp EndLine ; c'est fini! +;----------------------- +OkCopy: dec edi ; EDI un peu trop loin + inc ecx ; ECX trop Petit + + sub ebx, ecx ; EBX = Bytes Parcourus + add esi, ebx ; Maj ESI + + mov ebx, ecx ; EBX = Bytes Restant + repne scasb ; Combien != 0 ? + jne UntilEnd ; Tous jusqu'a fin (Quick! + + inc ecx ; Maj ECX + dec edi ; Maj EDI + sub ebx, ecx ; EBX = Nb Same Bytes + sub edi, ebx ; Recule EDI + xchg esi, edi ; Log <=> Phys + + xchg ecx, ebx + rep movsb ; movsD Plus Tard! + + mov ecx, ebx + jmp Again +UntilEnd: + sub edi, ebx + xchg esi, edi + mov ecx, ebx + rep movsb +EndLine: + pop ebx + + endm +;---------------------------------------------------------------------------- + +; Log -> Phys +; CopyBlockIncrust( x0, y0, x1, y1 ) +; +CopyBlockIncrust proc uses esi edi ebx ebp,\ + x0:DWORD, y0:DWORD, x1:DWORD, y1:DWORD + + mov edx, x0 + mov ecx, y0 + mov ebx, x1 + mov eax, y1 +;---------------------- Compute Delta X & Y + sub ebx, edx ; EBX Delta X + sub eax, ecx ; EAX Delta Y + inc ebx ; EBX = Delta X + 1 + inc eax ; EAX = Delta Y + 1 + mov word ptr [CptLine], ax +;---------------------- Compute Adresse + mov esi, TabOffLine[ecx*4] + add esi, edx + + mov edi, esi + + mov eax, edi + shr eax, 16 + SwitchBank ; Change Bank 64Kb + + add esi, Log + + xor ebp, ebp + and edi, 0FFFFh ; 64Kb bank + or edi, 0A0000h ; EDI = Phys + mov bp, di ; BP For Bank + + mov edx, Screen_X + sub edx, ebx ; DX Delta Screen +;---------------------- +Again: add bp, bx + jc NewBankNear0i + mov ecx, ebx + + SuperIncrust + + add esi, edx + add edi, edx + add bp, dx + jc NewBankNear1i + dec word ptr [CptLine] + jne short Again +;---------------------- + ret +;---------------------- +NewBankNear0i: mov ecx, ebx + sub ecx, ebp + push ebx ; Sauve EBX + mov ebx, ecx + + SuperIncrust ; Macro + + ChangeVideoBank : Macro + + mov edi, 0A0000h ; Begin Phys + mov ecx, ebp + mov ebx, ecx + + SuperIncrust + + pop ebx ; Restore EBX + + add esi, edx + add edi, edx + add bp, dx + jc NewBankNear1i + dec word ptr [CptLine] + jne Again + ret +;---------------------- +NewBankNear1i: ChangeVideoBank ; Macro + sub edi, 010000h ; Stay in Phys + dec word ptr [CptLine] + jne Again + ret +CopyBlockIncrust endp +;---------------------------------------------------------------------------- + +;---------------------------------------------------------------------------- +FlipComp proc uses esi edi ebx ebp,\ + log0:DWORD, log1:DWORD + + mov esi, log0 ; ESI = log0 + mov edi, log1 ; EDI = log1 + call Vsync +;------------------------------------------------------- +Bank0: mov eax, 0 ; Bank 0 + SwitchBank ; De l'ecran Phys + mov eax, esi ; EAX = log0 + sub eax, 0A0000h ; EAX = log0-Phys + mov ecx, 04000h ; 64Kb +Cont0: + rep cmpsd ; Cherche Difference + jne Diff0 ; Il y a Difference +;---------------------- +Bank1: mov eax, 1 ; Bank 1 + SwitchBank ; De l'ecran Phys + mov eax, esi ; Maj offset Phys + sub eax, 0A0000h ; Car Nouvelle Bank + mov ecx, 04000h ; 64Kb +Cont1: + rep cmpsd ; Cherche Difference + jne Diff1 ; Il y a Difference +;---------------------- +Bank2: mov eax, 2 ; Bank 1 + SwitchBank ; De l'ecran Phys + mov eax, esi ; Maj offset Phys + sub eax, 0A0000h ; Car Nouvelle Bank + mov ecx, 04000h ; 64Kb +Cont2: + rep cmpsd ; Cherche Difference + jne Diff2 ; Il y a Difference +;---------------------- +Bank3: mov eax, 3 ; Bank 1 + SwitchBank ; De l'ecran + mov eax, esi ; Maj offset Phys + sub eax, 0A0000h ; Car Nouvelle Bank + mov ecx, 04000h ; 64Kb +Cont3: + rep cmpsd ; Cherche Difference + jne Diff3 ; Il y a Difference +;---------------------- +Bank4: mov eax, 4 ; Bank 1 + SwitchBank ; De l'ecran + mov eax, esi ; Maj offset Phys + sub eax, 0A0000h ; Car Nouvelle Bank + mov ecx, 02C00h ; 64Kb +Cont4: + rep cmpsd ; Cherche Difference + jne Diff4 ; Il y a Difference +;---------------------- + ret +;------------------------------------------------------- +Diff0: sub esi, 4 ; Recule ESI + sub edi, 4 ; Recule EDI + inc ecx ; One More + mov edx, esi ; Sauve ESI + mov ebx, ecx ; Sauve ECX + + repne cmpsd ; Combien ? + sub edi, 4 ; Recule EDI + mov esi, edx ; Restore ESI + mov edx, edi ; Sauve EDI + inc ecx ; One More + sub ebx, ecx ; Calcul Nb Diffs + xchg ecx, ebx ; Sauve ECX + mov edi, esi ; Calcul + sub edi, eax ; Adresse Phys + rep movsd ; Ecriture Diffs + mov edi, edx ; Restore EDI + add ecx, ebx ; Restore ECX + je Bank1 ; Fin De cette Bank + jmp Cont0 ; Again and Again... +;---------------------- +Diff1: sub esi, 4 ; Recule ESI + sub edi, 4 ; Recule EDI + inc ecx ; One More + mov edx, esi ; Sauve ESI + mov ebx, ecx ; Sauve ECX + + repne cmpsd ; Combien ? + sub edi, 4 ; Recule EDI + mov esi, edx ; Restore ESI + mov edx, edi ; Sauve EDI + inc ecx ; One More + sub ebx, ecx ; Calcul Nb Diffs + xchg ecx, ebx ; Sauve ECX + mov edi, esi ; Calcul + sub edi, eax ; Adresse Phys + rep movsd ; Ecriture Diffs + mov edi, edx ; Restore EDI + add ecx, ebx ; Restore ECX + je Bank2 ; Fin De cette Bank + jmp Cont1 ; Again and Again... +;---------------------- +Diff2: sub esi, 4 ; Recule ESI + sub edi, 4 ; Recule EDI + inc ecx ; One More + mov edx, esi ; Sauve ESI + mov ebx, ecx ; Sauve ECX + + repne cmpsd ; Combien ? + sub edi, 4 ; Recule EDI + mov esi, edx ; Restore ESI + mov edx, edi ; Sauve EDI + inc ecx ; One More + sub ebx, ecx ; Calcul Nb Diffs + xchg ecx, ebx ; Sauve ECX + mov edi, esi ; Calcul + sub edi, eax ; Adresse Phys + rep movsd ; Ecriture Diffs + mov edi, edx ; Restore EDI + add ecx, ebx ; Restore ECX + je Bank3 ; Fin De cette Bank + jmp Cont2 ; Again and Again... +;---------------------- +Diff3: sub esi, 4 ; Recule ESI + sub edi, 4 ; Recule EDI + inc ecx ; One More + mov edx, esi ; Sauve ESI + mov ebx, ecx ; Sauve ECX + + repne cmpsd ; Combien ? + sub edi, 4 ; Recule EDI + mov esi, edx ; Restore ESI + mov edx, edi ; Sauve EDI + inc ecx ; One More + sub ebx, ecx ; Calcul Nb Diffs + xchg ecx, ebx ; Sauve ECX + mov edi, esi ; Calcul + sub edi, eax ; Adresse Phys + rep movsd ; Ecriture Diffs + mov edi, edx ; Restore EDI + add ecx, ebx ; Restore ECX + je Bank4 ; Fin De cette Bank + jmp Cont3 ; Again and Again... +;---------------------- +Diff4: sub esi, 4 ; Recule ESI + sub edi, 4 ; Recule EDI + inc ecx ; One More + mov edx, esi ; Sauve ESI + mov ebx, ecx ; Sauve ECX + + repne cmpsd ; Combien ? + sub edi, 4 ; Recule EDI + mov esi, edx ; Restore ESI + mov edx, edi ; Sauve EDI + inc ecx ; One More + sub ebx, ecx ; Calcul Nb Diffs + xchg ecx, ebx ; Sauve ECX + mov edi, esi ; Calcul + sub edi, eax ; Adresse Phys + rep movsd ; Ecriture Diffs + mov edi, edx ; Restore EDI + add ecx, ebx ; Restore ECX + jne Cont4 ; Again and Again + ret +FlipComp endp +;---------------------------------------------------------------------------- + + .386 +FlipComp386 proc uses ds es si di, \ + scr0:DWORD, scr1:DWORD + + mov dx, word ptr [scr0+2] ; dx = Log0 + mov ds, word ptr [scr1+2] ; ds = Log1 + mov ax, 0A000h ; Phys + xor si, si ; Maj Offset + mov di, si ; a zero + mov cx, 07D00h/2 ; 100 Lines * 4 (LONG) +Aqui: + mov es, dx ; es = Log0 + rep cmpsd ; Comp Log0 & Log1 + je TheEnd ; No difference, End + + mov bp, si ; Save offset in BP + mov bx, cx ; Save Nb Left + repne cmpsd ; How many difference(s) ? + jne UntilEnd ; All left are different... + + mov es, ax + sub bp, 4 ; Maj BP + mov si, bp ; Maj Offset SI + mov di, bp ; & DI + sub bx, cx ; How much in BX + xchg cx, bx ; Now in CX + rep movsd ; Copy CX Bytes Log1->Phys + + mov cx, bx ; Restore Bytes Left + inc cx + inc cx + jmp short Aqui ; Twist again +UntilEnd: + mov es, ax ; ES = Phys + sub bp, 4 ; Maj BP + mov si, bp ; Maj offset SI + mov di, bp ; & DI + sub bx, cx ; How much left in BX + mov cx, bx ; Now in CX ( ex: XCHG CX,BX ) + inc cx + inc cx + rep movsd +TheEnd: .8086 + ret +FlipComp386 endp + + + +;---------------------------------------------------------------------------- +opt_stos_line macro + + mov eax, ecx + shr ecx, 2 + rep movsd + and eax, 3 + mov ecx, eax + rep movsb + endm +;---------------------------------------------------------------------------- +; Flip de Log vers Phys + + +BlockLogPhys proc uses es ds si di,\ + sox:DWORD,soy:DWORD,sol:DWORD,soh:DWORD,\ + dex:DWORD,dey:DWORD + + + mov esi, soy + mov esi, TabOffLine[esi*4] + add esi, soy + mov edi, esi + + mov eax, edi + shr eax, 16 + SwitchBank + + add esi, Log + add edi, Phys + + + + mov di,bx + xor ebx,ebx + + mov ax,0A000h + mov es,ax + + mov ax, sol + mov cs:word ptr[patch_larg1],ax + mov cs:word ptr[patch_larg2],ax + mov cs:word ptr[patch_larg3],ax + neg ax + add ax,640 + mov cs:word ptr[patch_deoff],ax + + mov ax,320 + sub ax, sol + mov cs:word ptr[patch_sooff],ax + + jmp $+2 + + mov dx, soh + +Aqui: mov ebx, edi + add ebx, sol + jnc ok1 + + mov ecx, sol + sub ecx, ebx + opt_stos_line + + mov eax, BankCurrent + inc eax + SwitchBank + + mov ecx, ebx + opt_stos_line + + jmp Next + +ok1: xor ecx, ecx + mov ecx, sol + opt_stos_line + +Next: mov edi, ebx +patch_deoff equ $+2 + add edi, 1234h + jnc ok2 + + mov eax, BankCurrent + inc eax + push eax + SwitchBank + +ok2: +patch_sooff equ $+2 + add esi,1234h + + dec edx + jnz Aqui + + ret + +BlockLogPhys endp + +} +@ +;---------------------------------------------------------------------------- +; The + End + + + + + + diff --git a/LIB386/LIB_SVGA/S_PLOT.ASM b/LIB386/LIB_SVGA/S_PLOT.ASM new file mode 100644 index 0000000..8879a99 --- /dev/null +++ b/LIB386/LIB_SVGA/S_PLOT.ASM @@ -0,0 +1,101 @@ +;---------------------------------------------------------------------------- +; S_PLOT.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386p + jumps + .model SMALL, SYSCALL + + .data + + include svga.ash + + .code + + public NoLanguage Plot + public NoLanguage GetPlot + +;---------------------------------------------------------------------------- +; Plot( x, y, coul ) +; +Plot proc uses esi,\ + XX:DWORD, YY:DWORD, CC:DWORD + mov eax, XX + mov esi, YY +;---------------------- + cmp eax, ClipXmin + jl Plot_End + cmp eax, ClipXmax + jg Plot_End + cmp esi, ClipYmin + jl Plot_End + cmp esi, ClipYmax + jg Plot_End +;---------------------- + mov esi, TabOffLine[esi*4] + + add esi, Log + + add esi, eax + + mov al, byte ptr [CC] + + mov [esi], al +Plot_End: + ret +Plot endp +;---------------------------------------------------------------------------- +; GetPlot( x, y, coul ) +; +GetPlot proc uses esi,\ + XX:DWORD, YY:DWORD + mov eax, XX + mov esi, YY +;---------------------- + cmp eax, ClipXmin + jl GetPlot_End + cmp eax, ClipXmax + jg GetPlot_End + cmp esi, ClipYmin + jl GetPlot_End + cmp esi, ClipYmax + jg GetPlot_End +;---------------------- + + mov esi, TabOffLine[esi*4] + + add esi, Log + + add esi, eax + + xor eax, eax + mov al, [esi] + ret +GetPlot_End: + xor eax, eax + ret +GetPlot endp +;---------------------------------------------------------------------------- +; The + End + + + + + + + + + + + + + + + + + + + + + diff --git a/LIB386/LIB_SVGA/S_POLY.ASM b/LIB386/LIB_SVGA/S_POLY.ASM new file mode 100644 index 0000000..0381777 --- /dev/null +++ b/LIB386/LIB_SVGA/S_POLY.ASM @@ -0,0 +1,1376 @@ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; S_POLY.ASM 386 +; (c) Adeline 1993 +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + .486p + jumps + .model SMALL, SYSCALL + + .data + + include svga.ash + + public NoLanguage TabPoly + public NoLanguage TabVerticD + public NoLanguage TabVerticG + public NoLanguage TabCoulG + public NoLanguage TabCoulD + public NoLanguage TabGauche + public NoLanguage TabDroite + public NoLanguage TabX0 + public NoLanguage TabY0 + public NoLanguage TabX1 + public NoLanguage TabY1 + + public NoLanguage Xmin + public NoLanguage Ymin + public NoLanguage Xmax + public NoLanguage Ymax + public NoLanguage NbPolyPoints + public NoLanguage TypePoly + +;------------------------------------------------------------------------- + +EVEN + +Xmin dw 00 ; encombrement polygone +Ymin dw 00 +Xmax dw 00 +Ymax dw 00 + +TypePoly dw 00 + +NbPolyPoints dw 00 ; 32 max ? + +TabPoly dw 1234h + dw 32*3 dup(00) +TabPolyClip dw 32*3 dup(00) + + ; ne pas changer l'ordre de ce qui suit + + +TabGauche label WORD +TabVerticG dw 480 dup(00) +TabDroite label WORD +TabVerticD dw 480 dup(00) +TabX0 label WORD +TabCoulG dw 480 dup(00) +TabY0 label WORD +TabCoulD dw 480 dup(00) + +TabX1 dw 480 dup(0) +TabY1 dw 480 dup(0) + + +;-------------------------------------------------------------------------- + +boucle dw 00 ; nb points +newboucle dw 00 +flagrencadre dw 00 + +intensite_1 db 0 +intensite_2 db 0 +last_intensite db 0 + db 0 ; dummy + +coul1 dw 0 + +ALIGN 4 + +offtabpoly dd offset TabPoly + dd offset TabPolyClip + +;-------------------------------------------------------------------------- + .code + + public NoLanguage ComputePoly + public NoLanguage ComputePoly_A + public NoLanguage ComputeSphere + public NoLanguage ComputeSphere_A + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛÛßßß ÛßßßÛ Û Û Ûßßßß ÛßßßÛ Ûßßßß +; ßßßßÛ ÛÛßßß ÛÛßßÛ ÛÛßß ÛÛßÛß ÛÛßß +; ßßßßß ßß ßß ß ßßßßß ßß ß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +ComputeSphere proc uses esi edi ebp ebx,\ + pxc:DWORD, pyc:DWORD, rayon:DWORD + + mov ecx, pxc + mov esi, pyc + mov ebp, rayon + + call ComputeSphere_A + + ret + +ComputeSphere endp + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +ComputeSphere_A proc ; uses si di bp + + ; EBP = rayon + ; ECX = x screen centre + ; ESI = y screen centre + + ; xc equ ecx + ; yc equ esi + + ; px equ edi + ; py equ edx + ; sum equ ebp + + mov edi, ebp + xor edx, edx + neg ebp + + xor bx, bx + + mov eax, esi + sub eax, edi ; esi - rayon + cmp eax, [ClipYmax] + jg nosphere + cmp eax, [ClipYmin] + jge csc0 + inc bx + mov eax, [ClipYmin] +csc0: mov [Ymin], ax + + lea eax, [esi+edi] ; esi + rayon + cmp eax, [ClipYmin] + jl nosphere + cmp eax, [ClipYmax] + jle csc1 + inc bx + mov eax, [ClipYmax] +csc1: mov [Ymax], ax + + lea eax, [ecx+edi] ; ecx + rayon + cmp eax, [ClipXmin] + jl nosphere + cmp eax, [ClipXmax] + jle csc2 + inc bx + +csc2: mov eax, ecx + sub eax, edi ; ecx - rayon + cmp eax, [ClipXmax] + jg nosphere + + cmp eax, [ClipXmin] + jge csc3 + inc bx + +csc3: or bx, bx + jnz clipping + +;------------------------------------------------------------------------ +; EVEN + ALIGN 4 +nccs0: cmp edx, edi ; while( edx <= edi ) + jg fin + + lea ebx, [esi+edx] + lea eax, [ecx+edi] + mov word ptr[ TabVerticD + ebx*2 ], ax + mov ax, cx + sub ax, di + mov word ptr[ TabVerticG + ebx*2 ], ax + + mov ebx, esi + sub ebx, edx + mov word ptr[ TabVerticG + ebx*2 ], ax + lea eax, [ecx+edi] + mov word ptr[ TabVerticD + ebx*2 ], ax + + add ebp, edx + jnc ncnoovf + + lea ebx, [esi+edi] + lea eax, [ecx+edx] + mov word ptr[ TabVerticD + ebx*2 ], ax + mov ax, cx + sub ax, dx + mov word ptr[ TabVerticG + ebx*2 ], ax + + mov ebx, esi + sub ebx, edi + mov word ptr[ TabVerticG + ebx*2 ], ax + lea eax, [ecx+edx] + mov word ptr[ TabVerticD + ebx*2 ], ax + + dec edi + sub ebp, edi + +ncnoovf: inc edx + jmp nccs0 + +fin: mov eax, 1 + ret + +;------------------------------------------------------------------------ +clipping: +; EVEN + ALIGN 4 +cs0: cmp edx, edi ; while( edx <= edi ) + jg finclip + + lea ebx, [esi+edx] + cmp bx, [Ymax] + jg cs1 + cmp bx, [Ymin] + jl cs1 + + ; gauche + mov eax, ecx + sub eax, edi + cmp eax, [ClipXmin] + jl nocxi + cmp eax, [ClipXmax] + jle nocxi2 + mov ax, bx + dec ax + mov [Ymax], ax + jmp short cs1 +nocxi: mov eax, [ClipXmin] +nocxi2: mov word ptr[ TabVerticG + ebx*2 ], ax + + ; droite + lea eax, [ecx+edi] + cmp eax, [ClipXmax] + jg nocxa + cmp eax, [ClipXmin] + jge nocxa2 + mov ax, bx + dec ax + mov [Ymax], ax + jmp short cs1 +nocxa: mov eax, [ClipXmax] +nocxa2: mov word ptr[ TabVerticD + ebx*2 ], ax + +cs1: mov ebx, esi + sub ebx, edx + cmp bx, [Ymax] + jg cs2 + cmp bx, [Ymin] + jl cs2 + ; gauche + mov eax, ecx + sub eax, edi + cmp eax, [ClipXmin] + jl nocxia + cmp eax, [ClipXmax] + jle nocxia2 + lea eax, [ebx+1] + mov [Ymin], ax + jmp short cs2 +nocxia: mov eax, [ClipXmin] +nocxia2: mov word ptr[ TabVerticG + ebx*2 ], ax + ; droite + lea eax, [ecx+edi] + cmp eax, [ClipXmax] + jg nocxaa + cmp eax, [ClipXmin] + jge nocxaa2 + lea eax, [ebx+1] + mov [Ymin], ax + jmp short cs2 +nocxaa: mov eax, [ClipXmax] +nocxaa2: mov word ptr[ TabVerticD + ebx*2 ], ax + +cs2: add ebp, edx + jnc noovf + + lea ebx, [esi+edi] + cmp bx, [Ymax] + jg cs3 + cmp bx, [Ymin] + jl cs3 + ; gauche + mov eax, ecx + sub eax, edx + cmp eax, [ClipXmin] + jl nocxib + cmp eax, [ClipXmax] + jle nocxib2 + mov ax, bx + dec ax + mov [Ymax], ax + jmp short cs3 +nocxib: mov eax, [ClipXmin] +nocxib2: mov word ptr[ TabVerticG + ebx*2 ], ax + mov word ptr[ TabVerticG + ebx*2 ], ax + ; droite + lea eax, [ecx+edx] + cmp eax, [ClipXmax] + jg nocxab + cmp eax, [ClipXmin] + jge nocxab2 + mov ax, bx + dec ax + mov [Ymax], ax + jmp short cs3 +nocxab: mov eax, [ClipXmax] +nocxab2: mov word ptr[ TabVerticD + ebx*2 ], ax + +cs3: mov ebx, esi + sub ebx, edi + cmp bx, [Ymax] + jg cs4 + cmp bx, [Ymin] + jl cs4 + ; gauche + mov eax, ecx + sub eax, edx + cmp eax, [ClipXmin] + jl nocxic + cmp eax, [ClipXmax] + jle nocxic2 + lea eax, [ebx+1] + mov [Ymin], ax + jmp short cs4 +nocxic: mov eax, [ClipXmin] +nocxic2: mov word ptr[ TabVerticG + ebx*2 ], ax + ; droite + lea eax, [ecx+edx] + cmp eax, [ClipXmax] + jg nocxac + cmp eax, [ClipXmin] + jge nocxac2 + lea eax, [ebx+1] + mov [Ymin], ax + jmp short cs4 +nocxac: mov eax, [ClipXmax] +nocxac2: mov word ptr[ TabVerticD + ebx*2 ], ax + +cs4: dec edi + sub ebp, edi + +noovf: inc edx + jmp cs0 + +finclip: mov ax, word ptr[Ymin] + cmp ax, word ptr[Ymax] + +; modif pas de sphere d'une ligne ??? + + jge nosphere + + mov eax, 1 ; ok sphere + ret + +nosphere: xor eax, eax + ret + +ComputeSphere_A endp + + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛßßßÛ Û Û Üß Ûßßßß ÛßßßÛ ÛÛÜ Û Ûßßßß +; ÛÛßßß ÛÛ Û ÛÛ ÛÛß ÛÛ ßÛ ÛÛ Û ÛÛßÛÛ ÛÛßß +; ßß ßßßßß ßßßßß ßß ßßßßß ßßßßß ßß ß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +ComputePoly_A proc uses edi ebx + + movzx ecx, word ptr [NbPolyPoints] + + mov esi, offset TabPoly + + mov [offtabpoly ], esi + mov [offtabpoly+4], offset TabPolyClip + + mov [boucle], cx + + mov word ptr [flagrencadre], 0 + + mov ax, 32767 + mov bx, ax ; Xmin + mov bp, ax ; Ymin + mov ax, -32768 + mov di, ax ; Ymax + mov dx, ax ; Xmax + + jmp short encadre + +tt0a: mov bx, ax + jmp short tt0 +tt1a: mov dx, ax + jmp short tt1 +tt2a: mov bp, ax + jmp short tt2 +tt3a: mov di, ax + jmp short tt3 + +; EVEN + ALIGN 4 +encadre: add esi, 2 ; saute couleur + + lodsw + cmp ax, bx ; X + jl tt0a +tt0: cmp ax, dx + jg tt1a +tt1: + lodsw ; Y + cmp ax, bp + jl tt2a +tt2: cmp ax, di + jg tt3a +tt3: + dec ecx + jnz encadre + + mov cx, di + mov edi, esi + mov esi, [offtabpoly] ; offset TabPoly + + movsw + movsd ; transitivit‚ der point + + mov [Ymin], bp + mov [Xmax], dx + mov [Ymax], cx + mov [Xmin], bx + + cmp cx, bp ; si Ymin > Ymax fin poly + jl fin_poly + +;------------------------------------------------------------------------ + +CLIP: mov eax, [ClipXmin] + cmp [Xmin], ax + jge cl1 ; clipped + cmp [Xmax], ax ; outside screen + jl fin_poly + call ClipGauche + jz fin_poly + +cl1: mov eax, [ClipXmax] + cmp [Xmax], ax + jle cl2 ; clipped + cmp [Xmin], ax ; outside screen + jg fin_poly + call ClipDroit + jz fin_poly + +cl2: mov eax, [ClipYmin] + cmp [Ymin], ax + jge cl3 ; clipped + cmp [Ymax], ax ; outside screen + jl fin_poly + call ClipHaut + jz fin_poly + +cl3: mov eax, [ClipYmax] + cmp [Ymax], ax + jle cl4 ; clipped + cmp [Ymin], ax ; outside screen + jg fin_poly + call ClipBas + jz fin_poly +cl4: + +;------------------------------------------------------------------------ + + cmp word ptr[flagrencadre], 0 + jz filltabvertic + jmp short rencadre + +tr21a: mov bx, ax + jmp short tr21 +tr22a: mov dx, ax + jmp short tr22 + +rencadre: ; cherche si nouveau Ymin ou Ymax + + mov esi, [offtabpoly] ; TabPoly 1 ou 2 + + movzx ecx, [boucle] + mov bx, 32767 ; Ymin + mov dx, bx + inc dx ; - 32768 + +; EVEN + ALIGN 4 +tr20: add esi, 4 ; saute coul et X + lodsw ; read Y + cmp ax, bx ; Ymin + jl short tr21a ; new Ymin +tr21: cmp ax, dx ; Ymax + jg short tr22a ; new Ymax +tr22: dec ecx + jnz tr20 + + mov [Ymin], bx + mov [Ymax], dx + + cmp bx,dx ; si Ymin > Ymax fin poly + +; modif pas de poly d'une ligne (jg -> jge) + + jge fin_poly ; + +;------------------------------------------------------------------------ + +filltabvertic: ; draw les lines inter sommets + + mov esi, [offtabpoly] ; TabPoly 1 ou 2 + + mov ax, [esi] ; couleur sommet + mov [intensite_2], al + mov [last_intensite], al + + mov bx, [esi+2] + mov cx, [esi+4] + add esi, 6 + + ; BX = X0 + ; CX = Y0 + +; EVEN + ALIGN 4 +gtg0: mov al, [last_intensite] + mov [intensite_1], al + + mov ax, [esi] ; voir pour prestock 2 couls + mov [intensite_2], al + mov [last_intensite], al + + mov dx, [esi+2] ; X + mov ax, [esi+4] ; Y + add esi, 6 + + ; DX = X1 + ; AX = Y1 + + cmp ax, cx ; mettre les 2 X dans TabVertic + je same_y ; FAUX + + push dx + push ax + + jl y_monte + +;úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú +; Y descend donc buffer gauche + + mov bp, ax + sub bp, cx ; bp abs delta y + + cmp bx, dx ; X0 < X1 + jle gtg1 ; oui c'est bon + + xchg bx, dx ; remet X0 < X1 + xchg ax, cx ; fait suivre Y0 et Y1 + mov ax, word ptr[intensite_1] ; couls aussi + xchg al, ah + mov word ptr[intensite_1], ax + std +gtg1: + movzx edi, cx ; CX lig start + shl edi, 1 + + mov cx, bp ; abs delta y + + mov ebp, edi ; save lig start * 4 + add edi, offset TabVerticG + + mov ax, dx ; x0 + sub ax, bx ; x1 delta X (>0) + + shl eax, 16 + xor edx, edx + div ecx + + xchg edx, eax + shr ax, 1 + add ax, 7FFFh + rol edx, 16 + shl eax, 16 + mov ax, bx + mov bx, cx + + ; EAX = .cumul:X + + ; EDX = .DeltaX:DeltaX + + add cx, 2 + shr cx, 1 + jc even0 + add eax, edx ; init Carry + rcl cx, 1 + sub ax, dx + shr cx, 1 + jmp short lt01 +even0: add eax, edx ; init Carry + rcl cx, 1 + sub ax, dx + shr cx, 1 +; EVEN + ALIGN 4 +lt0: stosw + adc eax, edx +lt01: stosw + adc eax, edx + dec ecx + jnz lt0 + +; ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú +; fill tab coul G + + cmp word ptr[ TypePoly ], POLY_GOURAUD + jb gtg3 + + mov cx, bx ; delta Y + + mov edi, ebp ; lig start + add edi, offset TabCoulG + + mov ax, word ptr[intensite_1]; + mov bx, ax + sub ah, al ; delta intensite + jc ftg0 + xor dx, dx + mov al, dl + div cx + + xchg dx, ax ; DX step intensite + shr al, 1 + add al, 7Fh + mov ah, bl ; AH intensite start + + add cx, 2 + shr cx, 1 ; divise par 2 + jnc xloopg1 ; impair ? + + ALIGN 4 +xloopg: stosw + add ax, dx ; cumul step +xloopg1: stosw + add ax, dx ; cumul step + dec ecx + jnz xloopg + +gtg3: cld + pop cx ; XY1 = XY2 + pop bx + + dec word ptr[boucle] + jnz gtg0 + + mov eax, 1 ; ok poly drawed (perhaps clipped) + ret + + +;úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú + +ftg0: + neg ah + xor dx, dx + mov al, dl + div cx + + xchg dx, ax ; DX step intensite + shr al, 1 + neg al + add al, 7fh + mov ah, bl ; AH intensite start + + + add cx, 2 + shr cx, 1 ; divise par 2 + jnc xloopg01 ; impair ? +; EVEN + ALIGN 4 +xloopg0: stosw + sub ax, dx ; cumul step +xloopg01: stosw + sub ax, dx ; cumul step + dec ecx + jnz xloopg0 + +;úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú + + cld + pop cx ; XY1 = XY2 + pop bx + + dec word ptr[boucle] + jnz gtg0 + + mov eax, 1 ; ok poly drawed (perhaps clipped) + ret + + +;úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú + +same_y: + mov bp, dx +; +; cmp bx, dx ; X0 <= X1 +; jl gtg1s ; oui c'est bon +; xchg bx, dx ; remet X0 < X1 +; mov ax, word ptr[intensite_1] ; couls aussi +; xchg al, ah +; mov word ptr[intensite_1], ax +;gtg1s: +; movzx edi, cx +; mov word ptr[edi*2+TabVerticG], bx +; mov word ptr[edi*2+TabVerticD], dx +; +; xor al, al +; mov ah, [intensite_1] +; +; mov word ptr[edi+TabCoulG], ax +; +; mov ah, [intensite_1+1] +; mov word ptr[edi+TabCoulD], ax +; +; cld + mov bx, bp + + dec word ptr[boucle] + jnz gtg0 + + mov eax, 1 ; ok poly drawed (perhaps clipped) + ret + +;úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú +; Y monte donc buffer droit + +y_monte: mov bp, cx + sub bp, ax ; bp abs delta y + std + + cmp bx, dx ; X0 >= X1 + jge gtg1m ; oui c'est bon + + xchg bx, dx ; remet X0 < X1 + xchg ax, cx ; fait suivre Y0 et Y1 + mov ax, word ptr[intensite_1] ; couls aussi + xchg al, ah + mov word ptr[intensite_1], ax + cld +gtg1m: + movzx edi, cx + shl edi, 1 + + mov cx, bp ; abs delta y + + mov ebp, edi ; save CX lig start * 2 + add edi, offset TabVerticD + + mov ax, bx ; dx ; x0 + sub ax, dx ; bx ; x1 delta X + + shl eax, 16 + xor edx, edx + div ecx + + xchg edx, eax + shr ax, 1 + neg ax + add ax, 7FFFh + rol edx, 16 + shl eax, 16 + mov ax, bx + mov bx, cx ; save delta Y + + add cx, 2 + shr cx, 1 + jc even0m + sub eax, edx ; init Carry + rcl cx, 1 + add ax, dx + shr cx, 1 + jmp short lt01m +even0m: sub eax, edx ; init Carry + rcl cx, 1 + add ax, dx + shr cx, 1 +; EVEN + ALIGN 4 +lt0m: stosw ; stock X + sbb eax, edx ; add cumul +lt01m: stosw ; stock X + sbb eax, edx ; add cumul + dec ecx + jnz lt0m + +; ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú ú +; fill tab coul D + + cmp word ptr[ TypePoly ], POLY_GOURAUD + jb short gtg3m + + mov cx, bx ; delta Y + + mov edi, ebp ; lig start + add edi, offset TabCoulD + + mov ax, word ptr[intensite_1]; + mov bx, ax + sub ah, al ; delta intensite + jc ftd0 + + xor dx, dx + mov al, dl + div cx ; CX deltay + + xchg dx, ax ; DX step intensite + shr al, 1 ; reste / 2 + add al, 7Fh + mov ah, bl ; AH intensite start + + add cx, 2 + shr cx, 1 ; divise par 2 + jnc xloop1 ; impair ? + + ALIGN 4 +xloop: stosw + add ax, dx ; cumul step +xloop1: stosw + add ax, dx ; cumul step + dec ecx + jnz xloop + +;úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú +gtg3m: cld + pop cx ; XY1 = XY2 + pop bx + + dec word ptr[boucle] + jnz gtg0 + + mov eax, 1 ; ok poly drawed (perhaps clipped) + ret + +;úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú + +ftd0: + neg ah + xor dx, dx + mov al ,dl + div cx ; CX deltay + + xchg dx, ax ; DX step intensite + shr al, 1 ; reste / 2 + neg al + add al, 7Fh + mov ah, bl ; AH intensite start + + add cx, 2 + shr cx, 1 ; divise par 2 + jnc xloopn1 ; impair ? + + ALIGN 4 +xloopn: stosw + sub ax, dx ; cumul step +xloopn1: stosw + sub ax, dx ; cumul step + dec ecx + jnz xloopn + +;úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú + + cld + pop cx ; XY1 = XY2 + pop bx + + dec word ptr[boucle] + jnz gtg0 + + mov eax, 1 ; ok poly drawed (perhaps clipped) + ret + + +;úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú + +fin_poly: xor eax, eax ; no_poly + ret + +ComputePoly_A endp + +;------------------------------------------------------------------------ + +ComputePoly proc uses esi ebp + + mov [offtabpoly], offset TabPoly + call ComputePoly_A + ret + +ComputePoly endp + +;------------------------------------------------------------------------ +;------------------------------------------------------------------------ +;------------------------------------------------------------------------ + +ClipGauche proc near + + mov word ptr[newboucle], 0 + mov word ptr[flagrencadre], 1 + + mov esi, [offtabpoly] + mov edi, [offtabpoly+4] + + mov bp, [esi] ; BP = C0 + mov cx, [esi+2] ; CX = X0 + mov bx, [esi+4] ; BX = Y0 + add esi, 6 +; EVEN + ALIGN 4 +cfg: mov ax, [esi] ; C1 + mov [coul1], ax + mov ax, [esi+2] ; AX = X1 + mov dx, [esi+4] ; DX = Y1 + add esi, 6 + + cmp cx, word ptr[ClipXmin] ; test si X0 clipp‚ + jl cfg0 ; oui clipp‚ + + mov [edi], bp + mov [edi+2], cx ; pas clipp‚ on stock + mov [edi+4], bx + add edi, 6 + inc word ptr[newboucle] ; 1 point de plus + + cmp ax, word ptr[ClipXmin] ; test si X1 clipp‚ + jl cfg1 ; si oui on clip + +cfg2: mov bp, [coul1] + mov ecx, eax ; XYC0 = XYC1 + mov ebx, edx ; et on passe au suivant + + dec word ptr[boucle] + jnz cfg + jmp cfg3 ; fini + +cfg0: cmp ax, word ptr[ClipXmin] ; test si X2 clipp‚ + jl cfg2 ; oui 1 et 2 clipp‚ on oublie le 1 + ; 1er clipp‚ on ajuste coor +cfg1: ; BP = C0 + ; CX = X0 BX < DX + ; BX = Y0 + ; C1 + ; DX = X1 + ; AX = Y1 + + push eax + push edx + push [coul1] + + cmp ax, cx ; Ajuste X0 X1 pour clip 2 poly coll‚s + jl cfg4 + xchg eax, ecx + xchg edx, ebx + xchg bp, [coul1] +cfg4: + sub [coul1], bp ; coul1 = DeltaCoul + shl ebp, 16 ; save coul0 + + sub edx, ebx ; DX = DeltaY BX = Y0 + sub eax, ecx ; AX = DeltaX + mov bp, word ptr[ClipXmin] + sub bp, cx ; BP = deltaClipX + mov ecx, eax ; CX = DeltaX + mov eax, ebp ; AX = deltaClipX + imul dx ; AX = AX * deltaY + idiv cx ; AX = AX / deltaX + add ebx, eax ; Y0 = Y0 + AX + + mov ax, word ptr[ClipXmin] ; X0 + mov [edi+2], ax + mov [edi+4], bx + + cmp word ptr[ TypePoly ], POLY_GOURAUD + jb cfg5 + + mov ax, [coul1] ; AX = DeltaCoul + imul bp ; AX = AX * DeltaClipX + idiv cx ; AX = AX / deltaX + shr ebp, 16 ; BP = Coul0 + add eax, ebp ; AX = AX + coul0 + + mov [edi], ax +cfg5: + add edi, 6 + inc word ptr[newboucle] ; new point + + pop bp ; POP C1 dans C0 + pop ebx ; POP Y1 dans Y0 + pop ecx ; POP X1 dans X0 + + dec word ptr[boucle] + jnz cfg + +cfg3: mov eax, [offtabpoly] ; inversion pointeurs buffer + mov esi, [offtabpoly+4] + mov [offtabpoly+4], eax + mov [offtabpoly], esi + + movsw + movsd ; transitivit‚ der point + + mov ax, [newboucle] + mov [boucle], ax + or ax, ax + ret + +ClipGauche endp + +;------------------------------------------------------------------------ + +ClipDroit proc near + + mov word ptr[newboucle], 0 + mov word ptr[flagrencadre], 1 + + mov esi, [offtabpoly] + mov edi, [offtabpoly+4] + + mov bp, [esi] ; BP = C0 + mov cx, [esi+2] ; CX = X0 + mov bx, [esi+4] ; BX = Y0 + add esi, 6 +; EVEN + ALIGN 4 +cfg: mov ax, [esi] ; C1 + mov [coul1], ax + mov ax, [esi+2] ; AX = X1 + mov dx, [esi+4] ; DX = Y1 + add esi, 6 + + cmp cx, word ptr[ClipXmax] ; test si X0 clipp‚ + jg cfg0 ; oui clipp‚ + + mov [edi], bp + mov [edi+2], cx ; pas clipp‚ on stock + mov [edi+4], bx + add edi, 6 + inc word ptr[newboucle] ; 1 point de plus + + cmp ax, word ptr[ClipXmax] ; test si X1 clipp‚ + jg cfg1 ; si oui on clip + +cfg2: mov bp, [coul1] + mov ecx, eax ; XYC0 = XYC1 + mov ebx, edx ; et on passe au suivant + + dec word ptr[boucle] + jnz cfg + jmp cfg3 ; fini + +cfg0: cmp ax, word ptr[ClipXmax] ; test si X2 clipp‚ + jg cfg2 ; oui 1 et 2 clipp‚ on oublie le 1 + ; 1er clipp‚ on ajuste coor +cfg1: ; BP = C0 + ; CX = X0 BX < DX + ; BX = Y0 + ; C1 + ; DX = X1 + ; AX = Y1 + + push eax + push edx + push [coul1] + + + cmp ax, cx ; Ajuste X0 X1 pour clip 2 poly coll‚s + jl cfg4 + xchg eax, ecx + xchg edx, ebx + xchg bp, [coul1] +cfg4: + sub [coul1], bp ; coul1 = DeltaCoul + shl ebp, 16 ; save coul0 + + sub edx, ebx ; DX = DeltaY BX = Y0 + sub eax, ecx ; AX = DeltaX + mov bp, word ptr[ClipXmax] + sub bp, cx ; BP = deltaClipX + mov ecx, eax ; CX = DeltaX + mov eax, ebp ; AX = deltaClipX + imul dx ; AX = AX * deltaY + idiv cx ; AX = AX / deltaX + add ebx, eax ; Y0 = Y0 + AX + + mov ax, word ptr[ClipXmax] ; X0 + mov [edi+2], ax ; X0 + mov [edi+4], bx ; Y0 + + + cmp word ptr[ TypePoly ], POLY_GOURAUD + jb cfg5 + + mov ax, [coul1] ; AX = DeltaCoul + imul bp ; AX = AX * DeltaClipX + idiv cx ; AX = AX / deltaX + shr ebp, 16 ; BP = Coul0 + add eax, ebp ; AX = AX + coul0 + + mov [edi], ax +cfg5: + add edi, 6 + inc word ptr[newboucle] ; new point + + pop bp ; POP C1 dans C0 + pop ebx ; POP Y1 dans Y0 + pop ecx ; POP X1 dans X0 + + dec word ptr[boucle] + jnz cfg +cfg3: + mov eax, [offtabpoly] ; inversion pointeurs buffer + mov esi, [offtabpoly+4] + mov [offtabpoly+4], eax + mov [offtabpoly], esi + + movsw + movsd ; transitivit‚ der point + + mov ax, [newboucle] + mov [boucle], ax + or ax, ax + ret + + +ClipDroit endp + +;------------------------------------------------------------------------ + +ClipHaut proc near + + mov word ptr[newboucle], 0 + mov word ptr[flagrencadre], 1 + + mov esi, [offtabpoly] + mov edi, [offtabpoly+4] + + mov bp, [esi] ; BP = C0 + mov bx, [esi+2] ; BX = X0 + mov cx, [esi+4] ; CX = Y0 + add esi, 6 +; EVEN + ALIGN 4 +cfg: mov ax, [esi] ; C1 + mov [coul1], ax + mov dx, [esi+2] ; DX = X1 + mov ax, [esi+4] ; AX = Y1 + add esi, 6 + + cmp cx, word ptr[ClipYmin] ; test si Y0 clipp‚ + jl cfg0 ; oui clipp‚ + + mov [edi], bp + mov [edi+2], bx ; pas clipp‚ on stock + mov [edi+4], cx + add edi, 6 + inc word ptr[newboucle] ; 1 point de plus + + cmp ax, word ptr[ClipYmin] ; test si Y1 clipp‚ + jl cfg1 ; si oui on clip + +cfg2: mov bp, [coul1] + mov ebx, edx ; XYC0 = XYC1 + mov ecx, eax ; et on passe au suivant + + dec word ptr[boucle] + jnz cfg + jmp cfg3 ; fini + +cfg0: cmp ax, word ptr[ClipYmin] ; test si Y2 clipp‚ + jl cfg2 ; oui 1 et 2 clipp‚ on oublie le 1 + ; 1er clipp‚ on ajuste coor +cfg1: ; BP = C0 + ; BX = X0 + ; CX = Y0 + ; C1 + ; DX = X1 + ; AX = Y1 + + push edx + push eax + push [coul1] + + cmp ax, cx ; Ajuste Y0 Y1 pour clip 2 poly coll‚s + jl cfg4 + xchg edx, ebx + xchg eax, ecx + xchg bp, [coul1] +cfg4: + sub [coul1], bp ; coul1 = DeltaCoul + shl ebp, 16 ; save coul0 + + sub edx, ebx ; DX = DeltaX BX = X0 + sub eax, ecx ; AX = DeltaY + mov bp, word ptr[ClipYmin] + sub bp, cx ; BP = deltaClipY + mov ecx, eax ; CX = DeltaY + mov eax, ebp ; AX = deltaClipY + imul dx ; AX = AX * deltaX + idiv cx ; AX = AX / deltaY + add ebx, eax ; X0 = X0 + AX + + mov [edi+2], bx ; X0 + mov ax, word ptr[ClipYmin] ; Y0 + mov [edi+4], ax ; Y0 + + cmp word ptr[ TypePoly ], POLY_GOURAUD + jb cfg5 + + mov ax, [coul1] ; AX = DeltaCoul + imul bp ; AX = AX * DeltaClipY + idiv cx ; AX = AX / deltaY + shr ebp, 16 ; BP = Coul0 + add eax, ebp ; AX = AX + coul0 + + mov [edi], ax +cfg5: + add edi, 6 + inc word ptr[newboucle] ; new point + + pop bp ; POP C1 dans C0 + pop ecx ; POP Y1 dans Y0 + pop ebx ; POP X1 dans X0 + + dec word ptr[boucle] + jnz cfg + +cfg3: mov eax, [offtabpoly] ; inversion pointeurs buffer + mov esi, [offtabpoly+4] + mov [offtabpoly+4], eax + mov [offtabpoly], esi + + movsw + movsd ; transitivit‚ der point + + mov ax, [newboucle] + mov [boucle], ax + or ax, ax + ret + +ClipHaut endp + +;------------------------------------------------------------------------ + +ClipBas proc near + + mov word ptr[newboucle], 0 + mov word ptr[flagrencadre], 1 + + mov esi, [offtabpoly] + mov edi, [offtabpoly+4] + + mov bp, [esi] ; BP = C0 + mov bx, [esi+2] ; BX = X0 + mov cx, [esi+4] ; CX = Y0 + add esi, 6 +; EVEN + ALIGN 4 +cfg: mov ax, [esi] ; C1 + mov [coul1], ax + mov dx, [esi+2] ; DX = X1 + mov ax, [esi+4] ; AX = Y1 + add esi, 6 + + cmp cx, word ptr[ClipYmax] ; test si Y0 clipp‚ + jg cfg0 ; oui clipp‚ + + mov [edi], bp + mov [edi+2], bx ; pas clipp‚ on stock + mov [edi+4], cx + add edi, 6 + inc word ptr[newboucle] ; 1 point de plus + + cmp ax, word ptr[ClipYmax] ; test si Y1 clipp‚ + jg cfg1 ; si oui on clip + +cfg2: mov bp, [coul1] + mov ebx, edx ; XYC0 = XYC1 + mov ecx, eax ; et on passe au suivant + + dec word ptr[boucle] + jnz cfg + jmp cfg3 ; fini + +cfg0: cmp ax, word ptr[ClipYmax] ; test si Y2 clipp‚ + jg cfg2 ; oui 1 et 2 clipp‚ on oublie le 1 + ; 1er clipp‚ on ajuste coor +cfg1: ; BP = C0 + ; BX = X0 + ; CX = Y0 + ; C1 + ; DX = X1 + ; AX = Y1 + + push edx + push eax + push [coul1] + + cmp ax, cx ; Ajuste Y0 Y1 pour clip 2 poly coll‚s + jl cfg4 + xchg edx, ebx + xchg eax, ecx + xchg bp, [coul1] +cfg4: + sub [coul1], bp ; coul1 = DeltaCoul + shl ebp, 16 ; save coul0 + + sub edx, ebx ; DX = DeltaX BX = X0 + sub eax, ecx ; AX = DeltaY + mov bp, word ptr[ClipYmax] + sub bp, cx ; BP = deltaClipY + mov ecx, eax ; CX = DeltaY + mov eax, ebp ; AX = deltaClipY + imul dx ; AX = AX * deltaX + idiv cx ; AX = AX / deltaY + add ebx, eax ; X0 = X0 + AX + + mov [edi+2], bx ; X0 + mov ax, word ptr[ClipYmax] ; Y0 + mov [edi+4], ax ; Y0 + + cmp word ptr[ TypePoly ], POLY_GOURAUD + jb cfg5 + + mov ax, [coul1] ; AX = DeltaCoul + imul bp ; AX = AX * DeltaClipY + idiv cx ; AX = AX / deltaY + shr ebp, 16 ; BP = Coul0 + add eax, ebp ; AX = AX + coul0 + + mov [edi], ax +cfg5: + add edi, 6 + inc word ptr[newboucle] ; new point + + pop bp ; POP C1 dans C0 + pop ecx ; POP Y1 dans Y0 + pop ebx ; POP X1 dans X0 + + dec word ptr[boucle] + jnz cfg + +cfg3: mov eax, [offtabpoly] ; inversion pointeurs buffer + mov esi, [offtabpoly+4] + mov [offtabpoly+4], eax + mov [offtabpoly], esi + + movsw + movsd ; transitivit‚ der point + + mov ax, [newboucle] + mov [boucle], ax + or ax, ax + ret + +ClipBas endp + +;------------------------------------------------------------------------ + + END diff --git a/LIB386/LIB_SVGA/S_SCREEN.ASM b/LIB386/LIB_SVGA/S_SCREEN.ASM new file mode 100644 index 0000000..9f9f9be --- /dev/null +++ b/LIB386/LIB_SVGA/S_SCREEN.ASM @@ -0,0 +1,84 @@ +;---------------------------------------------------------------------------- +; S_SCREEN.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386p + jumps + .model SMALL, SYSCALL +;---------------------------------------------------------------------------- + .data + + include svga.ash + +ALIGN 4 + +Diff dd ? + +;---------------------------------------------------------------------------- + .code + + public NoLanguage Cls + public NoLanguage CopyScreen + +;---------------------------------------------------------------------------- +; Cls() +; +Cls proc uses edi + mov edi, Log + xor eax, eax + mov ecx, 307200/4 + rep stosd + ret +Cls endp + +;---------------------------------------------------------------------------- +; CopyScreen( UBYTE *src, UBYTE *dst ) +; +; Attention:De m‚moire … m‚moire (pas sur vid‚o ram) +; +CopyScreen proc uses esi edi,\ + src:DWORD, dst:DWORD + + mov esi, src + mov edi, dst + mov ecx, 307200/4 + rep movsd + ret +CopyScreen endp +;---------------------------------------------------------------------------- + +; +; The + End + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LIB386/LIB_SVGA/S_STRING.ASM b/LIB386/LIB_SVGA/S_STRING.ASM new file mode 100644 index 0000000..7675c61 --- /dev/null +++ b/LIB386/LIB_SVGA/S_STRING.ASM @@ -0,0 +1,434 @@ +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ +; S_TEST.ASM 386 +; (c) Adeline 1993 +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + .386p + jumps + .model SMALL, SYSCALL +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + .data + + include svga.ash + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + +; include Font6X6.asm + +; include Font8X8.asm + +Font8X8 db 0, 0, 0, 0, 0, 0, 0, 0 + db 126, 129, 165, 129, 189, 153, 129, 126 + db 126, 255, 219, 255, 195, 231, 255, 126 + db 108, 254, 254, 254, 124, 56, 16, 0 + db 16, 56, 124, 254, 124, 56, 16, 0 + db 56, 124, 56, 254, 254, 146, 16, 124 + db 0, 16, 56, 124, 254, 124, 56, 124 + db 0, 0, 24, 60, 60, 24, 0, 0 + db 255, 255, 231, 195, 195, 231, 255, 255 + db 0, 60, 102, 66, 66, 102, 60, 0 + db 255, 195, 153, 189, 189, 153, 195, 255 + db 15, 7, 15, 125, 204, 204, 204, 120 + db 60, 102, 102, 102, 60, 24, 126, 24 + db 63, 51, 63, 48, 48, 112, 240, 224 + db 127, 99, 127, 99, 99, 103, 230, 192 + db 153, 90, 60, 231, 231, 60, 90, 153 + db 128, 224, 248, 254, 248, 224, 128, 0 + db 2, 14, 62, 254, 62, 14, 2, 0 + db 24, 60, 126, 24, 24, 126, 60, 24 + db 102, 102, 102, 102, 102, 0, 102, 0 + db 127, 219, 219, 123, 27, 27, 27, 0 + db 62, 99, 56, 108, 108, 56, 134, 252 + db 0, 0, 0, 0, 126, 126, 126, 0 + db 24, 60, 126, 24, 126, 60, 24, 255 + db 24, 60, 126, 24, 24, 24, 24, 0 + db 24, 24, 24, 24, 126, 60, 24, 0 + db 0, 24, 12, 254, 12, 24, 0, 0 + db 0, 48, 96, 254, 96, 48, 0, 0 + db 0, 0, 192, 192, 192, 254, 0, 0 + db 0, 36, 102, 255, 102, 36, 0, 0 + db 0, 24, 60, 126, 255, 255, 0, 0 + db 0, 255, 255, 126, 60, 24, 0, 0 + db 0, 0, 0, 0, 0, 0, 0, 0 + db 24, 60, 60, 24, 24, 0, 24, 0 + db 108, 108, 108, 0, 0, 0, 0, 0 + db 108, 108, 254, 108, 254, 108, 108, 0 + db 24, 126, 192, 124, 6, 252, 24, 0 + db 0, 198, 204, 24, 48, 102, 198, 0 + db 56, 108, 56, 118, 220, 204, 118, 0 + db 48, 48, 96, 0, 0, 0, 0, 0 + db 24, 48, 96, 96, 96, 48, 24, 0 + db 96, 48, 24, 24, 24, 48, 96, 0 + db 0, 102, 60, 255, 60, 102, 0, 0 + db 0, 24, 24, 126, 24, 24, 0, 0 + db 0, 0, 0, 0, 0, 24, 24, 48 + db 0, 0, 0, 126, 0, 0, 0, 0 + db 0, 0, 0, 0, 0, 24, 24, 0 + db 6, 12, 24, 48, 96, 192, 128, 0 + db 124, 206, 222, 246, 230, 198, 124, 0 + db 48, 112, 48, 48, 48, 48, 252, 0 + db 120, 204, 12, 56, 96, 204, 252, 0 + db 120, 204, 12, 56, 12, 204, 120, 0 + db 28, 60, 108, 204, 254, 12, 30, 0 + db 252, 192, 248, 12, 12, 204, 120, 0 + db 56, 96, 192, 248, 204, 204, 120, 0 + db 252, 204, 12, 24, 48, 48, 48, 0 + db 120, 204, 204, 120, 204, 204, 120, 0 + db 120, 204, 204, 124, 12, 24, 112, 0 + db 0, 24, 24, 0, 0, 24, 24, 0 + db 0, 24, 24, 0, 0, 24, 24, 48 + db 24, 48, 96, 192, 96, 48, 24, 0 + db 0, 0, 126, 0, 126, 0, 0, 0 + db 96, 48, 24, 12, 24, 48, 96, 0 + db 60, 102, 12, 24, 24, 0, 24, 0 + db 124, 198, 222, 222, 220, 192, 124, 0 + db 48, 120, 204, 204, 252, 204, 204, 0 + db 252, 102, 102, 124, 102, 102, 252, 0 + db 60, 102, 192, 192, 192, 102, 60, 0 + db 248, 108, 102, 102, 102, 108, 248, 0 + db 254, 98, 104, 120, 104, 98, 254, 0 + db 254, 98, 104, 120, 104, 96, 240, 0 + db 60, 102, 192, 192, 206, 102, 58, 0 + db 204, 204, 204, 252, 204, 204, 204, 0 + db 120, 48, 48, 48, 48, 48, 120, 0 + db 30, 12, 12, 12, 204, 204, 120, 0 + db 230, 102, 108, 120, 108, 102, 230, 0 + db 240, 96, 96, 96, 98, 102, 254, 0 + db 198, 238, 254, 254, 214, 198, 198, 0 + db 198, 230, 246, 222, 206, 198, 198, 0 + db 56, 108, 198, 198, 198, 108, 56, 0 + db 252, 102, 102, 124, 96, 96, 240, 0 + db 124, 198, 198, 198, 214, 124, 14, 0 + db 252, 102, 102, 124, 108, 102, 230, 0 + db 124, 198, 224, 120, 14, 198, 124, 0 + db 252, 180, 48, 48, 48, 48, 120, 0 + db 204, 204, 204, 204, 204, 204, 252, 0 + db 204, 204, 204, 204, 204, 120, 48, 0 + db 198, 198, 198, 198, 214, 254, 108, 0 + db 198, 198, 108, 56, 108, 198, 198, 0 + db 204, 204, 204, 120, 48, 48, 120, 0 + db 254, 198, 140, 24, 50, 102, 254, 0 + db 120, 96, 96, 96, 96, 96, 120, 0 + db 192, 96, 48, 24, 12, 6, 2, 0 + db 120, 24, 24, 24, 24, 24, 120, 0 + db 16, 56, 108, 198, 0, 0, 0, 0 + db 0, 0, 0, 0, 0, 0, 0, 255 + db 48, 48, 24, 0, 0, 0, 0, 0 + db 0, 0, 120, 12, 124, 204, 118, 0 + db 224, 96, 96, 124, 102, 102, 220, 0 + db 0, 0, 120, 204, 192, 204, 120, 0 + db 28, 12, 12, 124, 204, 204, 118, 0 + db 0, 0, 120, 204, 252, 192, 120, 0 + db 56, 108, 100, 240, 96, 96, 240, 0 + db 0, 0, 118, 204, 204, 124, 12, 248 + db 224, 96, 108, 118, 102, 102, 230, 0 + db 48, 0, 112, 48, 48, 48, 120, 0 + db 12, 0, 28, 12, 12, 204, 204, 120 + db 224, 96, 102, 108, 120, 108, 230, 0 + db 112, 48, 48, 48, 48, 48, 120, 0 + db 0, 0, 204, 254, 254, 214, 214, 0 + db 0, 0, 184, 204, 204, 204, 204, 0 + db 0, 0, 120, 204, 204, 204, 120, 0 + db 0, 0, 220, 102, 102, 124, 96, 240 + db 0, 0, 118, 204, 204, 124, 12, 30 + db 0, 0, 220, 118, 98, 96, 240, 0 + db 0, 0, 124, 192, 112, 28, 248, 0 + db 16, 48, 252, 48, 48, 52, 24, 0 + db 0, 0, 204, 204, 204, 204, 118, 0 + db 0, 0, 204, 204, 204, 120, 48, 0 + db 0, 0, 198, 198, 214, 254, 108, 0 + db 0, 0, 198, 108, 56, 108, 198, 0 + db 0, 0, 204, 204, 204, 124, 12, 248 + db 0, 0, 252, 152, 48, 100, 252, 0 + db 28, 48, 48, 224, 48, 48, 28, 0 + db 24, 24, 24, 0, 24, 24, 24, 0 + db 224, 48, 48, 28, 48, 48, 224, 0 + db 118, 220, 0, 0, 0, 0, 0, 0 + db 0, 16, 56, 108, 198, 198, 254, 0 + db 124, 198, 192, 198, 124, 12, 6, 124 + db 0, 204, 0, 204, 204, 204, 118, 0 + db 28, 0, 120, 204, 252, 192, 120, 0 + db 126, 129, 60, 6, 62, 102, 59, 0 + db 204, 0, 120, 12, 124, 204, 118, 0 + db 224, 0, 120, 12, 124, 204, 118, 0 + db 48, 48, 120, 12, 124, 204, 118, 0 + db 0, 0, 124, 198, 192, 120, 12, 56 + db 126, 129, 60, 102, 126, 96, 60, 0 + db 204, 0, 120, 204, 252, 192, 120, 0 + db 224, 0, 120, 204, 252, 192, 120, 0 + db 204, 0, 112, 48, 48, 48, 120, 0 + db 124, 130, 56, 24, 24, 24, 60, 0 + db 224, 0, 112, 48, 48, 48, 120, 0 + db 198, 16, 124, 198, 254, 198, 198, 0 + db 48, 48, 0, 120, 204, 252, 204, 0 + db 28, 0, 252, 96, 120, 96, 252, 0 + db 0, 0, 127, 12, 127, 204, 127, 0 + db 62, 108, 204, 254, 204, 204, 206, 0 + db 120, 132, 0, 120, 204, 204, 120, 0 + db 0, 204, 0, 120, 204, 204, 120, 0 + db 0, 224, 0, 120, 204, 204, 120, 0 + db 120, 132, 0, 204, 204, 204, 118, 0 + db 0, 224, 0, 204, 204, 204, 118, 0 + db 0, 204, 0, 204, 204, 124, 12, 248 + db 195, 24, 60, 102, 102, 60, 24, 0 + db 204, 0, 204, 204, 204, 204, 120, 0 + db 24, 24, 126, 192, 192, 126, 24, 24 + db 56, 108, 100, 240, 96, 230, 252, 0 + db 204, 204, 120, 48, 252, 48, 252, 48 + db 248, 204, 204, 250, 198, 207, 198, 195 + db 14, 27, 24, 60, 24, 24, 216, 112 + db 28, 0, 120, 12, 124, 204, 118, 0 + db 56, 0, 112, 48, 48, 48, 120, 0 + db 0, 28, 0, 120, 204, 204, 120, 0 + db 0, 28, 0, 204, 204, 204, 118, 0 + db 0, 248, 0, 184, 204, 204, 204, 0 + db 252, 0, 204, 236, 252, 220, 204, 0 + db 60, 108, 108, 62, 0, 126, 0, 0 + db 56, 108, 108, 56, 0, 124, 0, 0 + db 24, 0, 24, 24, 48, 102, 60, 0 + db 0, 0, 0, 252, 192, 192, 0, 0 + db 0, 0, 0, 252, 12, 12, 0, 0 + db 198, 204, 216, 54, 107, 194, 132, 15 + db 195, 198, 204, 219, 55, 109, 207, 3 + db 24, 0, 24, 24, 60, 60, 24, 0 + db 0, 51, 102, 204, 102, 51, 0, 0 + db 0, 204, 102, 51, 102, 204, 0, 0 + db 34, 136, 34, 136, 34, 136, 34, 136 + db 85, 170, 85, 170, 85, 170, 85, 170 + db 219, 246, 219, 111, 219, 126, 215, 237 + db 24, 24, 24, 24, 24, 24, 24, 24 + db 24, 24, 24, 24, 248, 24, 24, 24 + db 24, 24, 248, 24, 248, 24, 24, 24 + db 54, 54, 54, 54, 246, 54, 54, 54 + db 0, 0, 0, 0, 254, 54, 54, 54 + db 0, 0, 248, 24, 248, 24, 24, 24 + db 54, 54, 246, 6, 246, 54, 54, 54 + db 54, 54, 54, 54, 54, 54, 54, 54 + db 0, 0, 254, 6, 246, 54, 54, 54 + db 54, 54, 246, 6, 254, 0, 0, 0 + db 54, 54, 54, 54, 254, 0, 0, 0 + db 24, 24, 248, 24, 248, 0, 0, 0 + db 0, 0, 0, 0, 248, 24, 24, 24 + db 24, 24, 24, 24, 31, 0, 0, 0 + db 24, 24, 24, 24, 255, 0, 0, 0 + db 0, 0, 0, 0, 255, 24, 24, 24 + db 24, 24, 24, 24, 31, 24, 24, 24 + db 0, 0, 0, 0, 255, 0, 0, 0 + db 24, 24, 24, 24, 255, 24, 24, 24 + db 24, 24, 31, 24, 31, 24, 24, 24 + db 54, 54, 54, 54, 55, 54, 54, 54 + db 54, 54, 55, 48, 63, 0, 0, 0 + db 0, 0, 63, 48, 55, 54, 54, 54 + db 54, 54, 247, 0, 255, 0, 0, 0 + db 0, 0, 255, 0, 247, 54, 54, 54 + db 54, 54, 55, 48, 55, 54, 54, 54 + db 0, 0, 255, 0, 255, 0, 0, 0 + db 54, 54, 247, 0, 247, 54, 54, 54 + db 24, 24, 255, 0, 255, 0, 0, 0 + db 54, 54, 54, 54, 255, 0, 0, 0 + db 0, 0, 255, 0, 255, 24, 24, 24 + db 0, 0, 0, 0, 255, 54, 54, 54 + db 54, 54, 54, 54, 63, 0, 0, 0 + db 24, 24, 31, 24, 31, 0, 0, 0 + db 0, 0, 31, 24, 31, 24, 24, 24 + db 0, 0, 0, 0, 63, 54, 54, 54 + db 54, 54, 54, 54, 255, 54, 54, 54 + db 24, 24, 255, 24, 255, 24, 24, 24 + db 24, 24, 24, 24, 248, 0, 0, 0 + db 0, 0, 0, 0, 31, 24, 24, 24 + db 255, 255, 255, 255, 255, 255, 255, 255 + db 0, 0, 0, 0, 255, 255, 255, 255 + db 240, 240, 240, 240, 240, 240, 240, 240 + db 15, 15, 15, 15, 15, 15, 15, 15 + db 255, 255, 255, 255, 0, 0, 0, 0 + db 0, 0, 118, 220, 200, 220, 118, 0 + db 0, 120, 204, 248, 204, 248, 192, 192 + db 0, 252, 204, 192, 192, 192, 192, 0 + db 0, 0, 254, 108, 108, 108, 108, 0 + db 252, 204, 96, 48, 96, 204, 252, 0 + db 0, 0, 126, 216, 216, 216, 112, 0 + db 0, 102, 102, 102, 102, 124, 96, 192 + db 0, 118, 220, 24, 24, 24, 24, 0 + db 252, 48, 120, 204, 204, 120, 48, 252 + db 56, 108, 198, 254, 198, 108, 56, 0 + db 56, 108, 198, 198, 108, 108, 238, 0 + db 28, 48, 24, 124, 204, 204, 120, 0 + db 0, 0, 126, 219, 219, 126, 0, 0 + db 6, 12, 126, 219, 219, 126, 96, 192 + db 56, 96, 192, 248, 192, 96, 56, 0 + db 120, 204, 204, 204, 204, 204, 204, 0 + db 0, 126, 0, 126, 0, 126, 0, 0 + db 24, 24, 126, 24, 24, 0, 126, 0 + db 96, 48, 24, 48, 96, 0, 252, 0 + db 24, 48, 96, 48, 24, 0, 252, 0 + db 14, 27, 27, 24, 24, 24, 24, 24 + db 24, 24, 24, 24, 24, 216, 216, 112 + db 24, 24, 0, 126, 0, 24, 24, 0 + db 0, 118, 220, 0, 118, 220, 0, 0 + db 56, 108, 108, 56, 0, 0, 0, 0 + db 0, 0, 0, 24, 24, 0, 0, 0 + db 0, 0, 0, 0, 24, 0, 0, 0 + db 15, 12, 12, 12, 236, 108, 60, 28 + db 88, 108, 108, 108, 108, 0, 0, 0 + db 112, 152, 48, 96, 248, 0, 0, 0 + db 0, 0, 60, 60, 60, 60, 0, 0 + db 0, 0, 0, 0, 0, 0, 0, 0 + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ + + .code + + public NoLanguage AffString + public NoLanguage CoulText + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ +; Text( x, y, pttext ) +; +; + +AffString proc uses ebp ebx edi esi,\ + XText:DWORD, YText:DWORD, PtText:DWORD + +;---------------------- + mov ebx, YText + mov edi, TabOffLine[ebx*4] + add edi, Log + add edi, XText +;---------------------- + mov esi, PtText + mov ebp, edi +;---------------------- +bcar: xor eax, eax + + mov al, [esi] + or al, al + jz short finstr + + lea ebx, [esi+1] ; save esi + + lea esi, [Font8X8+eax*8]; esi sur caractere + + mov dl, 8 +;---------------------- +blig: mov edi, ebp + + mov ah, [esi] + inc esi + mov ecx, 8 +;---------------------- +bcol: shl ah, 1 + jc short coulencre + + mov al, byte ptr[Text_Paper] + cmp al, -1 + jnz short coulfond + + jmp short next +coulencre: mov al, byte ptr[Text_Ink] +coulfond: mov byte ptr[edi], al +next: inc edi + dec ecx + jnz short bcol + + add ebp, Screen_X + dec dl + jnz short blig + + sub ebp, (640*8)-8 + + mov esi, ebx +;---------------------- + jmp short bcar +finstr: + ret + +AffString endp + +comment # + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ +; Text( x, y, pttext ) +; +; +AffString1 proc uses ebp ebx edi esi,\ + XText:DWORD, YText:DWORD, PtText:DWORD + +;---------------------- + mov ebx, YText + mov edi, TabOffLine[ebx*4] + add edi, Log + add edi, XText +;---------------------- + mov esi, PtText + mov ebp, edi +;---------------------- +bcar: xor eax, eax + + lodsb + or al, al + jz short finstr + + sub al, 32 + shl eax, 2 ; *4 + mov edi, eax + shl eax, 3 ; *36 + add eax, edi ; *36 +;---------------------- + mov ebx, esi + lea esi, [Font6X6+eax]; pointe datas car + mov cl, 6 +;---------------------- +blig: mov edi, ebp + mov ch, 6 +;---------------------- +bcol: lodsb + or al, al + jnz short coulencre + + mov al, byte ptr[Text_Paper] + cmp al, -1 + jnz short coulfond + + jmp short next +coulencre: mov al, byte ptr[Text_Ink] +coulfond: mov byte ptr[edi], al +next: inc edi + dec ch + jnz short bcol + + add ebp, Screen_X + dec cl + jnz short blig + + sub ebp, (640*6)-6 + + mov esi, ebx +;---------------------- + jmp short bcar +finstr: + ret + +AffString1 endp + + # + +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ +CoulText proc ,\ + ink:DWORD, paper:DWORD + mov eax, ink + mov byte ptr [Text_Ink], al + mov eax, paper + mov byte ptr [Text_Paper], al + ret +CoulText endp +;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ +; The + End + + + + + + + diff --git a/LIB386/LIB_SVGA/S_TEXT.C b/LIB386/LIB_SVGA/S_TEXT.C new file mode 100644 index 0000000..e486177 --- /dev/null +++ b/LIB386/LIB_SVGA/S_TEXT.C @@ -0,0 +1,190 @@ + +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" + +#include "\projet\lib386\lib_svga\lib_svga.h" + +#include +#include +#include +#include + +/*--------------------------------------------------------------------------*/ +/* (c) Adeline 1993 */ +/*--------------------------------------------------------------------------*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ßßÛßß Ûßßßß ßÜ Üß ßßÛßß + ÛÛ ÛÛßß ÜßÜ ÛÛ + ßß ßßßßß ß ß ßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void Text( WORD x,WORD y,char *msk, ... ) +{ +// ULONG *pt = (ULONG *)&str_in ; + WORD l ; + char c ; + char str[256] ; + char tempo[34] ; + char *str_out = str ; + char *ptr ; + WORD flagflip = 0 ; + va_list ap; + + if( (y < ClipYmin) + OR (y > ClipYmax-7) + OR (x > ClipXmax) ) return ; + + l = 0 ; + + va_start(ap, msk); + + *str_out = 0 ; + while( (c=*msk++) != 0 ) + { + if( c == '%' ) + { + switch( toupper(*msk++) ) + { + case 'C': /* char */ + tempo[0] = va_arg(ap,char); + tempo[1] = 0 ; + strcat(str_out, tempo ) ; + l++ ; + break ; + + case 'S': /* string */ + ptr = va_arg(ap,char*) ; + strcat(str_out, ptr) ; + l += strlen(ptr) ; + break ; + + case 'B': /* byte */ + strcat(str_out, ltoa( va_arg(ap, UBYTE), tempo, 10 )) ; + l += strlen( tempo ) ; + break ; + + case 'D': /* decimal */ + strcat(str_out, ltoa( va_arg(ap, int), tempo, 10 )) ; + l += strlen( tempo ) ; + break ; + + case 'L': /* long decimal */ + strcat(str_out, ltoa( va_arg(ap, int), tempo, 10 )) ; + l += strlen( tempo ) ; + break ; + + case 'U': /* unsigned decimal */ + strcat(str_out, ultoa( va_arg(ap, unsigned), tempo, 10 )) ; + l += strlen( tempo ) ; + break ; + + case 'P': /* pointeur hexa */ + strcat(str_out, ultoa( va_arg(ap, unsigned), tempo, 16 )) ; + l += strlen( tempo ) ; + break ; + + case 'F': + flagflip = 1 ; + break ; + + default: + return ; + } + } + else + { + str[l] = c ; + l++ ; + str[l] = 0 ; + } + } + + ptr = str ; + + if( x + l*8 - 1 > ClipXmax ) + { + ptr[ (ClipXmax-x)/8 ] = 0 ; + } + + if( x < ClipXmin ) + { + ptr += (ClipXmin-x)/8 ; + x += ClipXmin-x ; + } + + AffString( x, y, ptr ) ; + + if( flagflip ) + { + CopyBlockPhys( x,y, x+strlen(ptr)*8-1, y+7 ) ; + } + va_end(ap); +} + + +#ifdef OLD_VERSION + +void Text( WORD x,WORD y,char *msk, ULONG str_in ) +{ +ULONG *pt = (ULONG *)&str_in ; +WORD l ; +char c ; +char str[256] ; +char tempo[34] ; +char *str_out = str ; +void *ptr ; + + *str_out = 0 ; + while( (c=*msk++) != 0 ) + { + if( c == '%' ) + { + switch( toupper(*msk++) ) + { + case 'C': /* char */ + tempo[0] = *(char *)pt; + tempo[1] = 0 ; + strcat(str_out, tempo ) ; + break ; + + case 'S': /* string */ + strcat(str_out, *(char **)pt) ; + break ; + + case 'B': /* byte */ + strcat(str_out, ltoa( *(UBYTE *)pt, tempo, 10 )) ; + break ; + + case 'D': /* decimal */ + strcat(str_out, ltoa( *pt, tempo, 10 )) ; + break ; + + case 'L': /* long decimal */ + strcat(str_out, ltoa( *pt, tempo, 10 )) ; + break ; + + case 'U': /* unsigned decimal */ + strcat(str_out, ultoa( *pt, tempo, 10 )) ; + break ; + + case 'P': /* pointeur hexa */ + strcat(str_out, ltoa( *pt, tempo, 16 )) ; + break ; + + default: + return ; + } + pt++; + } + else + { + l = strlen( str ) ; + str[l] = c ; + str[l+1] = 0 ; + } + } + + AffString( x, y, str ) ; +} +#endif \ No newline at end of file diff --git a/LIB386/LIB_SVGA/TA.BAT b/LIB386/LIB_SVGA/TA.BAT new file mode 100644 index 0000000..b9a9447 --- /dev/null +++ b/LIB386/LIB_SVGA/TA.BAT @@ -0,0 +1,2 @@ + +tasm /m2 /mx /z /zi /t /jMASM51 /jQUIRKS %1 diff --git a/LIB386/LIB_SVGA/TEXTURE.ASM b/LIB386/LIB_SVGA/TEXTURE.ASM new file mode 100644 index 0000000..5aaf9a8 --- /dev/null +++ b/LIB386/LIB_SVGA/TEXTURE.ASM @@ -0,0 +1,2257 @@ +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +; (c) Adeline 1993 +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + + .386P + jumps + .model SMALL, SYSCALL + .data + + include \projet\lib386\lib_svga\svga.ash + + extrn NoLanguage TabVerticG :WORD + extrn NoLanguage TabCoulG :WORD + extrn NoLanguage TabCoulD :WORD + extrn NoLanguage Ymin :WORD + extrn NoLanguage Ymax :WORD + +EVEN + + public NoLanguage TabText + +TabText dw 32*3 dup(00) + +boucle dw 00 +loopy dw 00 + +darkdec dw 00 + +ALIGN 4 + +xstep dd 0000 +ystep dd 0000 + +ptrlig dd 0000 +ptrmap dd 0000 +ptrtab dd 0000 + + public NoLanguage LYmin + public NoLanguage LYmax + +LYmin dd 0000 +LYmax dd 0000 + + extrn NoLanguage TabGauche:WORD + extrn NoLanguage TabDroite:WORD + extrn NoLanguage TabX0:WORD + extrn NoLanguage TabY0:WORD + extrn NoLanguage TabX1:WORD + extrn NoLanguage TabY1:WORD + + extrn NoLanguage TabPoly:WORD + + extrn NoLanguage P_SinTab:WORD + +TAB_GAUCHE equ 960*0 +TAB_DROITE equ 960*1 +TAB_X0 equ 960*2 +TAB_Y0 equ 960*3 +TAB_X1 equ 960*4 +TAB_Y1 equ 960*5 + + .code + + public NoLanguage FillTextPoly + public NoLanguage FillTextPolyNoClip +; public NoLanguage M_FillTextPoly + public NoLanguage FillTextPolyShade + + public NoLanguage AsmTexturedTriangleNoClip + public NoLanguage AsmGouraudTriangleNoClip + + public NoLanguage AsmFillProp + public NoLanguage AsmFillPropNoClip +; public NoLanguage M_AsmFillProp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ÛßßßÛ ÛßßßÛ Û Û Üß ÛÛßßß +; ÛÛßßß ÛÛ Û ÛÛ ÛÛß ßßßßÛ +; ßß ßßßßß ßßßßß ßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +comment # +void FillProp( WORD *ptrdest, WORD x0, WORD y0, WORD x1, WORD y1 ) +{ + WORD y, t ; + + if( y0 > y1 ) + { + t=y0; y0=y1; y1=t; + t=x0; x0=x1; x1=t; + } + + for( y=y0; y<=y1; y++ ) + { + ptrdest[y] = RegleTrois32( x0, x1, y1-y0+1, y-y0 ) ; + } +} +# + +AsmFillProp proc uses esi edi ebx ebp,\ + ptrdest:DWORD, x0:DWORD, y0:DWORD, x1:DWORD, y1:DWORD + + mov edi, ptrdest + + mov eax, y0 + mov ecx, y1 + + mov ebx, x0 + mov edx, x1 + + cmp eax, ecx ; y0 < y1 + jle afp0 + + xchg eax, ecx ; y0 <> y1 + xchg ebx, edx ; x0 <> x1 + +afp0: + cmp eax, [ClipYmax] + jg nofill + + cmp ecx, [ClipYmin] + jl nofill + + cmp eax, [ClipYmin] + jl clip_ymin + +afp01: cmp ecx, [ClipYmax] + jle afp00 + +clip_ymax: + + push edi + push eax + + mov edi, ebx + sub edi, edx ; dx + + mov esi, eax + sub esi, ecx ; dy + jz nofill2 + + mov ebp, edx + + mov eax, ecx ; y1 + + sub eax, [ClipYmax] ; ymax - y1 + neg eax + imul edi ; * dx + idiv esi ; / dy + add eax, ebp ; += x1 + mov edx, eax + mov ecx, [ClipYmax] ; y1 = ymax + + pop eax + pop edi + + jmp afp00 + +clip_ymin: + + push edi + push edx + + mov edi, ebx + sub edi, edx ; dx + + mov esi, eax + sub esi, ecx ; dy + jz nofill1 + + mov ebp, ebx + + sub eax, [ClipYmin] ; ymin - y0 + neg eax + imul edi ; * dx + idiv esi ; / dy + add eax, ebp ; += x0 + mov ebx, eax + mov eax, [ClipYmin] ; y0 = ymin + + pop edx + pop edi + + jmp afp01 + +afp00: sub ecx, eax ; ecx deltay >= 0 + + + jz nofill ; GASP mettre cas 1 ligne + + + shl eax, 1 + add edi, eax ; (WORD*)ptrdest[y0] + + cmp ebx, edx + jg afp1 + + ; x0 < x1 + + mov ax, dx ; x0 + sub ax, bx ; x1 delta X (>0) + + shl eax, 16 + xor edx, edx + div ecx + + xchg edx, eax +;' shr ax, 1 +;' add ax, 7FFFh + rol edx, 16 + shl eax, 16 + + clc + + mov ax, bx + + inc ecx +;' add ecx, 16 +;' shr ecx, 4 + + ; EAX = .cumul:X + ; EDX = .DeltaX:DeltaX + ALIGN 4 +lt0: +;' REPT 16 + stosw + adc eax, edx +;' ENDM +;' loop lt0 ; pas touche C ? + + dec ecx + jnz lt0 + + ret + +afp1: ; x0 > x1 + + mov ax, bx ; x1 + sub ax, dx ; x0 delta X (>0) + + shl eax, 16 + xor edx, edx + div ecx + + xchg edx, eax +;' shr ax, 1 +;' add ax, 7FFFh + rol edx, 16 + shl eax, 16 + + clc ; la 1ere valeur est bonne + mov ax, bx ; x0 + + inc ecx +;' add ecx, 16 +;' shr ecx, 4 + + ; EAX = .cumul:X + ; EDX = .DeltaX:DeltaX + ALIGN 4 +afp2: +;' REPT 16 + stosw + sbb eax, edx +;' ENDM +;' loop afp2 + + dec ecx + jnz afp2 + +nofill: ret + +nofill1: pop edx + pop edi + ret + +nofill2: pop eax + pop edi + ret + +AsmFillProp endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +AsmFillPropNoClip proc uses esi edi ebx ebp,\ + ptrdest:DWORD, x0:DWORD, y0:DWORD, x1:DWORD, y1:DWORD + + mov edi, ptrdest + + mov eax, y0 + + mov ecx, y1 + + mov ebx, x0 + mov edx, x1 + + cmp eax, ecx ; y0 < y1 + jle afp0 + + xchg eax, ecx ; y0 <> y1 + xchg ebx, edx ; x0 <> x1 + +afp0: sub ecx, eax ; ecx deltay > 0 + + shl eax, 1 + add edi, eax ; (WORD*)ptrdest[y0] + + cmp ebx, edx + jg afp1 + + ; x0 < x1 + + mov ax, dx ; x0 + sub ax, bx ; x1 delta X (>0) + + shl eax, 16 + xor edx, edx + div ecx + + inc ecx + + xchg edx, eax + shr ax, 1 + add ax, 7FFFh + rol edx, 16 + shl eax, 16 + + clc + + mov ax, bx + + ; EAX = .cumul:X + ; EDX = .DeltaX:DeltaX + ALIGN 4 +lt0: stosw + adc eax, edx + dec ecx + jnz lt0 + + ret + +afp1: ; x0 > x1 + + mov ax, bx ; x1 + sub ax, dx ; x0 delta X (>0) + + shl eax, 16 + xor edx, edx + div ecx + + inc ecx + + xchg edx, eax + shr ax, 1 + add ax, 7FFFh + rol edx, 16 + shl eax, 16 + + clc ; la 1ere valeur est bonne + mov ax, bx ; x0 + + ; EAX = .cumul:X + ; EDX = .DeltaX:DeltaX + ALIGN 4 +afp2: stosw + sbb eax, edx + dec ecx + jnz afp2 + + ret + +AsmFillPropNoClip endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +A_FillPropNoClip proc + +; mov edi, ptrdest + +; mov eax, y0 +; mov ecx, y1 +; mov ebx, x0 +; mov edx, x1 + + cmp eax, ecx ; y0 < y1 + jle afp0 + + xchg eax, ecx ; y0 <> y1 + xchg ebx, edx ; x0 <> x1 + +afp0: sub ecx, eax ; ecx deltay > 0 + + shl eax, 1 + add edi, eax ; (WORD*)ptrdest[y0] + + cmp ebx, edx + jg afp1 + + ; x0 < x1 + + mov ax, dx ; x0 + sub ax, bx ; x1 delta X (>0) + + shl eax, 16 + xor edx, edx + div ecx + + inc ecx + + xchg edx, eax + shr ax, 1 + add ax, 7FFFh + rol edx, 16 + shl eax, 16 + + clc + + mov ax, bx + + ; EAX = .cumul:X + ; EDX = .DeltaX:DeltaX + ALIGN 4 +lt0: stosw + adc eax, edx + dec ecx + jnz lt0 + + ret + +afp1: ; x0 > x1 + + mov ax, bx ; x1 + sub ax, dx ; x0 delta X (>0) + + shl eax, 16 + xor edx, edx + div ecx + + inc ecx + + xchg edx, eax + shr ax, 1 + add ax, 7FFFh + rol edx, 16 + shl eax, 16 + + clc ; la 1ere valeur est bonne + mov ax, bx ; x0 + + ; EAX = .cumul:X + ; EDX = .DeltaX:DeltaX + ALIGN 4 +afp2: stosw + sbb eax, edx + dec ecx + jnz afp2 + + ret + +A_FillPropNoClip endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +AsmTexturedTriangleNoClip proc uses esi edi ebx ebp + +PX0 TEXTEQU +PY0 TEXTEQU +PX1 TEXTEQU +PY1 TEXTEQU +PX2 TEXTEQU +PY2 TEXTEQU + +TX0 TEXTEQU +TY0 TEXTEQU +TX1 TEXTEQU +TY1 TEXTEQU +TX2 TEXTEQU +TY2 TEXTEQU + + mov LYmin, 32000 + mov LYmax, -32000 + + movzx eax, PY0 + movzx ecx, PY1 + + cmp eax, ecx + jge ttnc0 + + cmp eax, LYmin + jg ttnc1 + mov LYmin, eax +ttnc1: + cmp ecx, LYmax + jl ttnc2 + mov LYmax, ecx +ttnc2: + mov edi, offset TabGauche + movzx ebx, PX0 +; movzx eax, PY0 + movzx edx, PX1 +; movzx ecx, PY1 + call A_FillPropNoClip + + mov edi, offset TabX0 + movzx ebx, TX0 + movzx eax, PY0 + movzx edx, TX1 + movzx ecx, PY1 + call A_FillPropNoClip + + mov edi, offset TabY0 + movzx ebx, TY0 + movzx eax, PY0 + movzx edx, TY1 + movzx ecx, PY1 + call A_FillPropNoClip +ttnc0: + movzx eax, PY0 + movzx ecx, PY1 + + cmp eax, ecx + jle ttnc0a + + cmp ecx, LYmin + jg ttnc1a + mov LYmin, ecx +ttnc1a: + cmp eax, LYmax + jl ttnc2a + mov LYmax, eax +ttnc2a: + mov edi, offset TabDroite + movzx ebx, PX0 +; movzx eax, PY0 + movzx edx, PX1 +; movzx ecx, PY1 + call A_FillPropNoClip + + mov edi, offset TabX1 + movzx ebx, TX0 + movzx eax, PY0 + movzx edx, TX1 + movzx ecx, PY1 + call A_FillPropNoClip + + mov edi, offset TabY1 + movzx ebx, TY0 + movzx eax, PY0 + movzx edx, TY1 + movzx ecx, PY1 + call A_FillPropNoClip +ttnc0a: + movzx eax, PY1 + movzx ecx, PY2 + + cmp eax, ecx + jge ttnc0b + + cmp eax, LYmin + jg ttnc1b + mov LYmin, eax +ttnc1b: + cmp ecx, LYmax + jl ttnc2b + mov LYmax, ecx +ttnc2b: + mov edi, offset TabGauche + movzx ebx, PX1 +; movzx eax, PY1 + movzx edx, PX2 +; movzx ecx, PY2 + call A_FillPropNoClip + + mov edi, offset TabX0 + movzx ebx, TX1 + movzx eax, PY1 + movzx edx, TX2 + movzx ecx, PY2 + call A_FillPropNoClip + + mov edi, offset TabY0 + movzx ebx, TY1 + movzx eax, PY1 + movzx edx, TY2 + movzx ecx, PY2 + call A_FillPropNoClip +ttnc0b: + movzx eax, PY1 + movzx ecx, PY2 + + cmp eax, ecx + jle ttnc0c + + cmp ecx, LYmin + jg ttnc1c + mov LYmin, ecx +ttnc1c: + cmp eax, LYmax + jl ttnc2c + mov LYmax, eax +ttnc2c: + + mov edi, offset TabDroite + movzx ebx, PX1 +; movzx eax, PY1 + movzx edx, PX2 +; movzx ecx, PY2 + call A_FillPropNoClip + + mov edi, offset TabX1 + movzx ebx, TX1 + movzx eax, PY1 + movzx edx, TX2 + movzx ecx, PY2 + call A_FillPropNoClip + + mov edi, offset TabY1 + movzx ebx, TY1 + movzx eax, PY1 + movzx edx, TY2 + movzx ecx, PY2 + call A_FillPropNoClip +ttnc0c: + movzx eax, PY2 + movzx ecx, PY0 + + cmp eax, ecx + jge ttnc0d + + cmp eax, LYmin + jg ttnc1d + mov LYmin, eax +ttnc1d: + cmp ecx, LYmax + jl ttnc2d + mov LYmax, ecx +ttnc2d: + mov edi, offset TabGauche + movzx ebx, PX2 +; movzx eax, PY2 + movzx edx, PX0 +; movzx ecx, PY0 + call A_FillPropNoClip + + mov edi, offset TabX0 + movzx ebx, TX2 + movzx eax, PY2 + movzx edx, TX0 + movzx ecx, PY0 + call A_FillPropNoClip + + mov edi, offset TabY0 + movzx ebx, TY2 + movzx eax, PY2 + movzx edx, TY0 + movzx ecx, PY0 + call A_FillPropNoClip +ttnc0d: + movzx eax, PY2 + movzx ecx, PY0 + + cmp eax, ecx + jle ttnc0e + + cmp ecx, LYmin + jg ttnc1e + mov LYmin, ecx +ttnc1e: + cmp eax, LYmax + jl ttnc2e + mov LYmax, eax +ttnc2e: + mov edi, offset TabDroite + movzx ebx, PX2 +; movzx eax, PY2 + movzx edx, PX0 +; movzx ecx, PY0 + call A_FillPropNoClip + + mov edi, offset TabX1 + movzx ebx, TX2 + movzx eax, PY2 + movzx edx, TX0 + movzx ecx, PY0 + call A_FillPropNoClip + + mov edi, offset TabY1 + movzx ebx, TY2 + movzx eax, PY2 + movzx edx, TY0 + movzx ecx, PY0 + call A_FillPropNoClip +ttnc0e: + ret + +AsmTexturedTriangleNoClip endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +AsmGouraudTriangleNoClip proc uses esi edi ebx ebp + +PI0 TEXTEQU +PX0 TEXTEQU +PY0 TEXTEQU +PI1 TEXTEQU +PX1 TEXTEQU +PY1 TEXTEQU +PI2 TEXTEQU +PX2 TEXTEQU +PY2 TEXTEQU + + mov LYmin, 32000 + mov LYmax, -32000 + + movzx eax, PY0 + movzx ecx, PY1 + + cmp eax, ecx + jge ttnc0 + + cmp eax, LYmin + jg ttnc1 + mov LYmin, eax +ttnc1: + cmp ecx, LYmax + jl ttnc2 + mov LYmax, ecx +ttnc2: + mov edi, offset TabGauche + movzx ebx, PX0 +; movzx eax, PY0 + movzx edx, PX1 +; movzx ecx, PY1 + call A_FillPropNoClip + + mov edi, offset TabCoulG + movzx ebx, PI0 +; shl ebx, 8 + movzx eax, PY0 + movzx edx, PI1 +; shl edx, 8 + movzx ecx, PY1 + call A_FillPropNoClip +ttnc0: + movzx eax, PY0 + movzx ecx, PY1 + + cmp eax, ecx + jle ttnc0a + + cmp ecx, LYmin + jg ttnc1a + mov LYmin, ecx +ttnc1a: + cmp eax, LYmax + jl ttnc2a + mov LYmax, eax +ttnc2a: + mov edi, offset TabDroite + movzx ebx, PX0 +; movzx eax, PY0 + movzx edx, PX1 +; movzx ecx, PY1 + call A_FillPropNoClip + + mov edi, offset TabCoulD + movzx ebx, PI0 +; shl ebx, 8 + movzx eax, PY0 + movzx edx, PI1 +; shl edx, 8 + movzx ecx, PY1 + call A_FillPropNoClip + +ttnc0a: + movzx eax, PY1 + movzx ecx, PY2 + + cmp eax, ecx + jge ttnc0b + + cmp eax, LYmin + jg ttnc1b + mov LYmin, eax +ttnc1b: + cmp ecx, LYmax + jl ttnc2b + mov LYmax, ecx +ttnc2b: + mov edi, offset TabGauche + movzx ebx, PX1 +; movzx eax, PY1 + movzx edx, PX2 +; movzx ecx, PY2 + call A_FillPropNoClip + + mov edi, offset TabCoulG + movzx ebx, PI1 +; shl ebx, 8 + movzx eax, PY1 + movzx edx, PI2 +; shl edx, 8 + movzx ecx, PY2 + call A_FillPropNoClip +ttnc0b: + movzx eax, PY1 + movzx ecx, PY2 + + cmp eax, ecx + jle ttnc0c + + cmp ecx, LYmin + jg ttnc1c + mov LYmin, ecx +ttnc1c: + cmp eax, LYmax + jl ttnc2c + mov LYmax, eax +ttnc2c: + + mov edi, offset TabDroite + movzx ebx, PX1 +; movzx eax, PY1 + movzx edx, PX2 +; movzx ecx, PY2 + call A_FillPropNoClip + + mov edi, offset TabCoulD + movzx ebx, PI1 +; shl ebx, 8 + movzx eax, PY1 + movzx edx, PI2 +; shl edx, 8 + movzx ecx, PY2 + call A_FillPropNoClip + +ttnc0c: + movzx eax, PY2 + movzx ecx, PY0 + + cmp eax, ecx + jge ttnc0d + + cmp eax, LYmin + jg ttnc1d + mov LYmin, eax +ttnc1d: + cmp ecx, LYmax + jl ttnc2d + mov LYmax, ecx +ttnc2d: + mov edi, offset TabGauche + movzx ebx, PX2 +; movzx eax, PY2 + movzx edx, PX0 +; movzx ecx, PY0 + call A_FillPropNoClip + + mov edi, offset TabCoulG + movzx ebx, PI2 +; shl ebx, 8 + movzx eax, PY2 + movzx edx, PI0 +; shl edx, 8 + movzx ecx, PY0 + call A_FillPropNoClip + +ttnc0d: + movzx eax, PY2 + movzx ecx, PY0 + + cmp eax, ecx + jle ttnc0e + + cmp ecx, LYmin + jg ttnc1e + mov LYmin, ecx +ttnc1e: + cmp eax, LYmax + jl ttnc2e + mov LYmax, eax +ttnc2e: + mov edi, offset TabDroite + movzx ebx, PX2 +; movzx eax, PY2 + movzx edx, PX0 +; movzx ecx, PY0 + call A_FillPropNoClip + + mov edi, offset TabCoulD + movzx ebx, PI2 +; shl ebx, 8 + movzx eax, PY2 + movzx edx, PI0 +; shl edx, 8 + movzx ecx, PY0 + call A_FillPropNoClip +ttnc0e: + + mov ax, word ptr[LYmin] + mov Ymin, ax + + mov ax, word ptr[LYmax] + mov Ymax, ax + + ret + +AsmGouraudTriangleNoClip endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; ßßÛßß Ûßßßß ßÜ Üß ßßÛßß Û Û ÛßßßÛ Ûßßßß ÛÛßßß +; ÛÛ ÛÛßß ÜßÜ ÛÛ ÛÛ Û ÛÛßÛß ÛÛßß ßßßßÛ +; ßß ßßßßß ß ß ßß ßßßßß ßß ß ßßßßß ßßßßß +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +FillTextPolyShade proc uses esi edi ebx ebp,\ + pymin:DWORD, pymax:DWORD, dark:DWORD, source:DWORD + + mov eax, dark + mov [darkdec], ax + + mov edi, [Log] + + mov ebx, pymin + add edi, TabOffLine[ ebx*4 ] + + mov [ptrlig], edi + + mov eax, source + mov [ptrmap], eax + + mov ecx, pymax + sub ecx, ebx + inc ecx + mov [loopy], cx + + mov esi, offset TabGauche + shl ebx, 1 ; ymin * word + add esi, ebx + + mov [ptrtab], esi + +l3: mov edi, [ptrlig] + mov esi, [ptrtab] + + movsx eax, word ptr[ esi + TAB_GAUCHE ] +; add edi, eax + + movsx ecx, word ptr[ esi + TAB_DROITE ] + sub ecx, eax + jle l4 ; prevoir cas 1 point + + movzx eax, word ptr[ esi + TAB_Y0 ] + movzx ebp, word ptr[ esi + TAB_Y1 ] + sub eax, ebp + neg eax ; -(y0-y1) + inc eax + cdq + idiv ecx + mov [ystep], eax ; step y source + + movzx eax, word ptr[ esi + TAB_X1 ] ; delta x + movzx ebp, word ptr[ esi + TAB_X0 ] + sub eax, ebp + inc eax + cdq + idiv ecx + mov [xstep], eax ; step x source + + xor eax, eax + mov ax, word ptr[ esi + TAB_GAUCHE ] + cmp ax, word ptr[ ClipXmin ] + jge noclpleft + + ; clip x min + + sub ax, word ptr[ ClipXmin ] + mov bx, ax + + imul word ptr[xstep] + sub word ptr[ esi + TAB_X0 ], ax + + mov ax, bx + imul word ptr[ystep] + sub word ptr[ esi + TAB_Y0 ], ax + + mov ax, word ptr[ ClipXmin ] + +noclpleft: add edi, eax + + mov cx, word ptr[ esi + TAB_DROITE ] + cmp cx, word ptr[ ClipXmax ] + jle noclpright + + ; clip x max + + mov cx, word ptr[ ClipXmax ] + +noclpright: sub cx, ax + inc cx + jle l4 + + mov [boucle], cx + + mov ecx, [ptrmap] + + mov dx, word ptr[ esi + TAB_X0 ] + xor ebx, ebx + mov bx, word ptr[ esi + TAB_Y0 ] ; precision ? + + mov esi, [xstep] + mov ebp, [ystep] + + ALIGN 4 +l2: xchg bl,dh ; bl <- dh colonne + mov al,byte ptr[ecx+ebx] ; bh ligne * 256 + xchg bl,dh + + mov ah, al + and al, 15 + sub al, byte ptr[darkdec] + jc ovfshd + and ah, 240 + or al, ah + + mov byte ptr[edi], al + inc edi + + add dx, si + add bx, bp + + dec word ptr[boucle] + jnz l2 + + +l4: add [ptrlig], 640 + add [ptrtab], 2 + + dec word ptr[loopy] + jnz l3 + + ret + +ovfshd: + and ah, 240 + mov al, ah + + mov byte ptr[edi], al + inc edi + + add dx, si + add bx, bp + + dec word ptr[boucle] + jnz l2 + + add [ptrlig], 640 + add [ptrtab], 2 + + dec word ptr[loopy] + jnz l3 + + ret + +FillTextPolyShade endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +FillTextPoly proc uses esi edi ebx ebp,\ + pymin:DWORD, pymax:DWORD, source:DWORD + + mov edi, [Log] + + mov ebx, pymin + add edi, TabOffLine[ ebx*4 ] + + mov [ptrlig], edi + + mov eax, source + mov [ptrmap], eax + + mov ecx, pymax + sub ecx, ebx + inc ecx + mov [loopy], cx + + mov esi, offset TabGauche + shl ebx, 1 ; ymin * word + add esi, ebx + + mov [ptrtab], esi + +l3: mov edi, [ptrlig] + mov esi, [ptrtab] + + movsx eax, word ptr[ esi + TAB_GAUCHE ] +; add edi, eax + + movsx ecx, word ptr[ esi + TAB_DROITE ] + sub ecx, eax + jle l4 ; prevoir cas 1 point + + movzx eax, word ptr[ esi + TAB_Y0 ] + movzx ebp, word ptr[ esi + TAB_Y1 ] + sub eax, ebp + neg eax ; -(y0-y1) + inc eax + cdq + idiv ecx + mov [ystep], eax ; step y source + + movzx eax, word ptr[ esi + TAB_X1 ] ; delta x + movzx ebp, word ptr[ esi + TAB_X0 ] + sub eax, ebp + inc eax + cdq + idiv ecx + mov [xstep], eax ; step x source + + xor eax, eax + mov ax, word ptr[ esi + TAB_GAUCHE ] + cmp ax, word ptr[ ClipXmin ] + jge noclpleft + + ; clip x min + + sub ax, word ptr[ ClipXmin ] + mov bx, ax + + imul word ptr[xstep] + sub word ptr[ esi + TAB_X0 ], ax + + mov ax, bx + imul word ptr[ystep] + sub word ptr[ esi + TAB_Y0 ], ax + + mov ax, word ptr[ ClipXmin ] + +noclpleft: add edi, eax + + mov cx, word ptr[ esi + TAB_DROITE ] + cmp cx, word ptr[ ClipXmax ] + jle noclpright + + ; clip x max + + mov cx, word ptr[ ClipXmax ] + +noclpright: sub cx, ax + inc cx + jle l4 + + mov [boucle], cx + + mov ecx, [ptrmap] + + mov dx, word ptr[ esi + TAB_X0 ] + xor ebx, ebx + mov bx, word ptr[ esi + TAB_Y0 ] ; precision ? + + mov esi, [xstep] + mov ebp, [ystep] + + ALIGN 4 +l2: xchg bl,dh ; bl <- dh colonne + mov al,byte ptr[ecx+ebx] ; bh ligne * 256 + xchg bl,dh + + mov byte ptr[edi], al + inc edi + + add dx, si + add bx, bp + + dec word ptr[boucle] + jnz l2 + + +l4: add [ptrlig], 640 + add [ptrtab], 2 + + dec word ptr[loopy] + jnz l3 + + + ret + +FillTextPoly endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +FillTextPolyNoClip proc uses esi edi ebx ebp,\ + pymin:DWORD, pymax:DWORD, source:DWORD + +; for( y=ymin; y<=ymax; y++ ) +; { +; xg = TabGauche[y] ; +; xd = TabDroite[y] ; +; +; x0 = TabX0[y] ; +; y0 = TabY0[y] ; +; +; x1 = TabX1[y] ; +; y1 = TabY1[y] ; +; +; CopyLine( xg, y, xd-xg+1, x0,y0, x1,y1, ptrmap ) ; +; } + + mov edi, [Log] + + mov ebx, pymin + add edi, TabOffLine[ ebx*4 ] + + mov [ptrlig], edi + + mov eax, source + mov [ptrmap], eax + + mov ecx, pymax + sub ecx, ebx + inc ecx + mov [loopy], cx + + mov esi, offset TabGauche + shl ebx, 1 ; ymin * word + add esi, ebx + + mov [ptrtab], esi + +l3: +;' mov ebx, [ptrmap] + mov edi, [ptrlig] + mov esi, [ptrtab] + + movsx eax, word ptr[ esi + TAB_GAUCHE ] + add edi, eax + + movsx ecx, word ptr[ esi + TAB_DROITE ] + sub ecx, eax +;' inc ecx + jle l4 + + movzx eax, word ptr[ esi + TAB_Y0 ] +;' mov edx, eax +;' and edx, 0FFFFFF00h + +;' add ebx, edx ; + start buf + + movzx ebp, word ptr[ esi + TAB_Y1 ] + sub eax, ebp + neg eax ; -(y0-y1) + inc eax + cdq + idiv ecx + mov [ystep], eax ; step y source + + movzx eax, word ptr[ esi + TAB_X1 ] ; delta x + movzx ebp, word ptr[ esi + TAB_X0 ] + sub eax, ebp + inc eax + cdq + idiv ecx + mov [xstep], eax ; step x source + mov edx, ebp ; word ptr[ esi + TAB_X0 ] + + + mov [boucle], cx + +;' mov ecx, ebx ; ecx ptr source + mov ecx, [ptrmap] + + xor ebx, ebx + mov bx, word ptr[ esi + TAB_Y0 ] ; precision ? +;' and ebx, 0FFh + + mov esi, [xstep] + mov ebp, [ystep] + + ALIGN 4 +l2: xchg bl,dh ; bl <- dh colonne + + mov al,byte ptr[ecx+ebx] ; bh ligne * 256 + + xchg bl,dh + + mov byte ptr[edi], al + inc edi + +;' add edx, esi +;' add ebx, ebp + + add dx, si + add bx, bp + + dec word ptr[boucle] + jnz l2 + + +l4: add [ptrlig], 640 + add [ptrtab], 2 + + dec word ptr[loopy] + jnz l3 + + ret + +FillTextPolyNoClip endp + + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + + END + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +M_FillTextPoly proc uses esi esi ebx ebp,\ + ymin:DWORD, ymax:DWORD, source:DWORD + + mov edi, [M_Log] + + mov ebx, ymin + + mov eax, ebx + shr eax, 2 + add edi, eax ; TabOffLine[ ebx*4 ] + add edi, 239*80 ; x = 0 = y = 239; + + mov [ptrlig], edi + + mov eax, ebx + and eax, 3 + mov al, byte ptr[Mask_p+eax] + mov byte ptr[maskplane], al + + mov eax, source + mov [ptrmap], eax + + mov ecx, ymax + sub ecx, ebx + inc ecx + mov [loopy], cx + + mov esi, offset TabGauche + shl ebx, 1 ; ymin * word + add esi, ebx + + mov [ptrtab], esi + + +l3: + mov ah, byte ptr[maskplane] + + mov dx,3C4h + mov al,02h ; s‚lectionne MAP MASK REGISTER + out dx,ax + + mov edi, [ptrlig] + mov esi, [ptrtab] + + movsx eax, word ptr[ esi + TAB_GAUCHE ] + + movsx ecx, word ptr[ esi + TAB_DROITE ] + sub ecx, eax + jle l4 ; prevoir cas 1 point + + movzx eax, word ptr[ esi + TAB_Y0 ] + movzx ebp, word ptr[ esi + TAB_Y1 ] + sub eax, ebp + neg eax ; -(y0-y1) + inc eax + cdq + idiv ecx + mov [ystep], eax ; step y source + + movzx eax, word ptr[ esi + TAB_X1 ] ; delta x + movzx ebp, word ptr[ esi + TAB_X0 ] + sub eax, ebp + inc eax + cdq + idiv ecx + mov [xstep], eax ; step x source + + xor eax, eax + mov ax, word ptr[ esi + TAB_GAUCHE ] + mov bx, 239 + sub bx, word ptr[ ClipYmax ] + cmp ax, bx + jge noclpleft + + ; clip x min + + mov bx, 239 + sub bx, word ptr[ ClipYmax ] + sub ax, bx + mov bx, ax + + imul word ptr[xstep] + sub word ptr[ esi + TAB_X0 ], ax + + mov ax, bx + imul word ptr[ystep] + sub word ptr[ esi + TAB_Y0 ], ax + + mov ax, 239 + sub ax, word ptr[ ClipYmax ] + +noclpleft: mov ecx, eax + shl eax, 2 + add eax, ecx + shl eax, 4 ; *80 + sub edi, eax ; sur bonne ligne + mov eax, ecx + + mov cx, word ptr[ esi + TAB_DROITE ] + mov dx, 239 + sub dx, word ptr[ ClipYmin ] + cmp cx, dx + jle noclpright + + ; clip x max + + mov cx, dx ; mov cx, word ptr[ ClipXmax ] + +noclpright: sub cx, ax + inc cx + jle l4 + + mov [boucle], cx + + mov ecx, [ptrmap] + + mov dx, word ptr[ esi + TAB_X0 ] + xor ebx, ebx + mov bx, word ptr[ esi + TAB_Y0 ] ; precision ? + + mov esi, [xstep] + mov ebp, [ystep] + + ALIGN 4 +l2: xchg bl,dh ; bl <- dh colonne + mov al,byte ptr[ecx+ebx] ; bh ligne * 256 + xchg bl,dh + + mov byte ptr[edi], al + sub edi, 80 + + add dx, si + add bx, bp + + dec word ptr[boucle] + jnz l2 + + +l4: + shl byte ptr[maskplane], 1 + cmp byte ptr[maskplane], 16 + jnz l4a + + mov byte ptr[maskplane], 1 + add [ptrlig], 1 + +l4a: + add [ptrtab], 2 + + dec word ptr[loopy] + jnz l3 + + + ret + +M_FillTextPoly endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +M_AsmFillProp proc uses esi edi ebx ebp,\ + ptrdest:DWORD, x0:DWORD, y0:DWORD, x1:DWORD, y1:DWORD + + mov edi, ptrdest + + mov eax, y0 + + mov ecx, y1 + + mov ebx, x0 + mov edx, x1 + + cmp eax, ecx ; y0 < y1 + jle afp0 + + xchg eax, ecx ; y0 <> y1 + xchg ebx, edx ; x0 <> x1 + +afp0: + cmp eax, [ClipXmax] + jg nofill + + cmp ecx, [ClipXmin] + jl nofill + + cmp eax, [ClipXmin] + jl clip_ymin + +afp01: cmp ecx, [ClipXmax] + jle afp00 + +clip_ymax: + + push edi + push eax + + mov edi, ebx + sub edi, edx ; dx + + mov esi, eax + sub esi, ecx ; dy + jz nofill2 + + mov ebp, edx + + mov eax, ecx ; y1 + + sub eax, [ClipXmax] ; ymax - y1 + neg eax + imul edi ; * dx + idiv esi ; / dy + add eax, ebp ; += x1 + mov edx, eax + mov ecx, [ClipXmax] ; y1 = ymax + + pop eax + pop edi + + jmp afp00 + +clip_ymin: + + push edi + push edx + + mov edi, ebx + sub edi, edx ; dx + + mov esi, eax + sub esi, ecx ; dy + jz nofill1 + + mov ebp, ebx + + sub eax, [ClipXmin] ; ymin - y0 + neg eax + imul edi ; * dx + idiv esi ; / dy + add eax, ebp ; += x0 + mov ebx, eax + mov eax, [ClipXmin] ; y0 = ymin + + pop edx + pop edi + + jmp afp01 + +afp00: sub ecx, eax ; ecx deltay >= 0 + + + jz nofill ; GASP mettre cas 1 ligne + + + shl eax, 1 + add edi, eax ; (WORD*)ptrdest[y0] + + cmp ebx, edx + jg afp1 + + ; x0 < x1 + + mov ax, dx ; x0 + sub ax, bx ; x1 delta X (>0) + + shl eax, 16 + xor edx, edx + div ecx + + xchg edx, eax +;' shr ax, 1 +;' add ax, 7FFFh + rol edx, 16 + shl eax, 16 + + clc + + mov ax, bx + + inc ecx +;' add ecx, 16 +;' shr ecx, 4 + + ; EAX = .cumul:X + ; EDX = .DeltaX:DeltaX + ALIGN 4 +lt0: +;' REPT 16 + stosw + adc eax, edx +;' ENDM + dec ecx + jnz lt0 ; pas touche C ? + +;' dec ecx +;' jnz lt0 + + ret + +afp1: ; x0 > x1 + + mov ax, bx ; x1 + sub ax, dx ; x0 delta X (>0) + + shl eax, 16 + xor edx, edx + div ecx + + xchg edx, eax +;' shr ax, 1 +;' add ax, 7FFFh + rol edx, 16 + shl eax, 16 + + clc ; la 1ere valeur est bonne + mov ax, bx ; x0 + + inc ecx +;' add ecx, 16 +;' shr ecx, 4 + + ; EAX = .cumul:X + ; EDX = .DeltaX:DeltaX + ALIGN 4 +afp2: +;' REPT 16 + stosw + sbb eax, edx +;' ENDM + dec ecx + jnz afp2 + +;' dec ecx +;' jnz afp2 + +nofill: ret + +nofill1: pop edx + pop edi + ret + +nofill2: pop eax + pop edi + ret + +M_AsmFillProp endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +; si = shape list +; bx = y list +; bp = x list +; ax = texture resource +; + +disptexture proc + + push ds + + mov cx,dgroup + mov ds,cx + mov ax, es + mov fs, ax ; data texture + mov es, Log + + add si,cl_miny + add bx,cl_leftx + add bp,cl_leftx + + lodsw + mov di,ax + lodsw + sub ax,di + js #dispret + add si,2 + mov boucle,ax + + shl di,1 + mov di,scantab[di] + +blig: + + lodsw ; xd1 + mov cx, ax + lodsw ; xd2 + sub ax, cx + inc ax + jle h1 + mov cx, ax ; delta xd + + mov ax, [bx+2] ; y2 + sub ax, [bx] ; y1 + cwd + idiv cx + + mov stepy, ax + + mov ax, ds:[bp+2] ; x2 + sub ax, ds:[bp] ; x1 + cwd + idiv cx + mov stepx, ax + + mov dx, [bx] + + mov ax, [si-4] ; xd1 + cmp ax, minx1 + jge l0 + + sub ax, minx1 + push ax + imul stepx + sub ds:[bp], ax + pop ax + imul stepy + sub [bx], ax + mov ax, minx1 + +l0: mov cx, [si-2] ; xd2 + cmp cx, maxx1 + jle l1 + mov cx, maxx1 +l1: sub cx, ax + inc cx + jle h1 + + push di + push bx + push bp + push si + + add di, ax + mov dx, ds:[bp] + mov bx, ds:[bx] + mov si, xdda + mov bp, ydda + +bcol: xchg bl,dh + mov al,fs:sp_data[bx] + xchg bl,dh + stosb + add dx,si + add bx,bp + dec ecx + jnz bcol + + pop si + pop bp + pop bx + pop di + +h1: add bx,4 ; next xy + add bp,4 ; next xy + add di,640 ; next lig + + dec boucle + jns #solidloop + +#dispret: pop ds + ret + +disptexture endp + + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +AsmTexturedTriangleNoClip proc uses esi edi ebx ebp + +;' WORD x0, WORD y0, WORD x1, WORD y1, WORD x2, WORD y2, +;' LONG tx0, LONG ty0, LONG tx1, LONG ty1, LONG tx2, LONG ty2, +;' UBYTE *ptrmap ) +;'{ +;' LONG y, ymin, ymax, xd, xg ; +;' WORD tabpoly[3*4] ; + + +;' tabpoly[1] = x0 ; +;' tabpoly[2] = y0 ; +;' tabpoly[4] = x1 ; +;' tabpoly[5] = y1 ; +;' tabpoly[7] = x2 ; +;' tabpoly[8] = y2 ; +;' +;' if( !TestVuePoly( tabpoly ) ) return ; + +PX0 = word ptr[ offset TabPoly + 1*2 ] +PY0 = word ptr[ offset TabPoly + 2*2 ] +PX1 = word ptr[ offset TabPoly + 4*2 ] +PY1 = word ptr[ offset TabPoly + 5*2 ] +PX2 = word ptr[ offset TabPoly + 7*2 ] +PY2 = word ptr[ offset TabPoly + 8*2 ] + +TX0 = word ptr[ offset TabText + 1*2 ] +TY0 = word ptr[ offset TabText + 2*2 ] +TX1 = word ptr[ offset TabText + 4*2 ] +TY1 = word ptr[ offset TabText + 5*2 ] +TX2 = word ptr[ offset TabText + 7*2 ] +TY2 = word ptr[ offset TabText + 8*2 ] + +;' ymin = 32000 ; +;' ymax = -32000 ; + + mov LYmin, 32000 + mov LYmax, -32000 + +;' if( y0 < y1 ) +;' { +;' if( y0 < ymin ) ymin = y0 ; +;' if( y1 > ymax ) ymax = y1 ; + + movzx eax, PY0 + movzx ecx, PY1 + + cmp eax, ecx + jge ttnc0 + + cmp eax, LYmin + jg ttnc1 + mov LYmin, eax +ttnc1: + cmp ecx, LYmax + jl ttnc2 + mov LYmax, ecx +ttnc2: + +;' AsmFillPropNoClip( TabGauche, x0, y0, x1, y1 ) ; + + mov edi, offset TabGauche + movzx ebx, PX0 +; movzx eax, PY0 + movzx edx, PX1 +; movzx ecx, PY1 + + call A_FillPropNoClip + +;' AsmFillPropNoClip( TabX0, tx0, y0, tx1, y1 ) ; + + mov edi, offset TabX0 + movzx ebx, TX0 + movzx eax, PY0 + movzx edx, TX1 + movzx ecx, PY1 + + call A_FillPropNoClip + +;' AsmFillPropNoClip( TabY0, ty0, y0, ty1, y1 ) ; + + mov edi, offset TabY0 + movzx ebx, TY0 + movzx eax, PY0 + movzx edx, TY1 + movzx ecx, PY1 + + call A_FillPropNoClip + +;' } +ttnc0: + +;' if( y0 > y1 ) +;' { +;' if( y0 > ymax ) ymax = y0 ; +;' if( y1 < ymin ) ymin = y1 ; + + movzx eax, PY0 + movzx ecx, PY1 + + cmp eax, ecx + jle ttnc0a + + cmp ecx, LYmin + jg ttnc1a + mov LYmin, ecx +ttnc1a: + cmp eax, LYmax + jl ttnc2a + mov LYmax, eax +ttnc2a: + + + +;' AsmFillPropNoClip( TabDroite, x0,y0, x1,y1 ) ; + + mov edi, offset TabDroite + movzx ebx, PX0 +; movzx eax, PY0 + movzx edx, PX1 +; movzx ecx, PY1 + + call A_FillPropNoClip + +;' AsmFillPropNoClip( TabX1, tx0, y0, tx1, y1 ) ; + + mov edi, offset TabX1 + movzx ebx, TX0 + movzx eax, PY0 + movzx edx, TX1 + movzx ecx, PY1 + + call A_FillPropNoClip + +;' AsmFillPropNoClip( TabY1, ty0, y0, ty1, y1 ) ; + + mov edi, offset TabY1 + movzx ebx, TY0 + movzx eax, PY0 + movzx edx, TY1 + movzx ecx, PY1 + + call A_FillPropNoClip +;' } +ttnc0a: + +;' if( y1 < y2 ) +;' { +;' if( y1 < ymin ) ymin = y1 ; +;' if( y2 > ymax ) ymax = y2 ; + + movzx eax, PY1 + movzx ecx, PY2 + + cmp eax, ecx + jge ttnc0b + + cmp eax, LYmin + jg ttnc1b + mov LYmin, eax +ttnc1b: + cmp ecx, LYmax + jl ttnc2b + mov LYmax, ecx +ttnc2b: + + + +;' AsmFillPropNoClip( TabGauche, x1,y1, x2,y2 ) ; + + mov edi, offset TabGauche + movzx ebx, PX1 +; movzx eax, PY1 + movzx edx, PX2 +; movzx ecx, PY2 + + call A_FillPropNoClip + +;' AsmFillPropNoClip( TabX0, tx1, y1, tx2, y2 ) ; + + mov edi, offset TabX0 + movzx ebx, TX1 + movzx eax, PY1 + movzx edx, TX2 + movzx ecx, PY2 + + call A_FillPropNoClip + +;' AsmFillPropNoClip( TabY0, ty1, y1, ty2, y2 ) ; + + mov edi, offset TabY0 + movzx ebx, TY1 + movzx eax, PY1 + movzx edx, TY2 + movzx ecx, PY2 + + call A_FillPropNoClip +;' } +ttnc0b: + +;' if( y1 > y2 ) +;' { +;' if( y1 > ymax ) ymax = y1 ; +;' if( y2 < ymin ) ymin = y2 ; + + movzx eax, PY1 + movzx ecx, PY2 + + cmp eax, ecx + jle ttnc0c + + cmp ecx, LYmin + jg ttnc1c + mov LYmin, ecx +ttnc1c: + cmp eax, LYmax + jl ttnc2c + mov LYmax, eax +ttnc2c: + +;' AsmFillPropNoClip( TabDroite, x1,y1, x2,y2 ) ; + + mov edi, offset TabDroite + movzx ebx, PX1 +; movzx eax, PY1 + movzx edx, PX2 +; movzx ecx, PY2 + + call A_FillPropNoClip + +;' AsmFillPropNoClip( TabX1, tx1, y1, tx2, y2 ) ; + + mov edi, offset TabX1 + movzx ebx, TX1 + movzx eax, PY1 + movzx edx, TX2 + movzx ecx, PY2 + + call A_FillPropNoClip + +;' AsmFillPropNoClip( TabY1, ty1, y1, ty2, y2 ) ; + + mov edi, offset TabY1 + movzx ebx, TY1 + movzx eax, PY1 + movzx edx, TY2 + movzx ecx, PY2 + + call A_FillPropNoClip +;' } +ttnc0c: + +;' if( y2 < y0 ) +;' { +;' if( y2 < ymin ) ymin = y2 ; +;' if( y0 > ymax ) ymax = y0 ; + + movzx eax, PY2 + movzx ecx, PY0 + + cmp eax, ecx + jge ttnc0d + + cmp eax, LYmin + jg ttnc1d + mov LYmin, eax +ttnc1d: + cmp ecx, LYmax + jl ttnc2d + mov LYmax, ecx +ttnc2d: + +;' AsmFillPropNoClip( TabGauche, x2,y2, x0,y0 ) ; + + mov edi, offset TabGauche + movzx ebx, PX2 +; movzx eax, PY2 + movzx edx, PX0 +; movzx ecx, PY0 + + call A_FillPropNoClip + +;' AsmFillPropNoClip( TabX0, tx2, y2, tx0, y0 ) ; + + mov edi, offset TabX0 + movzx ebx, TX2 + movzx eax, PY2 + movzx edx, TX0 + movzx ecx, PY0 + + call A_FillPropNoClip + +;' AsmFillPropNoClip( TabY0, ty2, y2, ty0, y0 ) ; + + mov edi, offset TabY0 + movzx ebx, TY2 + movzx eax, PY2 + movzx edx, TY0 + movzx ecx, PY0 + + call A_FillPropNoClip +;' } +ttnc0d: + + +;' if( y2 > y0 ) +;' { +;' if( y2 > ymax ) ymax = y2 ; +;' if( y0 < ymin ) ymin = y0 ; + + movzx eax, PY2 + movzx ecx, PY0 + + cmp eax, ecx + jle ttnc0e + + cmp ecx, LYmin + jg ttnc1e + mov LYmin, ecx +ttnc1e: + cmp eax, LYmax + jl ttnc2e + mov LYmax, eax +ttnc2e: + + + +;' AsmFillPropNoClip( TabDroite, x2,y2, x0,y0 ) ; + + mov edi, offset TabDroite + movzx ebx, PX2 +; movzx eax, PY2 + movzx edx, PX0 +; movzx ecx, PY0 + + call A_FillPropNoClip + +;' AsmFillPropNoClip( TabX1, tx2, y2, tx0, y0 ) ; + + mov edi, offset TabX1 + movzx ebx, TX2 + movzx eax, PY2 + movzx edx, TX0 + movzx ecx, PY0 + + call A_FillPropNoClip + +;' AsmFillPropNoClip( TabY1, ty2, y2, ty0, y0 ) ; + + mov edi, offset TabY1 + movzx ebx, TY2 + movzx eax, PY2 + movzx edx, TY0 + movzx ecx, PY0 + + call A_FillPropNoClip +;' } +ttnc0e: + +;' if( ymin < ClipYmin ) ymin = ClipYmin ; +;' if( ymax > ClipYmax ) ymax = ClipYmax ; +;' if( ymin > ClipYmax ) return ; +;' if( ymax < ClipYmin ) return ; + +;' FillTextPolyNoClip( ymin, ymax, ptrmap ) ; +;'} + ret + +AsmTexturedTriangleNoClip endp + +comment @ +/* +void TexturedTriangleNoClip( + WORD x0, WORD y0, WORD x1, WORD y1, WORD x2, WORD y2, + LONG tx0, LONG ty0, LONG tx1, LONG ty1, LONG tx2, LONG ty2, + UBYTE *ptrmap ) +{ + LONG y, ymin, ymax, xd, xg ; + WORD tabpoly[3*4] ; + + + tabpoly[1] = x0 ; + tabpoly[2] = y0 ; + tabpoly[4] = x1 ; + tabpoly[5] = y1 ; + tabpoly[7] = x2 ; + tabpoly[8] = y2 ; + + if( !TestVuePoly( tabpoly ) ) return ; + + ymin = 32000 ; + ymax = -32000 ; + + if( y0 < y1 ) + { + if( y0 < ymin ) ymin = y0 ; + if( y1 > ymax ) ymax = y1 ; + + AsmFillPropNoClip( TabGauche, x0, y0, x1, y1 ) ; + AsmFillPropNoClip( TabX0, tx0, y0, tx1, y1 ) ; + AsmFillPropNoClip( TabY0, ty0, y0, ty1, y1 ) ; + + } + + if( y0 > y1 ) + { + if( y0 > ymax ) ymax = y0 ; + if( y1 < ymin ) ymin = y1 ; + + AsmFillPropNoClip( TabDroite, x0,y0, x1,y1 ) ; + + AsmFillPropNoClip( TabX1, tx0, y0, tx1, y1 ) ; + AsmFillPropNoClip( TabY1, ty0, y0, ty1, y1 ) ; + } + + if( y1 < y2 ) + { + if( y1 < ymin ) ymin = y1 ; + if( y2 > ymax ) ymax = y2 ; + AsmFillPropNoClip( TabGauche, x1,y1, x2,y2 ) ; + + AsmFillPropNoClip( TabX0, tx1, y1, tx2, y2 ) ; + AsmFillPropNoClip( TabY0, ty1, y1, ty2, y2 ) ; + } + + if( y1 > y2 ) + { + if( y1 > ymax ) ymax = y1 ; + if( y2 < ymin ) ymin = y2 ; + AsmFillPropNoClip( TabDroite, x1,y1, x2,y2 ) ; + + AsmFillPropNoClip( TabX1, tx1, y1, tx2, y2 ) ; + AsmFillPropNoClip( TabY1, ty1, y1, ty2, y2 ) ; + } + + if( y2 < y0 ) + { + if( y2 < ymin ) ymin = y2 ; + if( y0 > ymax ) ymax = y0 ; + + AsmFillPropNoClip( TabGauche, x2,y2, x0,y0 ) ; + + AsmFillPropNoClip( TabX0, tx2, y2, tx0, y0 ) ; + AsmFillPropNoClip( TabY0, ty2, y2, ty0, y0 ) ; + } + + if( y2 > y0 ) + { + if( y2 > ymax ) ymax = y2 ; + if( y0 < ymin ) ymin = y0 ; + + AsmFillPropNoClip( TabDroite, x2,y2, x0,y0 ) ; + + AsmFillPropNoClip( TabX1, tx2, y2, tx0, y0 ) ; + AsmFillPropNoClip( TabY1, ty2, y2, ty0, y0 ) ; + } + + + if( ymin < ClipYmin ) ymin = ClipYmin ; + if( ymax > ClipYmax ) ymax = ClipYmax ; + + if( ymin > ClipYmax ) return ; + if( ymax < ClipYmin ) return ; + + FillTextPolyNoClip( ymin, ymax, ptrmap ) ; +} +*/ + @ + diff --git a/LIB386/LIB_SVGA/VESA.ASH b/LIB386/LIB_SVGA/VESA.ASH new file mode 100644 index 0000000..0cc724e --- /dev/null +++ b/LIB386/LIB_SVGA/VESA.ASH @@ -0,0 +1,33 @@ + +vgainfo struc +VESASignature db 4 dup (?) ; 4 signature bytes +VESAVersion dw ? ; VESA version number +OEMStringPtr dd ? ; Pointer to OEM string +Capabilities db 4 dup (?) ; Capabilities of the video environment +VideoModePtr dd ? ; Pointer to supported Super VGA modes +vgainfo ends + +vesamode struc +ModeAttributes dw ? ; mode attributes +WinAAttributes db ? ; window A attributes +WinBAttributes db ? ; window B attributes +WinGranularity dw ? ; window granularity +WinSize dw ? ; window size +WinASegment dw ? ; window A start segment +WinBSegment dw ? ; window B start segment +WinFuncPtr dd ? ; pointer to window function +BytesPerLine dw ? ; bytes per scan line +; +; optional information (provided if bit D1 of ModeAttributes is set) +; +XResolution dw ? ; horizontal resolution +YResolution dw ? ; vertical resolution +XCharSize db ? ; character cell width +YCharSize db ? ; character cell height +NumberOfPlanes db ? ; number of memory planes +BitsPerPixel db ? ; bits per pixel +NumberOfBanks db ? ; number of banks +MemoryModel db ? ; memory model type +BankSize db ? ; bank size in kb +vesamode ends + diff --git a/LIB386/LIB_SVGA/VESA.ASM b/LIB386/LIB_SVGA/VESA.ASM new file mode 100644 index 0000000..e205cd3 --- /dev/null +++ b/LIB386/LIB_SVGA/VESA.ASM @@ -0,0 +1,138 @@ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +; VESA.ASM 386 +; (c) Adeline 1993 +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + +;*--------------------------------------------------------------------------* + + .386 + jumps + + .model FLAT, SYSCALL + + .DATA + + PUBLIC NoLanguage VESA_Error + + extrn NoLanguage ScanLine: DWORD + extrn NoLanguage NonStdVESA: BYTE + extrn NoLanguage BankShift: BYTE + +;---------------------------------------------------------------------------- + +RMI equ $ +RMI_EDI dd 0 +RMI_ESI dd 0 +RMI_EBP dd 0 +RMI_RESERVED dd 0 +RMI_EBX dd 0 +RMI_EDX dd 0 +RMI_ECX dd 0 +RMI_EAX dd 0 +RMI_flags dw 0 +RMI_ES dw 0 +RMI_DS dw 0 +RMI_FS dw 0 +RMI_GS dw 0 +RMI_IP dw 0 +RMI_CS dw 0 +RMI_SP dw 0 +RMI_SS dw 0 + +;---------------------------------------------------------------------------- + +Vesa_Error db 0 + +;---------------------------------------------------------------------------- + + .CODE + + PUBLIC NoLanguage NewBankVesa + PUBLIC NoLanguage InitModeVesa + +;---------------------------------------------------------------------------- +NewBankVesa proc + + push ebx + +Shift equ $+3 + shl ax, 0 + + mov dx, ax + mov eax, 4F05h ; change bank VESA + xor ebx, ebx ; bh = 0, set bank + int 10h + + pop ebx + + ret + +NewBankVesa endp + +;---------------------------------------------------------------------------- +InitModeVesa proc + + mov byte ptr[VESA_Error], 0 + + mov eax, 0100h ; DMPI Allocate Dos Mem + mov ebx, 32 ; 512 byte just in case + int 31h ; return dos segment in ax + push edx ; save selector + push eax ; save real-mode segment + + push es ; save es + mov RMI_ES, ax ; buffer segment + xor RMI_EDI, 0 ; buffer offset 0 + mov RMI_EAX, 4F01h ; Vesa information + mov RMI_ECX, 0101h ; mode 101h + mov ax, ds + mov es, ax ; es = ds (just in case) + mov edi, offset RMI ; registers + mov ax, 0300h ; DMPI generate real-mode int + mov bx, 10h ; int 10h + int 31h + pop es ; restore es + + mov eax, RMI_EAX + cmp ax, 004Fh + jne error + + pop eax ; restore real-mode segment + and eax, 0FFFFh ; only segment + shl eax, 4 ; convert to linear + + movzx ebx, word ptr[eax+10h] + cmp ebx, 640 + je okscan + mov [ScanLine], ebx ; Scanline + mov [NonStdVESA], 1 + +okscan: mov ax, [eax+4] ; get granularity + bsr ax, ax ; get higher bit position + neg al ; - position + add al, 6 ; shift = 6 - position + mov byte ptr[Shift], al + + pop edx ; restore selector + mov eax, 0101h ; DPMI return Dos memory + int 31h + + mov ax, 4F02h ; Switch to Video Mode + mov bx, 0101h ; VESA 640*480*256 + int 10h + ret +error: + pop eax + pop edx ; restore selector + mov eax, 0101h ; DPMI return Dos memory + int 31h + + mov byte ptr[VESA_Error], 1 + + ret + +InitModeVesa endp + +;---------------------------------------------------------------------------- + + END diff --git a/LIB386/LIB_SVGA/VESA.INC b/LIB386/LIB_SVGA/VESA.INC new file mode 100644 index 0000000..0cc724e --- /dev/null +++ b/LIB386/LIB_SVGA/VESA.INC @@ -0,0 +1,33 @@ + +vgainfo struc +VESASignature db 4 dup (?) ; 4 signature bytes +VESAVersion dw ? ; VESA version number +OEMStringPtr dd ? ; Pointer to OEM string +Capabilities db 4 dup (?) ; Capabilities of the video environment +VideoModePtr dd ? ; Pointer to supported Super VGA modes +vgainfo ends + +vesamode struc +ModeAttributes dw ? ; mode attributes +WinAAttributes db ? ; window A attributes +WinBAttributes db ? ; window B attributes +WinGranularity dw ? ; window granularity +WinSize dw ? ; window size +WinASegment dw ? ; window A start segment +WinBSegment dw ? ; window B start segment +WinFuncPtr dd ? ; pointer to window function +BytesPerLine dw ? ; bytes per scan line +; +; optional information (provided if bit D1 of ModeAttributes is set) +; +XResolution dw ? ; horizontal resolution +YResolution dw ? ; vertical resolution +XCharSize db ? ; character cell width +YCharSize db ? ; character cell height +NumberOfPlanes db ? ; number of memory planes +BitsPerPixel db ? ; bits per pixel +NumberOfBanks db ? ; number of banks +MemoryModel db ? ; memory model type +BankSize db ? ; bank size in kb +vesamode ends + diff --git a/LIB386/LIB_SVGA/ZOOM.ASM b/LIB386/LIB_SVGA/ZOOM.ASM new file mode 100644 index 0000000..1db7d53 --- /dev/null +++ b/LIB386/LIB_SVGA/ZOOM.ASM @@ -0,0 +1,288 @@ + .386p + jumps + .model SMALL, SYSCALL + + .data + + include svga.ash + +EVEN + +Virgule dw 00 + +ALIGN 4 + +Largeur dd 0000 +OffsetLine dd 0000 +PoidFort dd 0000 +Hauteur dd 0000 + + .code + + public NoLanguage ScaleLine + public NoLanguage ScaleBox + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +ScaleBox proc uses ebx esi edi ebp,\ + xs0:DWORD, ys0:DWORD, xs1:DWORD, ys1:DWORD, ptrs:DWORD,\ + xd0:DWORD, yd0:DWORD, xd1:DWORD, yd1:DWORD, ptrd:DWORD + + mov esi, ptrs + mov edi, ptrd + + mov eax, xd0 + add edi, eax + mov ecx, xd1 + sub ecx, eax ; ECX delta x screen + + + mov edx, xs0 ; start x source + add esi, edx + mov eax, xs1 ; end x source + sub eax, edx ; delta source + inc eax + shl eax, 16 ; *65536 + + xor edx, edx + div ecx + mov [Virgule], ax + shr eax, 16 ; poid fort + mov [PoidFort], eax + + inc ecx + mov [Largeur], ecx + mov eax, 640 + sub eax, ecx + mov [OffsetLine], eax + + mov eax, yd0 + add edi, TabOffLine[eax*4] + mov ecx, yd1 + sub ecx, eax + + mov eax, ys0 + add esi, TabOffLine[eax*4] + mov edx, eax + + mov eax, ys1 + sub eax, edx + inc eax + shl eax, 16 + + xor edx, edx + div ecx + inc ecx + mov [Hauteur], ecx + mov ebp, eax + shr ebp, 16 + mov dx, ax + xor bx, bx + +yloop: push ebp + push edx + push ebx + push esi + + mov ebp, [PoidFort] + mov dx, [Virgule] + mov ecx, [Largeur] + xor bx, bx + EVEN +xloop: mov al, byte ptr[esi] + mov [edi], al + inc edi + add bx, dx ; virgule 16 bits + adc esi, ebp ; poid fort + dec ecx + jnz xloop + + add edi, [OffsetLine] ; 640-delta x screen + + pop esi + pop ebx + pop edx + pop ebp + + xor eax, eax + add bx, dx ; virgule 16 bits + adc eax, ebp ; poid fort + add esi, TabOffLine[eax*4] + + dec [Hauteur] + jnz yloop + + ret + +ScaleBox endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +ScaleLine proc uses ebx esi edi ebp,\ + xs0:DWORD, xs1:DWORD, ptrs:DWORD,\ + xe0:DWORD, xe1:DWORD, ptrd:DWORD + + + mov esi, ptrs + mov edi, ptrd + + mov eax, xe0 + mov ecx, xe1 + + sub ecx, eax ; ECX delta x screen + ; jz + + mov edx, xs0 ; start x source + mov eax, xs1 ; end x source + + sub eax, edx ; delta source + + shl eax, 16 ; *65536 + xor edx, edx + + div ecx + mov ebp, eax ; EBP step intensite, EDX reste + + shr ebp, 16 ; poid fort + + mov dx, ax + + xor bx, bx + + EVEN +xloop: mov al, byte ptr[esi] + mov [edi], al + inc edi + add bx, dx ; virgule + adc esi, ebp ; poid fort + dec ecx + jnz xloop + + ret + +ScaleLine endp + +;---------------------------------------------------------------------------- +; The + End + + + + +cumul_low dw 00 +cumul_high dw 00 +y_sprite dw 00 + +ScaleSprite proc uses es ds si di,\ + Xaff:WORD,Yaff:WORD,NumSpf:WORD,PtrSpf:PTR,\ + largeur:WORD,hauteur:WORD + + mov ax,largeur + mov cs:word ptr[patch_largeur],ax + + mov ax,hauteur + mov cs:word ptr[patch_hauteur],ax + mov cx,ax + + les di,Log + + mov bx,Yaff + shl bx,1 + mov di,ss:[bx] + add di,Xaff + + lds si,PtrSpf + + mov bx,NumSpf + shl bx,1 + add si,word ptr[si+bx] + add si,4 ; saute start x y + + lodsw + mov cs:word ptr[patch_largeur_sprite],ax ; largeur sprite + mov bx,ax + + lodsw ; hauteur sprite + + xor dx,dx + div cx + mov bp,ax + xor ax,ax + mov y_sprite,ax + div cx + mov cumul_low,ax + + mov ax,bp + mul bx + mov cumul_high,ax + + jmp $+2 + +patch_hauteur equ $+1 + mov cx,1234h + +l1: push cx + push di + +patch_largeur_sprite equ $+1 + mov bx,1234h + +patch_largeur equ $+1 + mov cx,1234h + + mov ax,bx ; delta + xor dx,dx + div cx ; /NbStep + mov bp,ax + xor ax,ax ; reste*65536 + div cx ; /NbStep + mov dx,bp ; low + mov bp,ax ; high + + xor bx,bx + + push si + +cl0: mov al,byte ptr[si] + stosb + add bx,bp + adc si,dx + loop cl0 + + pop si + + mov ax,cumul_low + add y_sprite,ax + jnc l4 + add si,cs:word ptr[patch_largeur_sprite] +l4: add si,cumul_high + + pop di + add di,320 + pop cx + loop l1 + + ret + +ScaleSprite endp + + + + + + + + + + + + + + + + + + + + + diff --git a/LIB386/LIB_SYS/ADELINE.C b/LIB386/LIB_SYS/ADELINE.C new file mode 100644 index 0000000..235c5ec --- /dev/null +++ b/LIB386/LIB_SYS/ADELINE.C @@ -0,0 +1,332 @@ +#include +#include +#include + +#include "f:\projet\lib386\lib_sys\adeline.h" +#include "f:\projet\lib386\lib_sys\lib_sys.h" + +#include "f:\projet\lib386\lib_midi\lib_midi.h" +#include "f:\projet\lib386\lib_samp\lib_wave.h" +#include "f:\projet\lib386\lib_mix\lib_mix.h" +#include "f:\projet\lib386\lib_svga\lib_svga.h" + + +char Driver[_MAX_PATH] ; + +// timer proc for ail_lib + +HTIMER HandleTimer ; + +void NewProc08() ; // dans timer.asm + +extern UBYTE VESA_Error ; + +char PathConfigFile[_MAX_PATH] ; + +char *Adeline="ADELINE" ; + +char MidiFM = 1 ; + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Ûßßßß ÛßßßÛ ÛÛÜ Û Ûßßßß Û Ûßßßß + ÛÛ ÛÛ Û ÛÛßÛÛ ÛÛßß ÛÛ ÛÛ ßÛ + ßßßßß ßßßßß ßß ß ßß ßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +WORD GiveIndexTab( UBYTE **tab, UBYTE *identificateur ) +{ + UBYTE **ptr ; + WORD i = 0 ; + + while( *tab[0] != 0 ) + { + if( !stricmp( *tab, identificateur ) ) + { + return i ; + } + tab++ ; + i++ ; + } + return -1 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void InitAdelineSystem( char *name, LONG inits ) +{ + char **ptridentifier ; + LONG *ptrvar ; + char *ptr, *midiptr=NULL ; + char *defname ; + char *rien="" ; + + printf( "\nCopyright (c) Adeline Software International 1994, All Rights Reserved.\n\n" ); + + *PathConfigFile = 0 ; + + if (!inits) return ; + + if (inits & INIT_VESA) + inits |= INIT_SVGA ; + + defname = getenv(Adeline) ; + + if ((inits & ~(INIT_MCGA | INIT_VESA | INIT_SVGA)) OR (inits == INIT_SVGA)) + { + if(!*name) + { + printf("Error: Empty configuration filename. Go kill the programmer! (Tell him to talk to Serge as well...)\n\n"); + exit(1); + } + if(!FileSize( defname )) + { + if (defname) + { + printf( "Warning: Cannot find configuration file %s as defined in the environment.\n", defname) ; + printf( " Using local configuration file %s.\n\n", name ) ; + } + if(!FileSize( name )) + { + printf( "Error: Cannot find configuration file %s.\n\n", name ) ; + exit( 1 ) ; + } + } + else + name = defname ; + + printf("Please wait, loading drivers using %s...\n\n", name ); + } + else + { + if(FileSize( defname )) + name = defname ; + } + + strcpy(PathConfigFile, name); + +//úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú +// midi device + + + if(inits & INIT_MIDI) + { + printf("Initialising Midi device. Please wait...\n\n"); + + midiptr = Def_ReadString( name, "MidiExec" ) ; + if( midiptr ) + if ((*midiptr!=0) AND stricmp(midiptr, "NoExec")) + { + spawnl(P_WAIT, midiptr, midiptr, NULL); + printf("\n"); + } + + ptr = Def_ReadString( name, "MidiDriver" ) ; + if( !ptr ) + { + printf( "Warning %s: 'MidiDriver' missing\n", name ) ; + ptr = rien ; + } + + if (stricmp(ptr, "NoMidi")) + strcpy( Driver, ptr ) ; + else + Driver[0]=0 ; + + if( Driver[0] != 0 ) /* si driver midi */ + { + + if( !InitMidiDLL( Driver ) ) exit( 1 ) ; + + AskMidiVars( &ptridentifier, &ptrvar ) ; + + while( **ptridentifier ) + { + if (!Def_ReadValue2( name, *ptridentifier, ptrvar++ )) + { + printf( "Error %s: '%s' missing\n", name, *ptridentifier ) ; + exit( 1 ) ; + } + + ptridentifier++ ; + } + + if( !InitMidi() ) exit( 1 ) ; + } + + ptr = Def_ReadString( name, "MidiType" ) ; + if( !ptr ) + { + printf( "Warning %s: 'MidiType' missing\n", name ) ; + ptr = rien ; + } + + if (*ptr) MidiFM = !stricmp(ptr, "FM") ; + } + +//úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú +// svga device + + if(inits & INIT_SVGA) + { + printf("Initialising SVGA device. Please wait...\n\n"); + + if(!(inits & INIT_VESA)) + { + ptr = Def_ReadString( name, "SvgaDriver" ) ; + if( !ptr ) + { + printf( "Warning %s: 'SvgaDriver' missing\n", name ) ; + ptr = rien ; + } + + if ((stricmp( ptr, "VESA" )) AND (*ptr) ) + { + strcpy( Driver, ptr ) ; + if( !SvgaInitDLL( Driver ) ) exit( 1 ) ; + } + else + printf( "Built-in VESA Super VGA Driver\n\n" ) ; + + } + } + else if (inits & INIT_MCGA) + printf( "Built-in MCGA Driver\n\n" ) ; + +//úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú +// mixer device + + if(inits & INIT_MIXER) + { + printf("Initialising Mixer device. Please wait...\n\n"); + + ptr = Def_ReadString( name, "MixerDriver" ) ; + if( !ptr ) + { + printf( "Warning %s: 'MixerDriver' missing\n", name ) ; + ptr = rien ; + } + + if (stricmp(ptr, "NoMixer")) + strcpy( Driver, ptr ) ; + else + Driver[0]=0 ; + + if( Driver[0] != 0 ) /* si driver wave */ + { + + if( !MixerInitDLL( Driver ) ) exit( 1 ) ; + + MixerAskVars( &ptridentifier, &ptrvar ) ; + + while( **ptridentifier ) + { + if (!Def_ReadValue2( name, *ptridentifier, ptrvar++ )) + { + printf( "Error %s: '%s' missing\n", name, *ptridentifier ) ; + exit( 1 ) ; + } + ptridentifier++; + } + } + } + +//úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú +// wave device + + if(inits & INIT_WAVE) + { + printf("Initialising Wave device. Please wait...\n\n"); + + ptr = Def_ReadString( name, "WaveExec" ) ; + if( ptr ) + if ((*ptr!=0) AND stricmp(ptr, "NoExec") AND stricmp(ptr, midiptr)) + { + spawnl(P_WAIT, ptr, ptr, NULL); + printf("\n"); + } + + ptr = Def_ReadString( name, "WaveDriver" ) ; + if( !ptr ) + { + printf( "Warning %s: 'WaveDriver' missing\n", name ) ; + ptr = rien ; + } + + if (stricmp(ptr, "NoWave")) + strcpy( Driver, ptr ) ; + else + Driver[0]=0 ; + + if( Driver[0] != 0 ) /* si driver wave */ + { + + if( !WaveInitDLL( Driver ) ) exit( 1 ) ; + + WaveAskVars( &ptridentifier, &ptrvar ) ; + + while( **ptridentifier ) + { + if (!Def_ReadValue2( name, *ptridentifier, ptrvar++ )) + { + printf( "Error %s: '%s' missing\n", name, *ptridentifier ) ; + exit( 1 ) ; + } + ptridentifier++; + } + + if( !InitWave() ) exit( 1 ) ; + } + } + +//úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú +// system etc + + InitSystem() ; + if (inits & INIT_SVGA) + InitGraphSvga() ; + else if (inits & INIT_MCGA) + InitGraphMcga() ; + + if (VESA_Error) + { + printf( "Error: SVGA card BIOS does not support VESA extensions.\n") ; + printf( " Please refer to your SVGA card documentation for installing VESA driver.\n") ; + exit( 1 ) ; + } + + InitKeyboard() ; + +//úúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúúú +// init Timer (TimerRef et NbF) selon midi install‚e ou non + + if( Midi_Driver_Enable ) + { + HandleTimer = AIL_register_timer( NewProc08 ) ; + AIL_set_timer_frequency( HandleTimer, 50 ) ; + AIL_start_timer( HandleTimer ) ; + } + else + { + InitTimer() ; + } + +// InitSample() ; + +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void ClearAdelineSystem() +{ +// ClearSample() ; + + if( !Midi_Driver_Enable ) ClearTimer() ; + ClearKeyboard() ; + ClearGraphSvga() ; + ClearSystem() ; + ClearWave(); + ClearMidi(); +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ diff --git a/LIB386/LIB_SYS/ADELINE.H b/LIB386/LIB_SYS/ADELINE.H new file mode 100644 index 0000000..fe7fba0 --- /dev/null +++ b/LIB386/LIB_SYS/ADELINE.H @@ -0,0 +1,51 @@ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßßÛ ÛßßßÜ Ûßßßß Û Û ÛÛÜ Û Ûßßßß + ÛÛßßÛ ÛÛ Û ÛÛßß ÛÛ ÛÛ ÛÛßÛÛ ÛÛßß + ßß ß ßßßß ßßßßß ßßßßß ßß ßß ß ßßßßß 386 + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#define ULONG unsigned long int +#define LONG signed long int +#define UWORD unsigned short int +#define WORD signed short int +#define UBYTE unsigned char +#define BYTE signed char + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#define AND && +#define OR || + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#define TRUE 1 +#define FALSE 0 + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LIB386/LIB_SYS/BUFFER_A.ASM b/LIB386/LIB_SYS/BUFFER_A.ASM new file mode 100644 index 0000000..284c0df --- /dev/null +++ b/LIB386/LIB_SYS/BUFFER_A.ASM @@ -0,0 +1,95 @@ +;---------------------------------------------------------------------------- +;' BUFFER_A.ASM 386 +;' (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386p + + .model SMALL, SYSCALL + + .data + + .code + + public NoLanguage MovMem + public NoLanguage RazMem + public NoLanguage CompBuf + +;---------------------------------------------------------------------------- +MovMem proc uses esi edi,\ + pts:DWORD, ptd:DWORD, nb:DWORD + + mov esi, pts + mov edi, ptd + mov eax, nb + + mov ecx, eax + shr ecx, 2 + rep movsd + mov ecx, eax + and ecx, 3 + rep movsb + ret +MovMem endp +;---------------------------------------------------------------------------- +RazMem proc uses edi,\ + buffer:DWORD, longueur:DWORD + + mov edi, buffer + mov ecx, longueur + mov edx, ecx + shr ecx, 2 + xor eax, eax + rep stosd + mov ecx, edx + and ecx, 11b + rep stosb + ret +RazMem endp +;---------------------------------------------------------------------------- +CompBuf proc uses esi edi,\ + pt0:DWORD, pt1:DWORD, nb0:DWORD + + mov esi, pt0 + mov edi, pt1 + mov eax, nb0 + + mov ecx, eax + shr ecx, 2 + rep cmpsd + jne NoGood + + mov ecx, eax + and ecx, 3 + rep cmpsb + jne NoGood + + mov eax, 1 + ret +NoGood: + xor eax, eax + ret +CompBuf endp +;---------------------------------------------------------------------------- +; The + End + + + + + + + + + + + + + + + + + + + + + diff --git a/LIB386/LIB_SYS/BUILD.BAT b/LIB386/LIB_SYS/BUILD.BAT new file mode 100644 index 0000000..0756dbc --- /dev/null +++ b/LIB386/LIB_SYS/BUILD.BAT @@ -0,0 +1,13 @@ +call watcom10 + +pkunzip -o obj >NUL +wmake +pkzip -m obj *.obj >NUL + +call watcom9 + +pkunzip -o obj9 >NUL +wmake WATCOM9=yes +pkzip -m obj9 *.obj >NUL + +call watcom10 \ No newline at end of file diff --git a/LIB386/LIB_SYS/DEFINES.H b/LIB386/LIB_SYS/DEFINES.H new file mode 100644 index 0000000..5f6d965 --- /dev/null +++ b/LIB386/LIB_SYS/DEFINES.H @@ -0,0 +1,113 @@ +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_svga\lib_svga.h" +#include "\projet\lib386\lib_3D\lib_3D.h" +#include "\projet\lib386\lib_menu\lib_menu.h" +#include + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßßÜ Ûßßßß Ûßßßß Û ÛÛÜ Û Ûßßßß ÛÛßßß + ÛÛ Û ÛÛßß ÛÛßß ÛÛ ÛÛßÛÛ ÛÛßß ßßßßÛ + ßßßß ßßßßß ßß ßß ßß ß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + + +#define SIZE_BRICK_XZ 512 +#define SIZE_BRICK_Y 256 +#define DEMI_BRICK_XZ 256 +#define DEMI_BRICK_Y 128 + + +/*---------------- OBJECTS ------------------*/ + +#define MAX_OBJETS 10 + +#define SIZE_PERSO_NAME 32 + +#define MAX_ANIMS 100 + + +typedef struct +{ + /* life tool */ + + UBYTE Name[SIZE_PERSO_NAME+1] ; + UBYTE File3D[_MAX_PATH] ; + + /* game infos */ + + WORD *PtrObj ; + + WORD PosObjX ; + WORD PosObjY ; + WORD PosObjZ ; + + WORD Alpha ; + WORD Beta ; + WORD Gamma ; + + WORD Move ; + UBYTE Col; + UBYTE dummy ; + + WORD AnimMasterRot ; + WORD AnimStepBeta ; + + WORD AnimStepX ; + WORD AnimStepY ; + WORD AnimStepZ ; + + WORD StartAnim ; + WORD Anim ; + WORD Frame ; + WORD FlagAnim ; + WORD NextAnim ; + } T_OBJET ; +typedef struct +{ + WORD Z ; + WORD NumObj ; } T_SORT ; + +typedef struct +{ + WORD NumObj ; + WORD x0 ; + WORD y0 ; + WORD x1 ; + WORD y1 ; } T_OBJ_SELECT ; + +/*---------------- divers ------------------*/ + +#define Rnd(n) (rand()%n) + +#define NUM_PERSO 0 + +#define ISO 1 +#define PCX 2 + +/*---------------- FlagInfos ------------------*/ + +#define INFO_SCREEN_BOX 1 +#define INFO_DRAW_ZV 2 +#define INFO_COOR 4 +#define INFO_FRAME_SPEED 8 + +/*---------------- InitAnim ------------------*/ + +#define ANIM_REPEAT 0 +#define ANIM_THEN 1 +#define ANIM_ALL_THEN 2 + +/*---------------- Script: defines ------------------*/ + +#define NO_MOVE 0 +#define MOVE_MANUAL 1 +#define MOVE_FOLLOW 2 +#define MOVE_GOTO 3 + +/*---------------- The End: error ------------------*/ + +#define FILE_NOT_FOUND 0 +#define NOT_ENOUGH_MEM 1 +#define PROGRAM_OK 2 diff --git a/LIB386/LIB_SYS/DEF_FILE.C b/LIB386/LIB_SYS/DEF_FILE.C new file mode 100644 index 0000000..55b37f2 --- /dev/null +++ b/LIB386/LIB_SYS/DEF_FILE.C @@ -0,0 +1,639 @@ +/* + DEF_FILE (c) Adeline 1993 + +*/ + +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" + +#include +#include +#include +#include +#include + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßßÜ Ûßßßß Ûßßßß Ûßßßß Û Û Ûßßßß + ÛÛ Û ÛÛßß ÛÛßß ÛÛßß ÛÛ ÛÛ ÛÛßß + ßßßß ßßßßß ßß ßßßßß ßß ßß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +UBYTE DefString[256] ; +UBYTE DefValue[50] ; +LONG DefHandle ; +//LONG DefHandleC ; +//LONG DefModeCopy = FALSE ; +UBYTE *PtrDef ; +UBYTE *OrgPtrDef ; +UBYTE *EndPtrDef ; + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +#ifdef OCAZOU +void NextLine() +{ + UBYTE c ; + + do /* saute cr/lf espace */ + { + if( Read( DefHandle, &c, 1L ) == 0L ) return ; + + if( DefModeCopy ) Write( DefHandleC, &c, 1L ) ; + } + while( c >= 32 ) ; +} +#endif +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/* +LONG ReadWord() +{ + UBYTE *ptr ; + UBYTE c ; + + ptr = DefString ; + + do // saute cr/lf espace + { + if( Read( DefHandle, &c, 1L ) == 0L ) return FALSE ; + + if( DefModeCopy ) Write( DefHandleC, &c, 1L ) ; + } + while( c <= 32 ) ; + + do // lit mot + { + *ptr++ = c ; + if( Read( DefHandle, &c, 1L ) == 0L ) c = 26 ; + else + if( DefModeCopy ) Write( DefHandleC, &c, 1L ) ; + } + while( c > 32 ) ; + + *ptr++ = 0 ; + + return TRUE ; +} +*/ + +LONG PtrDefReadWord() +{ + UBYTE *ptr ; + UBYTE c ; + + ptr = DefString ; + + do /* saute cr/lf espace */ + { + c = *PtrDef++ ; + if( PtrDef >= EndPtrDef ) return FALSE ; + } + while( c <= 32 ) ; + + do /* lit mot */ + { + *ptr++ = c ; + c = *PtrDef++ ; + if( PtrDef >= EndPtrDef ) c = 26 ; + } + while( c > 32 ) ; + + *ptr++ = 0 ; + + return TRUE ; +} + +LONG PtrDefReadIdent() +{ + UBYTE *ptr ; + UBYTE c ; + + ptr = DefString ; + + do /* saute cr/lf espace */ + { + c = *PtrDef++ ; + if( PtrDef >= EndPtrDef ) return FALSE ; + } + while( c <= 32 ) ; + + do /* lit mot */ + { + *ptr++ = c ; + c = *PtrDef++ ; + if( PtrDef >= EndPtrDef ) c = 26 ; + } + while( (c >= 32) AND (c != ':') ) ; + + while ( *--ptr == 32 ) ; + + *(ptr+1) = 0 ; + + return TRUE ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +/* +LONG ReadString() +{ + UBYTE *ptr ; + UBYTE c ; + + ptr = DefString ; + + do // saute cr/lf espace + { + if( Read( DefHandle, &c, 1L ) == 0L ) return FALSE ; + } + while( c <= 32 ) ; + + do // lit phrase jusqu'a CR/LF + { + *ptr++ = c ; + if( Read( DefHandle, &c, 1L ) == 0L ) c = 13 ; + } + while( c != 13 ) ; + Read( DefHandle, &c, 1L ) ; // lit LF ou rien si fin + + *ptr++ = 0 ; + + return TRUE ; +} +*/ +void PtrDefReadString() +{ + UBYTE *ptr ; + UBYTE c ; + + ptr = DefString ; + + *ptr = 0 ; + + do // saute espace / tab + { + c = *PtrDef++ ; + if(( PtrDef >= EndPtrDef ) OR + ( c == 13 ) OR + ( c == 10 ) ) + return; + } + while( c <= 32 ) ; + + do /* lit phrase jusqu'a CR/LF */ + { + *ptr++ = c ; + c = *PtrDef++ ; + if( PtrDef >= EndPtrDef ) c = 13 ; + } + while( c >= 32 ) ; + + while ( *--ptr == 32 ) ; + +// PtrDef++ ; /* lit LF ou rien si fin */ + + *(ptr+1) = 0 ; +} +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/* +LONG ReadThisString() +{ + UBYTE *ptr ; + UBYTE c ; + + ptr = DefString ; + + do // saute espace + { + if( Read( DefHandle, &c, 1L ) == 0L ) + { + *ptr = 0 ; + return TRUE ; + } + } + while( c == 32 ) ; + + if( c > 31 ) + { + do // lit phrase jusqu'a CR/LF + { + *ptr++ = c ; + if( Read( DefHandle, &c, 1L ) == 0L ) c = 13 ; + } + while( c != 13 ) ; + } + Read( DefHandle, &c, 1L ) ; // lit LF ou rien si fin + + *ptr++ = 0 ; + + return TRUE ; +} +*/ + +LONG PtrDefReadThisString() +{ + UBYTE *ptr ; + UBYTE c ; + + ptr = DefString ; + + do // saute espace + { + c = *PtrDef++ ; + if( PtrDef >= EndPtrDef ) return FALSE ; + } + while( c == 32 ) ; + + if( c>31 ) // on a pu lire un cr + { + do // lit phrase jusqu'a CR/LF + { + *ptr++ = c ; + c = *PtrDef++ ; + if( PtrDef >= EndPtrDef ) c = 13 ; + } + while( c != 13 ) ; + } + + PtrDef++ ; // lit LF ou rien si fin + + *ptr++ = 0 ; + + return TRUE ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/* +LONG SearchIdentificator( UBYTE *identificateur ) +{ + while( ReadWord() ) + { + if( DefString[strlen(DefString)-1] == ':' ) + { + DefString[strlen(DefString)-1] = 0 ; + if( !strnicmp( identificateur, + DefString, + strlen( identificateur ) ) ) + { + return TRUE ; // identificateur trouve + } + } + } + return FALSE ; +} +*/ + +LONG PtrDefSearchIdentificator( UBYTE *identificateur ) +{ + while( PtrDefReadIdent() ) + { +/* if( DefString[strlen(DefString)-1] == ':' ) + { + DefString[strlen(DefString)-1] = 0 ; +*/ + if( !stricmp( identificateur, DefString ) ) + { + return TRUE ; // identificateur trouve + } +// } + } + return FALSE ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +/* +UBYTE *Def_ReadString( UBYTE *deffic, UBYTE *identificateur ) +{ + DefHandle = OpenRead( deffic ) ; + if( !DefHandle ) return 0L ; + + if( SearchIdentificator( identificateur ) ) + { + if( ReadThisString() ) + { + Close( DefHandle ) ; + return DefString ; + } + } + Close( DefHandle ) ; + return 0L ; +} +*/ + +UBYTE *Def_ReadString( UBYTE *deffic, UBYTE *identificateur ) +{ + OrgPtrDef = PtrDef = LoadMalloc( deffic ) ; + if( !PtrDef ) return 0 ; + EndPtrDef = PtrDef + LoadMallocFileSize ; + + if( PtrDefSearchIdentificator( identificateur ) ) + { + PtrDefReadString() ; + Free( OrgPtrDef ) ; + return DefString ; + } + Free( OrgPtrDef ) ; + return 0 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/* +LONG Def_ReadValue( UBYTE *deffic, UBYTE *identificateur ) +{ + LONG i ; + LONG handle ; + LONG value ; + UBYTE c ; + + DefHandle = OpenRead( deffic ) ; + if( !DefHandle ) return -1L ; + + if( SearchIdentificator( identificateur ) ) + { + if( ReadWord() ) + { + Close( DefHandle ) ; + + c =DefString[strlen(DefString)-1]&~32 ; + if( c == 'H' ) + { + // hexa + value = 0 ; + for( i=0; i +#include +#include +#include +#include + +#include "adeline.h" +#include "lib_sys.h" + +char ItoaTempoString[40] ; /* c'est 17 le max je crois */ + +char *Itoa( LONG value ) +{ + return itoa( value, ItoaTempoString, 10 ) ; +} diff --git a/LIB386/LIB_SYS/DLL.H b/LIB386/LIB_SYS/DLL.H new file mode 100644 index 0000000..75298d0 --- /dev/null +++ b/LIB386/LIB_SYS/DLL.H @@ -0,0 +1,80 @@ +// +// 386FX file & DLL loader functions/equates +// + +#ifndef DLL_H +#define DLL_H + +// +// MetaWare support +// + +#ifdef __HIGHC__ +#define cdecl _CC(_REVERSE_PARMS | _NEAR_CALL) +#pragma Global_aliasing_convention("_%r"); +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef FILE_ERRS +#define FILE_ERRS + +#define NO_ERROR 0 +#define IO_ERROR 1 +#define OUT_OF_MEMORY 2 +#define FILE_NOT_FOUND 3 +#define CANT_WRITE_FILE 4 +#define CANT_READ_FILE 5 +#define DISK_FULL 6 + +#endif + +// #ifndef TYPEDEFS +// #define TYPEDEFS + +// typedef unsigned char UBYTE; +// typedef unsigned short UWORD; +// typedef unsigned long ULONG; +// typedef char BYTE; +// typedef short WORD; +// typedef long LONG; + +// #endif + +// +// DLL loader flags & functions +// + +#define DLLSRC_FILE 0 // *source is filename string +#define DLLSRC_MEM 1 // *source is pointer to DLL image in memory +#define DLLMEM_USER 2 // *dll -> output memory block alloc'd by user +#define DLLMEM_ALLOC 4 // *dll = don't care; allocate & return output mem + +ULONG cdecl DLL_size(void *source, ULONG flags); +void * cdecl DLL_load(void *source, ULONG flags, void *dll); + +// +// File functions +// + +LONG cdecl FILE_error(void); +LONG cdecl FILE_size(BYTE *filename); +void * cdecl FILE_read(BYTE *filename, void *dest); +LONG cdecl FILE_write(BYTE *filename, void *buf, ULONG len); +LONG cdecl FILE_append(BYTE *filename, void *buf, ULONG len); + +#ifdef __cplusplus +} +#endif + +// +// MetaWare support +// + +#ifdef __HIGHC__ +#pragma Global_aliasing_convention(); +#endif + +#endif diff --git a/LIB386/LIB_SYS/DLLLOAD.C b/LIB386/LIB_SYS/DLLLOAD.C new file mode 100644 index 0000000..8bfc4b8 --- /dev/null +++ b/LIB386/LIB_SYS/DLLLOAD.C @@ -0,0 +1,639 @@ +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ +//ÛÛ ÛÛ +//ÛÛ DLLLOAD.C ÛÛ +//ÛÛ ÛÛ +//ÛÛ 32-bit DLL driver loader ÛÛ +//ÛÛ ÛÛ +//ÛÛ V1.00 of 16-Aug-92: Initial version for Watcom C ÛÛ +//ÛÛ V1.01 of 1-May-93: Zortech C++ v3.1 compatibility added ÛÛ +//ÛÛ V1.02 of 16-Nov-93: Metaware High C/C++ v3.1 compatibility added ÛÛ +//ÛÛ ÛÛ +//ÛÛ Project: 386FX Sound & Light(TM) ÛÛ +//ÛÛ Author: John Lemberger ÛÛ +//ÛÛ ÛÛ +//ÛÛ C source compatible with Watcom C386 v9.0 or later ÛÛ +//ÛÛ Zortech C++ v3.1 or later ÛÛ +//ÛÛ MetaWare High C/C++ v3.1 or later ÛÛ +//ÛÛ ÛÛ +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ +//ÛÛ ÛÛ +//ÛÛ Copyright (C) 1991-1993 Miles Design, Inc. ÛÛ +//ÛÛ ÛÛ +//ÛÛ Miles Design, Inc. ÛÛ +//ÛÛ 6702 Cat Creek Trail ÛÛ +//ÛÛ Austin, TX 78731 ÛÛ +//ÛÛ (512) 345-2642 / FAX (512) 338-9630 / BBS (512) 454-9990 ÛÛ +//ÛÛ ÛÛ +//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "adeline.h" +#include "lib_sys.h" + +// +// Entry table types +// + +#define UNUSED_ENTRY 0 +#define BIT16_ENTRY 1 +#define CALL_GATE 2 +#define BIT32_ENTRY 3 +#define FORWARDER_ENTRY 4 +#define PARAMETER_TYPING 0x80 + +// +// Fixup record source +// + +#define BYTE_FIXUP 0x00 +#define BIT16_SELECTOR 0x02 +#define BIT16_POINTER 0x03 +#define BIT16_OFFSET 0x05 +#define BIT32_POINTER 0x06 +#define BIT32_OFFSET 0x07 +#define BIT32_RELATIVE 0x08 +#define FIXUP_ALIAS 0x10 +#define SRC_LIST_FLAG 0x20 + +// +// Fixup record flags +// + +#define INT_REF 0x00 +#define IMP_REF_BY_ORD 0x01 +#define IMP_REF_BY_NAME 0x02 +#define INT_REF_ENTRY_TBL 0x03 +#define ADDITIVE_FIXUP 0x04 +#define BIT32_TARGET 0x10 +#define BIT32_ADDITIVE 0x20 +#define BIT16_OBJECT 0x40 +#define BIT8_ORDINAL 0x80 + +typedef struct +{ + ULONG lxbw; + ULONG format_level; + ULONG cpu_os_type; + ULONG module_version; + ULONG module_flags; + ULONG module_num_of_pages; + ULONG eip_object_num; + ULONG eip; + ULONG esp_object_num; + ULONG esp; + ULONG page_size; + ULONG page_offset_shift; + ULONG fixup_section_size; + ULONG fixup_section_chksum; + ULONG loader_section_size; + ULONG loader_section_chksum; + ULONG object_table_off; + ULONG num_objects_in_module; + ULONG object_page_table_off; + ULONG object_iter_pages_off; + ULONG resource_table_off; + ULONG num_resource_table_entries; + ULONG resident_name_table_off; + ULONG entry_table_off; + ULONG module_directives_off; + ULONG num_module_directives; + ULONG fixup_page_table_off; + ULONG fixup_record_table_off; + ULONG import_module_table_off; + ULONG num_import_mod_entries; + ULONG import_proc_table_off; + ULONG per_page_chksum_off; + ULONG data_pages_off; + ULONG num_preload_pages; + ULONG nonres_name_table_off; + ULONG nonres_name_table_len; + ULONG nonres_name_table_chksum; + ULONG auto_ds_object_num; + ULONG debug_info_off; + ULONG debug_info_len; + ULONG numinstance_preload; + ULONG numinstance_demand; + ULONG heapsize; +} +LX_header_struct; + +typedef struct +{ + ULONG virtual_size; + ULONG reloc_base_addr; + ULONG object_flags; + ULONG page_table_index; + ULONG num_page_table_entries; + ULONG reserved_space; +} +object_table_struct; + +typedef struct +{ + ULONG page_data_offset; + UWORD data_size; + UWORD flags; +} +object_page_table_struct; + +typedef struct +{ + UWORD type_id; + UWORD name_id; + ULONG resource_size; + UWORD object; + ULONG offset; +} +resource_table_struct; + +static LONG disk_err = 0; + +#undef min +#define min(a,b) ((a) < (b) ? (a) : (b)) + +/**********************************************************/ +static void *cdecl DLL_read(ULONG src, ULONG srcoff, ULONG flags, + void *dest, ULONG length) +{ + if (flags & DLLSRC_MEM) + { + memcpy(dest,(BYTE *) src+srcoff,length); + return (void *) (srcoff+length); + } + else + { + lseek(src,(ULONG) srcoff,SEEK_SET); // get LX header offset + read(src,dest,length); + + return (void *) (srcoff+length); + } +} + +/**********************************************************/ +ULONG cdecl DLL_size(void *source, ULONG flags) +{ + BYTE cword[]=" \0"; + void *src_ptr; + LX_header_struct LX_hdr; + object_table_struct object_table; + ULONG lx; + ULONG i; + ULONG LX_offset; + ULONG module_size=0; + + if (flags & DLLSRC_MEM) + lx=(ULONG) source; + else + { + lx=open((BYTE *) source,O_RDONLY | O_BINARY); + + if (lx==-1) // error opening file? + return 0; + } + + // + // Get LX header offset + // + + src_ptr=DLL_read(lx, 0x03c, flags, &LX_offset, 4); + + // + // Check for valid LX marker + // + + src_ptr=DLL_read(lx,LX_offset, flags, cword, 2); + if (strcmp(cword,"LX")) + { + // + // Error: Invalid LX file + // + + close(lx); + return 0; + } + + // + // Read LX header (Tables not included) + // + + src_ptr=DLL_read(lx,LX_offset, flags, &LX_hdr, sizeof(LX_hdr)); + + // + // Read object table; calculate memory needed + // + + src_ptr=(void *)(LX_offset+LX_hdr.object_table_off); + + for(i=0;i +#include +#include +#include +#include + +#include "adeline.h" +#include "lib_sys.h" + + +/*--------------------------------------------------------------------------*/ +LONG OpenRead( char *name ) +{ + int handle ; + + if ( _dos_open( name, O_RDONLY, &handle )) handle = 0 ; + return(handle) ; + +} +/*--------------------------------------------------------------------------*/ +LONG OpenWrite( char *name ) +{ + int handle ; + + if ( _dos_creat( name, _A_NORMAL, &handle )) handle = 0 ; + return(handle) ; + +} +/*--------------------------------------------------------------------------*/ +LONG OpenReadWrite( char *name ) +{ + int handle ; + + if ( _dos_open( name, O_RDWR, &handle )) handle = 0 ; + return(handle) ; + +} +/*--------------------------------------------------------------------------*/ +ULONG Read( LONG handle, void *buffer, ULONG lenread ) +{ + ULONG howmuch ; + + if ( lenread == 0xFFFFFFFFL ) /* -1L */ + lenread = 16000000L ;/* Ca Accelere !! */ + _dos_read( handle, buffer, lenread, (unsigned int *)&howmuch ) ; + return( howmuch ) ; +} +/*--------------------------------------------------------------------------*/ +ULONG Write( LONG handle, void *buffer, ULONG lenwrite ) +{ + ULONG howmuch ; + + _dos_write( handle, buffer, lenwrite, (unsigned int *)&howmuch ) ; + return( howmuch ) ; +} +/*--------------------------------------------------------------------------*/ +void Close( LONG handle ) +{ + _dos_close( handle ) ; +} +/*--------------------------------------------------------------------------*/ +LONG Seek( LONG handle, LONG position, LONG mode ) +{ + return(lseek( handle, position, mode )) ; +} +/*--------------------------------------------------------------------------*/ +LONG Delete( char *name ) +{ + if ( remove( name )) return(0) ; + return(1) ; +} +/*--------------------------------------------------------------------------*/ +ULONG FileSize( char *name ) +{ + int handle ; + ULONG fsize ; + + handle = OpenRead( name ) ; + if ( handle == 0 ) return(0) ; + + fsize = Seek( handle, 0, SEEK_END ); + + Close( handle ) ; + return( fsize ) ; +} +/*-------------------------------------------------------------------------*/ +void AddExt( char *path, char *ext ) +{ +// Version Loran + + +/* + char *pt ; + pt = path ; + while(( *pt != '.' ) AND ( *pt != 0 )) pt++ ; + *pt = 0 ; + strcat( path, ext ) ; +*/ + + + char drive[_MAX_DRIVE] ; + char dir[_MAX_DIR] ; + char name[_MAX_FNAME] ; + char oldext[_MAX_EXT] ; + + _splitpath( path, drive, dir, name, oldext ) ; + + // makepath rajoute le point si necessaire + + // oldext[0] = '.' ; + // if (*ext == '.' ) ext++ ; + // strcpy(oldext+1, ext); + // _makepath( path, drive, dir, name, oldext ) ; + + + _makepath( path, drive, dir, name, ext ) ; +} +/*--------------------------------------------------------------------------*/ +LONG Copy( UBYTE *sname, UBYTE *dname ) +{ + ULONG n, size ; + LONG shandle ; + LONG dhandle ; + UBYTE c ; + + size = FileSize( sname ) ; + if( !size ) return 0L ; + + shandle = OpenRead( sname ) ; + if( !shandle ) return 0L ; + + dhandle = OpenWrite( dname ) ; + if( !dhandle ) + { + Close( shandle ) ; + return 0L ; + } + + for( n=0; n +#include +#include +#include +#include + +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û Û ÛßßßÛ ÛÜ ÜÛ Ûßßßß ÛÜ ÜÛ ÛßßßÛ ÛßßßÛ Û Üß + ÛÛßßÛ ÛÛ ÜÛ ÛÛß Û ÛÛßß ÛÛß Û ÛÛ Û ÛÛßÛß ÛÛß + ßß ß ßßßß ßßßßß ßß ß ßßßßß ßß ß ßßßßß ßß ß ßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +ULONG Size_HQM_Memory = 0 ; +ULONG Size_HQM_Free = 0 ; +UBYTE *Ptr_HQM_Memory = 0 ; +UBYTE *Ptr_HQM_Next = 0 ; + +typedef struct { ULONG Id ; + ULONG Size ; + void **Ptr ; } HQM_HEADER ; + + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +// Init le buffer global + +LONG HQM_Init_Memory( ULONG size ) +{ + if( !Ptr_HQM_Memory ) + { + Ptr_HQM_Memory = Malloc( size + 500 ) ; // recover area + if( Ptr_HQM_Memory ) + { + Size_HQM_Memory = size ; + Size_HQM_Free = size ; + Ptr_HQM_Next = Ptr_HQM_Memory ; + return TRUE ; + } + } + return FALSE ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +// free le buffer global + +void HQM_Clear_Memory() +{ + if( Ptr_HQM_Memory ) + { + Free( Ptr_HQM_Memory ) ; + Size_HQM_Free = 0 ; + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +// alloue un bloc de memoire + +LONG HQM_Alloc( ULONG size, void **ptr ) +{ + if( !Ptr_HQM_Memory ) + { + *ptr = 0 ; + return FALSE ; + } + + if( size <= (Size_HQM_Free + sizeof( HQM_HEADER )) ) + { + *ptr = Ptr_HQM_Next + sizeof( HQM_HEADER ) ; + + ((HQM_HEADER*)Ptr_HQM_Next)->Id = 0x12345678 ; + ((HQM_HEADER*)Ptr_HQM_Next)->Size = size ; + ((HQM_HEADER*)Ptr_HQM_Next)->Ptr = ptr ; + + Ptr_HQM_Next += size + sizeof( HQM_HEADER ) ; + Size_HQM_Free -= size + sizeof( HQM_HEADER ) ; + + return TRUE ; + } + *ptr = 0 ; + return FALSE ; // pas assez de place +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +// free tous les blocs dans le buffer global + +void HQM_Free_All() +{ + if( Ptr_HQM_Memory ) + { + Ptr_HQM_Next = Ptr_HQM_Memory ; + Size_HQM_Free = Size_HQM_Memory ; + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +// resize le dernier bloc de memoire + +void HQM_Shrink_Last( void *ptr, ULONG newsize ) +{ + HQM_HEADER *ptrh ; + ULONG deltasize ; + + if( !Ptr_HQM_Memory ) return ; + + ptrh = (HQM_HEADER*)((UBYTE*)ptr - sizeof( HQM_HEADER )) ; + + if( ptrh->Id != 0x12345678 ) return ; // erreur grave + + deltasize = ptrh->Size - newsize ; + + ptrh->Size -= deltasize ; + + Ptr_HQM_Next -= deltasize ; + Size_HQM_Free += deltasize ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +// libere un bloc de memoire et bouche le trou (remap les ptrs) + +void HQM_Free( void *ptr ) +{ + HQM_HEADER *ptrh ; + UBYTE *ptrs, *ptrd, *ptrm ; + ULONG delsize, movesize ; + + if( !Ptr_HQM_Memory ) return ; + + ptrs = ptrd = (UBYTE*)ptr - sizeof( HQM_HEADER ) ; + + ptrh = (HQM_HEADER*)ptrd ; + if( ptrh->Id != 0x12345678 ) return ; // erreur grave + + delsize = sizeof( HQM_HEADER ) + ptrh->Size ; + ptrs = ptrd + delsize ; + movesize = (ULONG)(Ptr_HQM_Next - ptrs) ; + + ptrm = ptrs ; + while( ptrm < Ptr_HQM_Next ) + { + ptrh = (HQM_HEADER*)ptrm ; + *(UBYTE*)(ptrh->Ptr) = *(UBYTE*)(ptrh->Ptr) - delsize ; + ptrm += ptrh->Size + sizeof( HQM_HEADER ) ; + } + + memmove( ptrd, ptrs, movesize ) ; + + Ptr_HQM_Next -= delsize ; + Size_HQM_Free += delsize ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +// test la coh‚rence du buffer global + +LONG HQM_Check() +{ + HQM_HEADER *ptrh ; + UBYTE *ptr ; + + if( !Ptr_HQM_Memory ) return FALSE ; + + ptr = Ptr_HQM_Memory ; + + while( ptr < Ptr_HQM_Next ) + { + ptrh = (HQM_HEADER*)ptr ; + + if( ptrh->Id != 0x12345678 ) return FALSE ; + + ptr += ptrh->Size + sizeof( HQM_HEADER ) ; + } + return TRUE ; +} diff --git a/LIB386/LIB_SYS/HQ_RESS.C b/LIB386/LIB_SYS/HQ_RESS.C new file mode 100644 index 0000000..723ce40 --- /dev/null +++ b/LIB386/LIB_SYS/HQ_RESS.C @@ -0,0 +1,629 @@ +#include +#include +#include +#include +#include + +#include "adeline.h" +#include "lib_sys.h" +#include "\projet\lib386\lib_samp\lib_wave.h" + +#define RECOVER_AREA 500 + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û Û ÛßßßÛ ÛßßßÛ Ûßßßß ÛÛßßß ÛÛßßß ÛßßßÛ Û Û ÛßßßÛ Ûßßßß Ûßßßß + ÛÛßßÛ ÛÛ ÜÛ ÛÛßÛß ÛÛßß ßßßßÛ ßßßßÛ ÛÛ Û ÛÛ Û ÛÛßÛß ÛÛ ÛÛßß + ßß ß ßßßß ßßßßß ßß ß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßß ß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +WORD HQR_Flag = FALSE ; + +typedef struct { ULONG SizeFile ; + ULONG CompressedSizeFile ; + WORD CompressMethod ; /* 0 stored */ + /* 1 LZS */ + } T_HEADER ; + +void Expand( void *ptrsourcecomp, void *ptrblocdest, ULONG sizefile ) ; + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û Û ÛßßßÛ ÛßßßÛ Û ÛßßßÛ ÛßßßÛ ÛßßßÜ + ÛÛßßÛ ÛÛ ÜÛ ÛÛßÛß ÛÛ ÛÛ Û ÛÛßßÛ ÛÛ Û + ßß ß ßßßß ßß ß ßßßßß ßßßßß ßßßßß ßß ß ßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void *LoadMalloc_HQR( UBYTE *name, UWORD index ) +{ + LONG handle ; + UWORD nbbloc ; + ULONG buffer ; + ULONG seekindex ; + UBYTE *ptrbloc ; + UBYTE *ptrdecomp ; + T_HEADER header ; + + handle = OpenRead( name ) ; + if( !handle ) return 0L ; + + Read( handle, &buffer, 4L ) ; + nbbloc = (UWORD)(buffer / 4L) ; + + if( index >= nbbloc ) + { + Close( handle ) ; + return 0L ; + } + + Seek( handle, index * 4L, SEEK_START ) ; + Read( handle, &seekindex, 4L ) ; + + Seek( handle, seekindex, SEEK_START ) ; + Read( handle, &header, sizeof( header ) ) ; + + ptrbloc = Malloc( header.SizeFile + RECOVER_AREA ) ; + if( !ptrbloc ) + { + Close( handle ) ; + return 0L ; + } + + switch( header.CompressMethod ) + { + case 0: /* Stored */ + Read( handle, ptrbloc, header.SizeFile ) ; + break ; + + case 1: /* LZS */ + ptrdecomp = ptrbloc + header.SizeFile - header.CompressedSizeFile + RECOVER_AREA ; + Read( handle, ptrdecomp, header.CompressedSizeFile ) ; + Expand( ptrdecomp, ptrbloc, header.SizeFile ) ; + break ; + + default: + Free( ptrbloc ) ; + Close( handle ) ; + return 0L ; /* UnKnown version */ + } + + Mshrink( ptrbloc, header.SizeFile ) ; + Close( handle ) ; + + return ptrbloc ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +ULONG Load_HQR( UBYTE *name, void *ptrdest, UWORD index ) +{ + LONG handle ; + UWORD nbbloc ; + ULONG buffer ; + ULONG seekindex ; + UBYTE *ptrdecomp ; + T_HEADER header ; + + handle = OpenRead( name ) ; + if( !handle ) return 0L ; + + Read( handle, &buffer, 4L ) ; + nbbloc = (UWORD)(buffer / 4L) ; + + if( index >= nbbloc ) + { + Close( handle ) ; + return 0L ; + } + + Seek( handle, index * 4L, SEEK_START ) ; + Read( handle, &seekindex, 4L ) ; + + Seek( handle, seekindex, SEEK_START ) ; + Read( handle, &header, sizeof( header ) ) ; + + switch( header.CompressMethod ) + { + case 0: /* Stored */ + Read( handle, ptrdest, header.SizeFile ) ; + break ; + + case 1: /* LZS */ + ptrdecomp = (UBYTE*)ptrdest + header.SizeFile - header.CompressedSizeFile + RECOVER_AREA ; + Read( handle, ptrdecomp, header.CompressedSizeFile ) ; + Expand( ptrdecomp, ptrdest, header.SizeFile ) ; + break ; + + default: + Close( handle ) ; + return 0L ; /* UnKnown version */ + } + + Close( handle ) ; + + return header.SizeFile ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +ULONG Size_HQR( char *name, UWORD index ) +{ + ULONG handle ; + UWORD nbbloc ; + ULONG buffer ; + ULONG seekindex ; + UBYTE *ptrdecomp ; + T_HEADER header ; + + handle = OpenRead( name ) ; + if( !handle ) return 0 ; + + Read( handle, &buffer, 4 ) ; + nbbloc = (UWORD)(buffer / 4) ; + + if( index >= nbbloc ) + { + Close( handle ) ; + return 0 ; + } + + Seek( handle, index * 4, SEEK_START ) ; + Read( handle, &seekindex, 4 ) ; + + if( seekindex ) + { + Seek( handle, seekindex, SEEK_START ) ; + Read( handle, &header, sizeof( T_HEADER ) ) ; + + Close( handle ) ; + + return header.SizeFile ; + } + else + { + Close( handle ) ; + return 0 ; + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û Û ÛßßßÛ ÛßßßÛ ÛÜ ÜÛ ÛßßßÛ Û Û ÛßßßÛ Ûßßßß + ÛÛßßÛ ÛÛ ÜÛ ÛÛßÛß ÛÛß Û ÛÛßßÛ ÛÛ ÛÛ ÛÛ Û ÛÛ + ßß ß ßßßß ßß ß ßßßßß ßß ß ßß ß ßßßßß ßßßßß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +T_HQR_HEADER *HQR_Init_Ressource( char *hqrname, + ULONG maxsize, + UWORD maxindex ) +{ + T_HQR_HEADER *header ; + void *buffer ; + + if( !FileSize( hqrname ) ) return 0 ; // fichier ok ? + + header = Malloc( sizeof(T_HQR_HEADER) + + + sizeof(T_HQR_BLOC) * maxindex ) ; + + if( !header ) return 0 ; // mem ok ? + + buffer = Malloc( maxsize + RECOVER_AREA ) ; + if( !buffer ) return 0 ; // mem ok ? + + strcpy( header->Name, hqrname ) ; + header->MaxSize = + header->FreeSize = maxsize ; + header->MaxIndex = maxindex ; + header->NbIndex = 0 ; + header->Buffer = buffer ; + + return header ; // header +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void HQR_Reset_Ressource( T_HQR_HEADER *header ) +{ + header->FreeSize = header->MaxSize ; + header->NbIndex = 0 ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +LONG HQR_Change_Ressource( T_HQR_HEADER *header, char *newhqrname ) +{ + if( !FileSize( newhqrname ) ) return FALSE ; // fichier ok ? + + strcpy( header->Name, newhqrname ) ; + + header->FreeSize = header->MaxSize ; + header->NbIndex = 0 ; + + return TRUE ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void HQR_Free_Ressource( T_HQR_HEADER *header ) +{ + if( header ) + { + Free( header->Buffer ) ; + Free( header ) ; + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +UWORD HQR_Del_Bloc( T_HQR_HEADER *header, WORD index ) +{ + UWORD n ; + T_HQR_BLOC *ptrbloc ; + ULONG delsize ; + UBYTE *ptr, *ptrs, *ptrd ; + + ptr = (UBYTE*)(header) + sizeof(T_HQR_HEADER) ; + ptrbloc = (T_HQR_BLOC*)(ptr) ; + delsize = ptrbloc[index].Size ; + + if( index < (header->NbIndex-1) ) + { + // shift buffer + ptrd = header->Buffer + ptrbloc[index].Offset ; + ptrs = ptrd + delsize ; + memmove(ptrd, + ptrs, + ((header->Buffer+header->MaxSize) - ptrs) ) ; + + // shift index table + + ptrd = (UBYTE*)&ptrbloc[index] ; + ptrs = ptrd + sizeof( T_HQR_BLOC ) ; + memmove(ptrd, + ptrs, + (header->MaxIndex - (index + 1))*sizeof(T_HQR_BLOC) ) ; + + // shift index value + + for(n=index; n<(header->NbIndex-1); n++ ) + { + ptrbloc[n].Offset -= delsize ; + } + } + + header->NbIndex-- ; + header->FreeSize += delsize ; + + return delsize ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void *HQR_Get( T_HQR_HEADER *header, WORD index ) +{ + UWORD n, oldest ; + ULONG time, testtime ; + UBYTE *ptr ; + T_HQR_BLOC *ptrbloc ; + ULONG size ; + ULONG offset ; + + // ressources + ULONG handle ; + UWORD nbbloc ; + ULONG buffer ; + ULONG seekindex ; + UBYTE *ptrdecomp ; + T_HEADER lzssheader ; + + if( index < 0 ) return 0 ; + + if( (ptrbloc = HQR_GiveIndex( + index, + header->NbIndex, + (UBYTE*)header+sizeof(T_HQR_HEADER) )) != 0 ) + { // existing index + ptrbloc->Time = TimerRef ; + + HQR_Flag = FALSE ; // marque non chargement ressource + + return( header->Buffer + ptrbloc->Offset ) ; + } + else // need load + { +// SaveTimer() ; + size = Size_HQR( header->Name, index ) ; + + // load and expand hqr bloc + + handle = OpenRead( header->Name ) ; + if( !handle ) return 0 ; + + Read( handle, &buffer, 4 ) ; + nbbloc = (UWORD)(buffer / 4) ; + + if( index >= nbbloc ) + { + Close( handle ) ; + return 0 ; + } + + Seek( handle, index * 4, SEEK_START ) ; + Read( handle, &seekindex, 4 ) ; + + if( !seekindex ) + { + Close( handle ) ; + return 0 ; + } + + Seek( handle, seekindex, SEEK_START ) ; + Read( handle, &lzssheader, sizeof( T_HEADER ) ) ; + + // taille decompacte + size = lzssheader.SizeFile ; + + if( !size ) + { + Close( handle ) ; + return 0 ; + } + + // gestion m‚moire + + time = TimerRef ; + + ptr = (UBYTE*)(header) + sizeof(T_HQR_HEADER) ; + ptrbloc = (T_HQR_BLOC*)(ptr) ; + + // check if enough space for bloc or index + + while( (size > header->FreeSize) OR (header->NbIndex >= header->MaxIndex) ) + { + // delete oldest bloc + oldest = 0 ; + testtime = 0 ; + + for( n=0; nNbIndex; n++ ) + { + if( (time-ptrbloc[n].Time) > testtime ) + { + testtime = time - ptrbloc[oldest].Time ; + oldest = n ; + } + } + HQR_Del_Bloc( header, oldest ) ; + } + + // space size ok, load it + + ptr = header->Buffer + header->MaxSize - header->FreeSize ; + +// Load_HQR( header->Name, ptr, index ) ; + + switch( lzssheader.CompressMethod ) + { + case 0: /* Stored */ + Read( handle, ptr, lzssheader.SizeFile ) ; + break ; + + case 1: /* LZS */ + ptrdecomp = (UBYTE*)ptr + lzssheader.SizeFile - lzssheader.CompressedSizeFile + RECOVER_AREA ; + Read( handle, ptrdecomp, lzssheader.CompressedSizeFile ) ; + Expand( ptrdecomp, ptr, lzssheader.SizeFile ) ; + break ; + + default: + Close( handle ) ; + return 0 ; /* UnKnown version */ + } + + Close( handle ) ; + + HQR_Flag = TRUE ; // indicate loaded + + ptrbloc[header->NbIndex].Index = index ; + ptrbloc[header->NbIndex].Time = TimerRef ; + ptrbloc[header->NbIndex].Offset = header->MaxSize - header->FreeSize ; + ptrbloc[header->NbIndex].Size = size ; + + header->NbIndex++ ; + header->FreeSize -= size ; + +// RestoreTimer() ; + + return ptr ; + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +UWORD HQR_Del_Bloc_Sample( T_HQR_HEADER *header, WORD index ) +{ + UWORD n ; + T_HQR_BLOC *ptrbloc ; + ULONG delsize ; + UBYTE *ptr, *ptrs, *ptrd ; + + ptr = (UBYTE*)(header) + sizeof(T_HQR_HEADER) ; + ptrbloc = (T_HQR_BLOC*)(ptr) ; + delsize = ptrbloc[index].Size ; + + if( index < (header->NbIndex-1) ) + { + // shift buffer + ptrd = header->Buffer + ptrbloc[index].Offset ; + ptrs = ptrd + delsize ; +/* memmove(ptrd, + ptrs, + ((header->Buffer+header->MaxSize) - ptrs) ) ; +*/ + WaveMove(ptrd, + ptrs, + ((header->Buffer+header->MaxSize) - ptrs) ) ; + + // shift index table + + ptrd = (UBYTE*)&ptrbloc[index] ; + ptrs = ptrd + sizeof( T_HQR_BLOC ) ; + memmove(ptrd, + ptrs, + (header->MaxIndex - (index + 1))*sizeof(T_HQR_BLOC) ) ; + + // shift index value + + for(n=index; n<(header->NbIndex-1); n++ ) + { + ptrbloc[n].Offset -= delsize ; + } + } + + header->NbIndex-- ; + header->FreeSize += delsize ; + + return delsize ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void *HQR_GetSample( T_HQR_HEADER *header, WORD index ) +{ + UWORD n, oldest ; + ULONG time, testtime ; + UBYTE *ptr ; + T_HQR_BLOC *ptrbloc ; + ULONG size ; + ULONG offset ; + + // ressources + ULONG handle ; + UWORD nbbloc ; + ULONG buffer ; + ULONG seekindex ; + UBYTE *ptrdecomp ; + T_HEADER lzssheader ; + + if( index < 0 ) return 0 ; + + if( (ptrbloc = HQR_GiveIndex( + index, + header->NbIndex, + (UBYTE*)header+sizeof(T_HQR_HEADER) )) != 0 ) + { // existing index + ptrbloc->Time = TimerRef ; + + HQR_Flag = FALSE ; // marque non chargement ressource + + return( header->Buffer + ptrbloc->Offset ) ; + } + else // need load + { +// SaveTimer() ; + size = Size_HQR( header->Name, index ) ; + + // load and expand hqr bloc + + handle = OpenRead( header->Name ) ; + if( !handle ) return 0 ; + + Read( handle, &buffer, 4 ) ; + nbbloc = (UWORD)(buffer / 4) ; + + if( index >= nbbloc ) + { + Close( handle ) ; + return 0 ; + } + + Seek( handle, index * 4, SEEK_START ) ; + Read( handle, &seekindex, 4 ) ; + + if( !seekindex ) + { + Close( handle ) ; + return 0 ; + } + + Seek( handle, seekindex, SEEK_START ) ; + Read( handle, &lzssheader, sizeof( T_HEADER ) ) ; + + // taille decompacte + size = lzssheader.SizeFile ; + + if( !size ) + { + Close( handle ) ; + return 0 ; + } + + // gestion m‚moire + + time = TimerRef ; + + ptr = (UBYTE*)(header) + sizeof(T_HQR_HEADER) ; + ptrbloc = (T_HQR_BLOC*)(ptr) ; + + // check if enough space for bloc or index + + while( (size > header->FreeSize) OR (header->NbIndex >= header->MaxIndex) ) + { + // delete oldest bloc + oldest = 0 ; + testtime = 0 ; + + for( n=0; nNbIndex; n++ ) + { + if( (time-ptrbloc[n].Time) > testtime ) + { + testtime = time - ptrbloc[oldest].Time ; + oldest = n ; + } + } + // m‚thode violente (attendre r‚flexions d‚sagr‚ables...) + WaveStopOne( ptrbloc[oldest].Index ) ; + + HQR_Del_Bloc_Sample( header, oldest ) ; + } + + // space size ok, load it + + ptr = header->Buffer + header->MaxSize - header->FreeSize ; + +// Load_HQR( header->Name, ptr, index ) ; + + switch( lzssheader.CompressMethod ) + { + case 0: /* Stored */ + Read( handle, ptr, lzssheader.SizeFile ) ; + break ; + + case 1: /* LZS */ + ptrdecomp = (UBYTE*)ptr + lzssheader.SizeFile - lzssheader.CompressedSizeFile + RECOVER_AREA ; + Read( handle, ptrdecomp, lzssheader.CompressedSizeFile ) ; + Expand( ptrdecomp, ptr, lzssheader.SizeFile ) ; + break ; + + default: + Close( handle ) ; + return 0 ; /* UnKnown version */ + } + + Close( handle ) ; + + HQR_Flag = TRUE ; // indicate loaded + + ptrbloc[header->NbIndex].Index = index ; + ptrbloc[header->NbIndex].Time = TimerRef ; + ptrbloc[header->NbIndex].Offset = header->MaxSize - header->FreeSize ; + ptrbloc[header->NbIndex].Size = size ; + + header->NbIndex++ ; + header->FreeSize -= size ; + +// RestoreTimer() ; + + return ptr ; + } +} + diff --git a/LIB386/LIB_SYS/HQ_R_M.C b/LIB386/LIB_SYS/HQ_R_M.C new file mode 100644 index 0000000..f738006 --- /dev/null +++ b/LIB386/LIB_SYS/HQ_R_M.C @@ -0,0 +1,72 @@ +#include +#include +#include + +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" + +#define RECOVER_AREA 500 + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +typedef struct { ULONG SizeFile ; + ULONG CompressedSizeFile ; + WORD CompressMethod ; /* 0 stored */ + /* 1 LZS */ + } T_HEADER ; + +void Expand( void *ptrsourcecomp, void *ptrblocdest, ULONG sizefile ) ; + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +LONG HQRM_Load( UBYTE *name, UWORD index, void **ptrptr ) +{ + LONG handle ; + UWORD nbbloc ; + ULONG buffer ; + ULONG seekindex ; +// UBYTE *ptrbloc ; + UBYTE *ptrdecomp ; + T_HEADER header ; + + handle = OpenRead( name ) ; + if( !handle ) return FALSE ; + + Read( handle, &buffer, 4L ) ; + nbbloc = (UWORD)(buffer / 4L) ; + + if( index >= nbbloc ) return FALSE ; + + Seek( handle, index * 4L, SEEK_START ) ; + Read( handle, &seekindex, 4L ) ; + + Seek( handle, seekindex, SEEK_START ) ; + Read( handle, &header, sizeof( header ) ) ; + + if( !HQM_Alloc( header.SizeFile, ptrptr ) ) // il y a deja 500 de plus + { + return FALSE ; + } + + switch( header.CompressMethod ) + { + case 0: /* Stored */ + Read( handle, *ptrptr, header.SizeFile ) ; + break ; + + case 1: /* LZS */ + ptrdecomp = (UBYTE*)(*ptrptr) + header.SizeFile - header.CompressedSizeFile + RECOVER_AREA ; + Read( handle, ptrdecomp, header.CompressedSizeFile ) ; + Expand( ptrdecomp, *ptrptr, header.SizeFile ) ; + break ; + + default: + HQM_Free( *ptrptr ) ; + return FALSE ; /* UnKnown version */ + } + + Close( handle ) ; + + return header.SizeFile ; +} + diff --git a/LIB386/LIB_SYS/KEYB.C b/LIB386/LIB_SYS/KEYB.C new file mode 100644 index 0000000..2aeca43 --- /dev/null +++ b/LIB386/LIB_SYS/KEYB.C @@ -0,0 +1,124 @@ + +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_svga\lib_svga.h" +#include +#include +#include +#include + +extern UWORD Old_PM09_Sel ; +extern ULONG Old_PM09_Off ; + +#ifdef KEYB_REAL +UWORD Old_RM09_Seg ; +ULONG Old_RM09_Off ; +#endif + +extern void __interrupt NewIntPM09(void) ; + +//#define int15 + +/*-------------------------------------------------------------------------*/ +void InitKeyboard() +{ + union REGS r ; + struct SREGS sr ; + void far *fh ; + void *ptrealproc ; + +/*----- Save Old Protected Mode Vector 09 ------*/ +#ifdef int15 + r.x.eax = 0x3515 ;/* Function 35h, for Int 9 */ +#else + r.x.eax = 0x3509 ;/* Function 35h, for Int 9 */ +#endif + sr.ds = sr.es = 0 ;/* Security (kill the cat) */ + int386x( 0x21, &r, &r, &sr ) ;/* Call Int 21 */ + Old_PM09_Sel = (UWORD)sr.es ;/* ES:EBX=Old Interrupt 09 */ + Old_PM09_Off = r.x.ebx ; + +#ifdef KEYB_REAL +/*----- Save Old Real Mode Vector 09 -----------*/ + r.x.eax = 0x0200 ;/* DPMI Get Real Mode Vect */ + r.h.bl = 0x09 ;/* Interrupt Number */ + int386( 0x31, &r, &r ) ;/* Invoke DPMI */ + Old_RM09_Seg = (UWORD)r.x.ecx ;/* CX:DX=Old Interrupt 09 */ + Old_RM09_Off = (UWORD)r.x.edx ; + +/*----- Create 128 Byte under First Meg for NewIntRM09 in Real Mode ----*/ + ptrealproc = DosMalloc(512) ;/* Prog will be copied here*/ + memcpy( ptrealproc, (void*)NewIntRM09, 512 ) ; +#endif +/*----- Install New Protected Vector 09 --------*/ +#ifdef int15 + r.x.eax = 0x2515 ;/* Function 25h for int 09 */ +#else + r.x.eax = 0x2509 ;/* Function 25h for int 09 */ +#endif + fh = (void far*)NewIntPM09 ;/* Get far Pointer */ + r.x.edx = FP_OFF( fh ) ;/* Get Offset */ + sr.ds = FP_SEG( fh ) ;/* Get Segment */ + sr.es = 0 ;/* Security ( ... ) */ + int386x( 0x21, &r, &r, &sr ) ;/* Invoke DPMI */ + +#ifdef KEYB_REAL +/*----- Install New Real Vector 09 -------------*/ + r.x.eax = 0x0201 ;/* DPMI Set Real Mode Vect */ + r.h.bl = 0x09 ;/* Interrupt Number */ + r.x.ecx = GetRealSeg(ptrealproc);/* Get Segment of ptreal */ + r.x.edx = GetRealOff(ptrealproc);/* Get Offset of ptreal */ + int386( 0x31, &r, &r ) ; +#endif +} +/*-------------------------------------------------------------------------*/ +void ClearKeyboard() +{ + union REGS r ; + struct SREGS sr ; + +/*----- Restore Old Protected Vector 09 --------*/ +#ifdef int15 + r.x.eax = 0x2515 ;/* Set Vector Interupt PM09*/ +#else + r.x.eax = 0x2509 ;/* Set Vector Interupt PM09*/ +#endif + r.x.edx = Old_PM09_Off ;/* Adr Old Interrupt 09 */ + sr.ds = Old_PM09_Sel ; + sr.es = 0 ;/* ... (...) */ + int386x( 0x21, &r, &r, &sr ) ;/* Invoke int 21 */ + +#ifdef KEYB_REAL +/*----- Restore Old Real Vector 08--------------*/ + r.x.eax = 0x0201 ;/* DPMI Set Real Mode Vect */ + r.h.bl = 0x09 ;/* Interrupt Number 09 */ + r.x.ecx = (ULONG)Old_RM09_Seg ;/* Old Segment Interrupt */ + r.x.edx = (ULONG)Old_RM09_Off ;/* Old Offset Interrupt */ + int386( 0x31, &r, &r ) ;/* Invoke DPMI */ +#endif +} +/*-------------------------------------------------------------------------*/ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LIB386/LIB_SYS/KEYBOARD.ASM b/LIB386/LIB_SYS/KEYBOARD.ASM new file mode 100644 index 0000000..d38cf88 --- /dev/null +++ b/LIB386/LIB_SYS/KEYBOARD.ASM @@ -0,0 +1,436 @@ +;/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +; Û Üß Ûßßßß Û Üß ÛßßÛ ÛßßßÛ ÛßßßÛ ÛßßßÛ ÛßßßÜ +; ÛÛßÜ ÛÛßß ÛÛß ÛÛßßÛ ÛÛ Û ÛÛßßÛ ÛÛßÛß ÛÛ Û +; ßß ß ßßßßß ßß ßßßßß ßßßßß ßß ß ßß ß ßßßß +; *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +; +;/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + .386p + + .model SMALL, SYSCALL + +KB_DATA equ 60H + +;int15 equ 1 + +;/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + .DATA + + public NoLanguage Key + public NoLanguage _Key + public NoLanguage Joy + public NoLanguage Fire + public NoLanguage FuncKey + public NoLanguage AsciiMode + public NoLanguage Old_PM09_Off + public NoLanguage Old_PM09_Sel + + +NoAscii db 0 + +Key dw 00 +_Key dw 00 +FuncKey dw 00 +Joy dw 00 +Fire dw 00 +AsciiMode dw 00 + + +NB_SPECIAL_KEY equ 29 + +TabSpecialKey db 72 ; UP + db 80 ; DOWN + db 75 ; LEFT + db 77 ; RIGHT Joy + db 71 ; UP LEFT + db 73 ; UP RIGHT + db 81 ; DOWN RIGHT + db 79 ; DOWN LEFT + + db 57 ; space + db 28 ; return + db 29 ; CTRL + db 56 ; ALT + db 83 ; SUPPR + db 42 ; SHIFT_LEFT + db 54 ; SHIFT_RIGHT + + db 59 ; F1 + db 60 ; F2 + db 61 ; F3 + db 62 ; F4 + db 63 ; F5 + db 64 ; F6 + db 65 ; F7 + db 66 ; F8 + db 67 ; F9 + db 68 ; F10 + db 87 ; F11 + db 88 ; F12 + + db 42 + db 0 ; ??? code cursor + +comment @ + +TabSpecialCount db 00 ; UP + db 00 ; DOWN + db 00 ; LEFT + db 00 ; RIGHT Joy + db 00 ; UP LEFT + db 00 ; UP RIGHT + db 00 ; DOWN RIGHT + db 00 ; DOWN LEFT + + db 00 ; space + db 00 ; return + db 00 ; CTRL + db 00 ; ALT + db 00 ; SUPPR + db 00 ; SHIFT_LEFT + db 00 ; SHIFT_RIGHT + + db 00 ; F1 + db 00 ; F2 + db 00 ; F3 + db 00 ; F4 + db 00 ; F5 + db 00 ; F6 + db 00 ; F7 + db 00 ; F8 + db 00 ; F9 + db 00 ; F10 + db 00 ; F11 + db 00 ; F12 + + db 00 + db 00 ; ??? code cursor + + @ + +TabSpecialFunc db 0,1 ; J_UP + db 0,2 ; J_DOWN + db 0,4 ; J_LEFT + db 0,8 ; J_RIGHT Joy + db 0,1+4 ; UP LEFT + db 0,1+8 ; UP RIGHT + db 0,2+8 ; DOWN RIGHT + db 0,2+4 ; DOWN LEFT + + db 1,1 ; Fire + db 1,2 ; return + db 1,4 ; ctrl + db 1,8 ; alt + db 1,16 ; suppr ; attention cas 224 + db 1,32 ; shift left + db 1,32 ; shift right + + db 2,1 ; F1 + db 2,2 ; F2 + db 2,4 ; F3 + db 2,8 ; F4 + db 2,16 ; F5 + db 2,32 ; F6 + db 2,64 ; F7 + db 2,128 ; F8 + db 3,1 ; F9 + db 3,2 ; F10 + db 3,4 ; F11 + db 3,8 ; F12 + + db 255,0 ; oublie 42 + db 255,0 ; oublie 0 + +Old_Int_09 dd 0000 + +Old_PM09_Off dd 0000 +Old_PM09_Sel dw 00 + + +FlagExtendScan db 0 + +;/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + + .CODE + + public NoLanguage NewIntPM09 + public NoLanguage GetAscii + public NoLanguage ClearAsciiBuffer + +;/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +NewIntPM09 PROC FAR + + push eax + push ecx + push ebx + push edi + push ds + push es + +ifdef int15 + jnc back15 + + cmp ah, 4Fh + jne back15 +endif + + cld + + mov cx, DGROUP + mov ds, cx + mov es, cx + +comment @ +; peut etre une bonne idee mais plante le clavier sur plein de pc + mov al, 0ADh + out 64h, al ; disable keyboard + @ + +ifdef int15 + + mov ah, al + +else + +once_again: + in al, KB_DATA + mov ah, al + +endif + + mov byte ptr[_Key], ah + + cmp al, 224 ; code etendu + jz doextend + + and al, 127 ; al scancode + + cmp al, 2Ah ; shift ? + jnz noshift + + cmp [FlagExtendScan], 1 ; extended shift say goodbye + jz exit + +noshift: mov ecx, NB_SPECIAL_KEY + mov edi, offset TabSpecialKey + repne scasb + jnz nospecial + + mov ebx, NB_SPECIAL_KEY-1 + sub ebx, ecx + +comment @ + lea ecx, [TabSpecialCount + ebx] + mov al, [ecx] + + test ah, 128 + jnz decr + + inc al + jmp ok1 + +decr: or al, al + jz keyup + dec al + jz keyup + +keydown: and ah, 127 + jmp ok1 +keyup: or ah, 128 +ok1: mov [ecx], al + mov al, ah + @ + + mov bx, word ptr[ TabSpecialFunc + ebx*2 ] + +ni0: or bl, bl + jnz ni1 + + ; code touche pour Joy CODE BL 0 : Joy + + test ah, 128 + jnz relache0 + + or byte ptr[ Joy ], bh + jmp exit + +relache0: not bh + and byte ptr[ Joy ], bh + jmp exit + +doextend: mov [FlagExtendScan], 1 + jmp exit2 + + ; code touche pour Fire CODE BL 1 : Fire + +ni1: dec bl + jnz ni2 + + test ah, 128 + jnz relache1 + + or byte ptr[ Fire ], bh + + cmp byte ptr[ Fire ], 4 + 8 + 16 ; ctrl alt suppr + jnz exit + +reset: mov eax, 472h + mov word ptr[eax], 1234h ; don'check mem but reset it + + push 0FFFFh + push 00000h + retf + +relache1: not bh + and byte ptr[ Fire ], bh + jmp short exit + +ni2: dec bl + jnz ni3 + + ; code touche pour FuncKey CODE BL 2 : FuncKey 1-8 + + test ah, 128 + jnz relache2 + + or byte ptr[ FuncKey ], bh + jmp short nospecial + +relache2: not bh + and byte ptr[ FuncKey ], bh + jmp short nospecial + +ni3: dec bl + jnz ni4 + + ; code touche pour FuncKey CODE BL 3 : FuncKey 9-12 + + test ah, 128 + jnz relache3 + + or byte ptr[ FuncKey+1 ], bh + jmp short nospecial + +relache3: not bh + and byte ptr[ FuncKey+1 ],bh + jmp short nospecial + +ni4: jmp short exit ; CODE BL 255 : oublie token + +nospecial: test ah, 128 + jnz relache5 + + mov byte ptr[ Key ], al + jmp short exit + +relache5: mov byte ptr[ Key ], 0 + +exit: mov [FlagExtendScan], 0 + +exit2: + +ifdef int15 + + cmp byte ptr[ AsciiMode ], 0 + jne back15 + + and dword ptr[esp+8*4], 0FFFFFFFEh +back15: + pop es + pop ds + pop edi + pop ebx + pop ecx + pop eax + iret + +else + + in al, 64h + test al, 1 + jnz once_again + + cmp byte ptr[ AsciiMode ], 0 + jnz ascii + +;-------------- + mov al, 20H + out 20H, al + +comment @ +; peut etre une bonne idee mais plante le clavier sur plein de pc + mov al, 0AEh + out 64h, al ; enable keyboard + @ + pop es + pop ds + pop edi + pop ebx + pop ecx + pop eax + iretd + +ascii: +comment @ +; peut etre une bonne idee mais plante le clavier sur plein de pc + mov al, 0AEh + out 64h, al ; enable keyboard + @ + xor eax, eax + mov ecx, [Old_PM09_Off] + mov ax, [Old_PM09_Sel] + + xchg ecx, [esp+4*4] + xchg eax, [esp+5*4] + + pop es + pop ds + pop edi + pop ebx + retf + +endif + +NewIntPM09 endp + +;/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +GetAscii proc + + mov ah, 1 + int 16h + jz nokey + mov ah, 0 + int 16h + ret + +nokey: xor ax, ax + ret + +GetAscii endp + +;/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +ClearAsciiBuffer proc + +cab0: mov ah, 1 + int 16h + jz nokey1 + mov ah, 0 + int 16h + jmp cab0 +nokey1: ret + +ClearAsciiBuffer endp + +;/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +; The + End + + + + + + + diff --git a/LIB386/LIB_SYS/LIB_SYS.ASH b/LIB386/LIB_SYS/LIB_SYS.ASH new file mode 100644 index 0000000..4f623a9 --- /dev/null +++ b/LIB386/LIB_SYS/LIB_SYS.ASH @@ -0,0 +1,23 @@ + +;----------------------------------------------------------------------------- +; LIB_SYS.ASH +;----------------------------------------------------------------------------- + + extrn NoLanguage TimerRef:DWORD + extrn NoLanguage NbFramePerSecond:WORD + extrn NoLanguage WaitNbTicks:WORD + extrn NoLanguage CmptFrame:WORD + extrn NoLanguage Cmpt_18:WORD + +;TIMERREF equ 0 +;NBFRAMEPERSECOND equ 4 +;WAITNBTICKS equ 6 +;CMPTFRAME equ 8 +;CMPT_18 equ 10 + +;----------------------------------------------------------------------------- + + + + + diff --git a/LIB386/LIB_SYS/LIB_SYS.H b/LIB386/LIB_SYS/LIB_SYS.H new file mode 100644 index 0000000..1612714 --- /dev/null +++ b/LIB386/LIB_SYS/LIB_SYS.H @@ -0,0 +1,346 @@ +/*--------------------------------------------------------------------------*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û Üß Ûßßßß Û Üß ÛßßÛ ÛßßßÛ ÛßßßÛ ÛßßßÛ ÛßßßÜ + ÛÛßÜ ÛÛßß ÛÛß ÛÛßßÛ ÛÛ Û ÛÛßßÛ ÛÛßÛß ÛÛ Û + ßß ß ßßßßß ßß ßßßßß ßßßßß ßß ß ßß ß ßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +#ifdef WATCOM9 + #pragma library ("f:\projet\lib386\lib_sys\lb9_sys.lib"); +#else + #pragma library ("f:\projet\lib386\lib_sys\lib_sys.lib"); +#endif + +#include "f:\projet\lib386\lib_sys\dll.h" + +extern volatile UWORD Key ; /* scan code keyboard */ + +#define K_ESC 1 + +#define K_F1 59 +#define K_F2 60 +#define K_F3 61 +#define K_F4 62 +#define K_F5 63 +#define K_F6 64 +#define K_F7 65 +#define K_F8 66 +#define K_F9 67 +#define K_F10 68 +#define K_F11 87 +#define K_F12 88 + + +#define K_PLUS 78 +#define K_MOINS 74 +#define K_BACKSPACE 14 +#define K_TAB 15 +#define K_NUMLOCK 69 + +#define K_A 16 +#define K_B 48 +#define K_C 46 +#define K_D 32 +#define K_E 18 +#define K_F 33 +#define K_G 34 +#define K_H 35 +#define K_I 23 +#define K_J 36 +#define K_K 37 +#define K_L 38 +#define K_M 39 +#define K_N 49 +#define K_O 24 +#define K_P 25 +#define K_Q 30 +#define K_R 19 +#define K_S 31 +#define K_T 20 +#define K_U 22 +#define K_V 47 +#define K_W 44 +#define K_X 45 +#define K_Y 21 +#define K_Z 17 + +#define K_1 2 +#define K_2 3 +#define K_3 4 +#define K_4 5 +#define K_5 6 +#define K_6 7 +#define K_7 8 +#define K_8 9 +#define K_9 10 +#define K_10 11 + +extern volatile UWORD FuncKey ; /* mask bit touches fonctions */ + +#define FK_F1 1 +#define FK_F2 2 +#define FK_F3 4 +#define FK_F4 8 +#define FK_F5 16 +#define FK_F6 32 +#define FK_F7 64 +#define FK_F8 128 +#define FK_F9 256 +#define FK_F10 512 +#define FK_F11 1024 +#define FK_F12 2048 + +extern volatile UWORD Joy ; /* emulation cursor key */ + +#define J_UP 1 +#define J_DOWN 2 +#define J_LEFT 4 +#define J_RIGHT 8 + +extern volatile UWORD Fire ; /* emulation touches fire */ + +#define F_SPACE 1 +#define F_RETURN 2 +#define F_CTRL 4 +#define F_ALT 8 +#define F_SUPPR 16 +#define F_SHIFT 32 + +void InitKeyboard(void) ; /* init de Key Joy Fire */ +void ClearKeyboard(void) ; + +UWORD GetAscii(void) ; /* retourne code ascii dos */ +void ClearAsciiBuffer(void) ; /* vide buffer dos */ + +extern UWORD AsciiMode ; /* TRUE/FALSE gestion buffer keyboard */ + +#define A_F1 0x3B00 +#define A_F2 0x3C00 +#define A_F3 0x3D00 +#define A_F4 0x3E00 +#define A_F5 0x3F00 +#define A_F6 0x4000 +#define A_F7 0x4100 +#define A_F8 0x4200 +#define A_F9 0x4300 +#define A_F10 0x4400 + +#define A_ESC 0x011B + +#define A_UP 0x4800 +#define A_DOWN 0x5000 +#define A_LEFT 0x4B00 +#define A_RIGHT 0x4D00 + +#define A_HOME 0x4700 +#define A_END 0x4F00 +#define A_PGUP 0x4900 +#define A_PGDN 0x5100 + +#define A_SPACE 0x3920 +#define A_RETURN 0x1C0D + +#define A_N_PLUS 0x4E2B +#define A_N_MOINS 0x4A2D + +#define A_BACKSPACE 0x0E08 +#define A_SUPPR 0x5300 + +#define A_CARRE 0x29FD + +#define A_1 0x226 +#define A_2 0x382 +#define A_3 0x422 +#define A_4 0x527 +#define A_5 0x628 +#define A_6 0x77D +#define A_7 0x88A +#define A_8 0x95F +#define A_9 0xA87 +#define A_0 0xB85 + +#define A_A 0x1061 +#define A_B 0x3062 +#define A_C 0x2e63 +#define A_D 0x2064 +#define A_E 0x1265 +#define A_F 0x2166 +#define A_G 0x2267 +#define A_H 0x2368 +#define A_I 0x1769 +#define A_J 0x246a +#define A_K 0x256b +#define A_L 0x266c +#define A_M 0x276d +#define A_N 0x316e +#define A_O 0x186f +#define A_P 0x1970 +#define A_Q 0x1e71 +#define A_R 0x1372 +#define A_S 0x1f73 +#define A_T 0x1474 +#define A_U 0x1675 +#define A_V 0x2f76 +#define A_W 0x2c77 +#define A_X 0x2d78 +#define A_Y 0x1579 +#define A_Z 0x117a +#define FALSE 0 +#define TRUE 1 + +#define SEEK_START 0 +#define SEEK_CURRENT 1 +#define SEEK_END 2 + +#define Rnd(n) (rand()%n) + +#define GetRealSeg(p) ((((ULONG)(p)) >> 4) & 0xFFFF ) +#define GetRealOff(p) (((ULONG)(p)) & 0xF ) + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* FILES.C */ +void AddExt( char *name, char *ext ) ; +LONG OpenRead( char *name ) ; +LONG OpenWrite( char *name ) ; +LONG OpenReadWrite( char *name ) ; +ULONG Read( LONG handle, void *buffer, ULONG lenread ) ; +ULONG Write( LONG handle, void *buffer, ULONG lenwrite ) ; +void Close( LONG handle ) ; +LONG Seek( LONG handle, LONG position,LONG mode ) ; +LONG Delete( char *name ) ; +ULONG FileSize( char *name ) ; +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* LOADSAVE.C */ +ULONG Load( char *name, void *buffer ) ; +ULONG Save( char *name,void *buffer, ULONG size ) ; +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* MALLOC.C */ + +extern LONG ModeTraceMalloc ; + +void *DosMalloc( LONG size, ULONG *handle ) ; +void DosFree( ULONG handle ) ; + +void *SmartMalloc( LONG lenalloc ) ; +void *Malloc( LONG lenalloc ) ; + +void Free( void *buffer ) ; +void *Mshrink( void *buffer, ULONG taille ) ; +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* LOADMALL.C */ + +extern ULONG LoadMallocFileSize ; + +void *LoadMalloc( char *name ) ; +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* TIMER.C */ + +/* +extern UBYTE *BufferGlobal ; + +#define TimerRef (*((ULONG *)(BufferGlobal+0))) +#define NbFramePerSecond (*((UWORD *)(BufferGlobal+4))) +#define WaitNbTicks (*((UWORD *)(BufferGlobal+6))) +#define CmptFrame (*((UWORD *)(BufferGlobal+8))) +#define Cmpt_18 (*((UWORD *)(BufferGlobal+10))) +*/ + +extern volatile ULONG TimerSystem ; +extern volatile ULONG TimerRef ; +extern UWORD NbFramePerSecond ; +extern UWORD WaitNbTicks ; +extern UWORD CmptFrame ; +extern UWORD Cmpt_18 ; + +void SetTimer( WORD divisor ) ; +WORD GetTimer() ; + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* DEF_FILE.C */ + +LONG Def_WriteString( UBYTE *deffic, UBYTE *indentificateur, UBYTE *string ) ; +LONG Def_WriteValue( UBYTE *deffic, UBYTE *indentificateur, LONG value ) ; + +UBYTE *Def_ReadString( UBYTE *deffic, UBYTE *indentificateur ) ; +LONG Def_ReadValue( UBYTE *deffic, UBYTE *indentificateur ) ; +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* BUFFER_A.ASM */ +void RazMem( void *pt, ULONG size ) ; +void MovMem( void *pt0, void *pt1, ULONG size ) ; +LONG CompBuf( void *pt0, void *pt1, ULONG size ) ; + +char *Itoa( LONG value ) ; + + + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* HQ_Ressource */ + +extern WORD HQR_Flag ; // flag de load done par HQR_Get + + +typedef struct { char Name[128] ; + ULONG MaxSize ; + ULONG FreeSize ; + UWORD MaxIndex ; + UWORD NbIndex ; + UBYTE *Buffer ; } T_HQR_HEADER ; + +typedef struct { UWORD Index ; + ULONG Offset ; + ULONG Size ; + ULONG Time ; } T_HQR_BLOC ; + +void *LoadMalloc_HQR( UBYTE *name, UWORD index ) ; +ULONG Load_HQR( UBYTE *name, void *ptrdest, UWORD index ) ; +ULONG Size_HQR( char *name, UWORD index ) ; + +T_HQR_HEADER *HQR_Init_Ressource( char *hqrname, + ULONG maxsize, + UWORD maxindex ) ; + +LONG HQR_Change_Ressource( T_HQR_HEADER *header, char *newhqrname ) ; +void HQR_Reset_Ressource( T_HQR_HEADER *header ) ; +void HQR_Free_Ressource( T_HQR_HEADER *header ) ; + +void *HQR_Get( T_HQR_HEADER *header, UWORD index ) ; +void *HQR_GetSample( T_HQR_HEADER *header, UWORD index ) ; + +UWORD HQR_Del_Bloc( T_HQR_HEADER *header, WORD index ) ; +UWORD HQR_Del_Bloc_Sample( T_HQR_HEADER *header, WORD index ) ; +T_HQR_BLOC *HQR_GiveIndex( UWORD index, UWORD nbindex, void *ptrlist ) ; + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* HQ_MEM.C */ + +extern ULONG Size_HQM_Memory ; +extern ULONG Size_HQM_Free ; + +LONG HQM_Init_Memory( ULONG size ) ; +void HQM_Clear_Memory() ; +LONG HQM_Alloc( ULONG size, void **ptr ) ; +void HQM_Free_All() ; +void HQM_Free( void *ptr ) ; +LONG HQM_Check() ; +void HQM_Shrink_Last( void *ptr, ULONG newsize ) ; + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* HQ_R_M.C */ + +LONG HQRM_Load( UBYTE *name, UWORD index, void **ptrptr ) ; + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* ADELINE.C */ + +#define INIT_SVGA 1 +#define INIT_WAVE 2 +#define INIT_MIDI 4 +#define INIT_MIXER 8 +#define INIT_VESA 16 +#define INIT_MCGA 32 + +void InitAdelineSystem( char *name, LONG inits ) ; +void ClearAdelineSystem() ; + +extern char PathConfigFile[] ; +extern char MidiFM ; \ No newline at end of file diff --git a/LIB386/LIB_SYS/LIB_SYS.MAK b/LIB386/LIB_SYS/LIB_SYS.MAK new file mode 100644 index 0000000..f729534 --- /dev/null +++ b/LIB386/LIB_SYS/LIB_SYS.MAK @@ -0,0 +1,39 @@ +# name the compiler +!ifdef %HOME +CC = c:\compil\watcom10\binb\wcc386 +WL = c:\compil\watcom10\binb\wlib +!else +CC = f:\compil\watcom10\binb\wcc386 +WL = f:\compil\watcom10\binb\wlib +!endif + +ASMFLAGS = /m2 /mx /z /p /q /t /jMASM51 /jQUIRKS +CFLAGS = /oaxet /zp2 /s /4s /x /c /l=dos4g /zq +LIBFLAGS = /c /q /b /n + +OBJETS1 = FILES.obj MALLOC.obj LOADMALL.obj LOADSAVE.obj DEF_FILE.obj +OBJETS2 = System.obj Timer_a.obj Timer.obj Buffer_A.obj DIVERS.obj +OBJETS3 = Keyb.obj Keyboard.obj Expand.obj HQ_ress.obj hqr.obj +OBJETS4 = DllLoad.obj Adeline.obj HQ_mem.obj HQ_r_m.obj + +LIB = LIB_SYS + +$(LIB).LIB: $(OBJETS1) $(OBJETS2) $(OBJETS3) $(OBJETS4) + + @echo $(OBJETS1) > clibmak.rsp + @echo $(OBJETS2) >> clibmak.rsp + @echo $(OBJETS3) >> clibmak.rsp + @echo $(OBJETS4) >> clibmak.rsp + + @$(WL) $(LIBFLAGS) $(LIB) @clibmak.rsp + @del clibmak.rsp + @prntitre G "$(LIB)" + +.asm.obj: + @PRNTITRE M "$*.ASM" + @TASM $(ASMFLAGS) $*; + +.c.obj: + @PRNTITRE M "$*.C" + @$( $(CFLAGS) $* + diff --git a/LIB386/LIB_SYS/LOADMALL.C b/LIB386/LIB_SYS/LOADMALL.C new file mode 100644 index 0000000..77d2e7b --- /dev/null +++ b/LIB386/LIB_SYS/LOADMALL.C @@ -0,0 +1,48 @@ +/* + MALLOC (c) Adeline 1993 + + Functions: + + - Malloc + - Free + - Mshrink +*/ + +#include +#include +#include +#include +#include + +#include "adeline.h" +#include "lib_sys.h" + +ULONG LoadMallocFileSize ; + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +void *LoadMalloc( char *name ) +{ + LONG handle ; + ULONG sizer ; + void *pt ; + + LoadMallocFileSize = FileSize( name ) ; + if ( !LoadMallocFileSize ) return( 0 ) ; + + pt = Malloc( LoadMallocFileSize ) ; + if ( pt == 0 ) return( 0 ) ; + + handle = OpenRead( name ) ; + if ( !handle) return( 0 ) ; + + sizer = Read( handle, pt, LoadMallocFileSize ); + if ( sizer != LoadMallocFileSize ) + { + Close( handle ) ; + return( 0 ); + } + + Close( handle ) ; + return( pt ) ; +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ diff --git a/LIB386/LIB_SYS/LOADSAVE.C b/LIB386/LIB_SYS/LOADSAVE.C new file mode 100644 index 0000000..a9ad6d5 --- /dev/null +++ b/LIB386/LIB_SYS/LOADSAVE.C @@ -0,0 +1,58 @@ +/* + LOADSAVE (c) Adeline 1993 + + Functions: + + - Load + - Save +*/ + +#include +#include +#include +#include +#include + +#include "adeline.h" +#include "lib_sys.h" + + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +ULONG Load( char *name, void *buffer ) +{ + LONG handle ; + ULONG size ; + + size = FileSize( name ) ; + if ( !size ) return(0L) ; + + handle = OpenRead( name ) ; + if ( handle ) + { + size = Read( handle, buffer, size ) ; + Close( handle ) ; + return( size ) ; + } + return( 0L ); +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +ULONG Save( char *name, void *buffer, ULONG size ) +{ + LONG handle ; + ULONG nbwrote ; + + handle = OpenWrite( name ) ; + if( handle ) + { + nbwrote = Write( handle, buffer, size ) ; + Close( handle ) ; + if( nbwrote != size ) return FALSE ; + return TRUE ; + } + return FALSE ; +} + + + + diff --git a/LIB386/LIB_SYS/MAKEFILE b/LIB386/LIB_SYS/MAKEFILE new file mode 100644 index 0000000..bd7835d --- /dev/null +++ b/LIB386/LIB_SYS/MAKEFILE @@ -0,0 +1,60 @@ +# name the compiler +!ifdef %HOME +!ifeq WATCOM9 yes +CC = c:\compil\watcom\bin\wcc386p +WL = c:\compil\watcom\binb\wlib +!else +CC = c:\compil\watcom10\binb\wcc386 +WL = c:\compil\watcom10\binb\wlib +!endif +!else +!ifeq WATCOM9 yes +CC = f:\compil\watcom\bin\wcc386p +WL = f:\compil\watcom\binb\wlib +!else +CC = f:\compil\watcom10\binb\wcc386 +WL = f:\compil\watcom10\binb\wlib +!endif +!endif + +ASM = ml + +!ifeq WATCOM9 yes +CFLAGS = /oeaxt /zp2 /4s /zq /s /DWATCOM9 +!else +CFLAGS = /oeaxt /zp2 /5s /zq /s +!endif +LFLAGS = /c /q /b /n +#AFLAGS = /m2 /mx /z /p /q /t /jMASM51 /jQUIRKS +AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=; + +.SILENT + +OBJETS1 = FILES.obj MALLOC.obj LOADMALL.obj LOADSAVE.obj DEF_FILE.obj +OBJETS2 = System.obj Timer_a.obj Timer.obj Buffer_A.obj DIVERS.obj +OBJETS3 = Keyb.obj Keyboard.obj Expand.obj HQ_ress.obj hqr.obj +OBJETS4 = DllLoad.obj Adeline.obj HQ_mem.obj HQ_r_m.obj Files_A.obj + +!ifeq WATCOM9 yes +LIB = LB9_SYS +!else +LIB = LIB_SYS +!endif + +$(LIB).LIB: $(OBJETS1) $(OBJETS2) $(OBJETS3) $(OBJETS4) + @echo $(OBJETS1) > clibmak.rsp + @echo $(OBJETS2) >> clibmak.rsp + @echo $(OBJETS3) >> clibmak.rsp + @echo $(OBJETS4) >> clibmak.rsp + + @$(WL) $(LFLAGS) $(LIB) @clibmak.rsp + @del clibmak.rsp + @prntitre G "$(LIB)" + +.c.obj : + PRNTITRE M "$*.C" + $(CC) $^& $(CFLAGS) + +.asm.obj : + PRNTITRE M "$*.ASM" + $(ASM) $(AFLAGS) $^&.ASM diff --git a/LIB386/LIB_SYS/MALLOC.C b/LIB386/LIB_SYS/MALLOC.C new file mode 100644 index 0000000..ec6ac95 --- /dev/null +++ b/LIB386/LIB_SYS/MALLOC.C @@ -0,0 +1,326 @@ +/* + MALLOC (c) Adeline 1993 + + Functions: + + - Malloc + - Free + - Mshrink +*/ + +#include +#include +#include +#include +#include +#include + +#include "adeline.h" +#include "lib_sys.h" + +struct meminfo { + unsigned LargestBlockAvail; + unsigned MaxUnlockedPage; + unsigned LargestLockablePage; + unsigned LinAddrSpace; + unsigned NumFreePagesAvail; + unsigned NumPhysicalPagesFree; + unsigned TotalPhysicalPages; + unsigned FreeLinAddrSpace; + unsigned SizeOfPageFile; + unsigned Reserved[3]; +} MemInfo; + +#define DPMI_INT 0x31 + + +// #define DEBUG_MALLOC 1 + +#ifdef DEBUG_MALLOC +LONG ModeTraceMalloc = FALSE ; +#endif + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* Special, Allocate Memory Under First Meg */ +void *DosMalloc( LONG size, ULONG *handle ) +{ + +/* union REGS r ; + + r.x.eax = 0x0100 ;// Function allocate Dos Memory + r.x.ebx =(size+15)>>4 ;// Number off Paragraphs Requested + int386( 0x31, &r, &r ) ;// Invoke DPMI + if( r.x.cflag ) + return(0) ;// Failed + return( (void*)((r.x.eax & 0xFFFF) << 4 )) ;// Ok, Take this! +*/ + union REGS r ; + ULONG strat ; + ULONG addr ; + +#ifdef jhjkhjkhjlk + r.x.eax = 0x5800 ; + int386( 0x21, &r, &r ) ; + strat = r.x.eax ;/* Save DOS alloc strategie */ + + r.x.eax = 0x5801 ; + r.x.ebx = 1 ;/* Low mem, best fit */ + int386( 0x21, &r, &r ) ;/* Set alloc strategie */ +#endif + r.x.eax = 0x0100 ;/* Function allocate Dos Memory */ + if (size == -1) + r.x.ebx = -1 ;/*Number off Paragraphs Requested */ + else + r.x.ebx =(size+15)>>4;/*Number off Paragraphs Requested */ + int386( 0x31, &r, &r ) ;/* Invoke DPMI */ + + addr = 0 ; + if (size == -1) + { + if( r.x.cflag ) + addr = (r.x.ebx & 0xFFFF) << 4 ; + } + else + { + if( !r.x.cflag ) + { + if (handle) *handle = r.x.edx & 0xFFFF;/* DPMI selector*/ + addr = (r.x.eax & 0xFFFF) << 4;/* Ok, Take this! */ + } + } + +#ifdef hjhkjhlhjk + r.x.eax = 0x5801 ; + r.x.ebx = strat ;/* Odl startegie */ + int386( 0x21, &r, &r ) ;/* Set alloc strategie */ +#endif + return((void *)addr) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* Special, Free Allocated Memory Under First Meg */ +void DosFree( ULONG handle ) +{ + union REGS r ; + + r.x.eax = 0x0101 ;/* Function allocate Dos Memory */ + r.x.edx = handle ;/* DPMI Selector */ + int386( 0x31, &r, &r ) ;/* Invoke DPMI */ +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#ifdef DEBUG_MALLOC + +LONG mymalloc( LONG lenalloc, void **memptr ) +{ + union REGS regs ; + struct SREGS sregs ; + UBYTE *ptr ; + + lenalloc+=16; + regs.x.eax = 0x00000501 ; + regs.x.ebx = lenalloc>>16 ; + regs.x.ecx = lenalloc & 0xFFFF ; + sregs.es = 0 ; + sregs.ds = 0 ; + sregs.fs = 0 ; + sregs.gs = 0 ; + int386x( DPMI_INT, ®s, ®s, &sregs ) ; + + if( regs.x.cflag ) + { + *memptr = NULL ; + return regs.x.eax ; + } + + ptr=(UBYTE *)((regs.x.ebx<<16) | (regs.x.ecx & 0xFFFF)); + + *(WORD*)(ptr+0)=(WORD)regs.x.esi ; + *(WORD*)(ptr+2)=(WORD)regs.x.edi ; + + *memptr=(void*)(ptr+16) ; + return 0 ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +LONG myfree( void *ptr ) +{ + union REGS regs ; + struct SREGS sregs ; + UBYTE *ptrh ; + + ptrh = ptr ; + ptrh -= 16 ; + + regs.x.esi = *(WORD*)(ptrh+0) ; + regs.x.edi = *(WORD*)(ptrh+2) ; + regs.x.eax = 0x00000502 ; + sregs.es = 0 ; + sregs.ds = 0 ; + sregs.fs = 0 ; + sregs.gs = 0 ; + int386x( DPMI_INT, ®s, ®s, &sregs ) ; + + return regs.x.cflag ? regs.x.eax : 0 ; +} + +#endif + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +void *SmartMalloc( LONG lenalloc ) +{ + union REGS r ; + ULONG strat ; + ULONG addr ; + +#ifdef jhghhlk + r.x.eax = 0x5800 ; + int386( 0x21, &r, &r ) ; + strat = r.x.eax ;/* Save DOS alloc strategie */ + + r.x.eax = 0x5801 ; + r.x.ebx = 0x81 ;/* UMB first then Low mem, best fit*/ + int386( 0x21, &r, &r ) ;/* Set alloc strategie */ +#endif + r.x.eax = 0x0100 ;/* Function allocate Dos Memory */ + r.x.ebx =(lenalloc+15)>>4;/*Number off Paragraphs Requested */ + int386( 0x31, &r, &r ) ;/* Invoke DPMI */ + + if( !r.x.cflag ) + addr = (r.x.eax & 0xFFFF) << 4;/* Ok, Take this! */ + else + addr = (ULONG)malloc( lenalloc ); +#ifdef hjgkgjk + r.x.eax = 0x5801 ; + r.x.ebx = strat ;/* Odl startegie */ + int386( 0x21, &r, &r ) ;/* Set alloc strategie */ +#endif + return((void *)addr) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +void *Malloc( LONG lenalloc ) +{ + union REGS regs ; + struct SREGS sregs ; + void *ptr ; + FILE *fh ; + ULONG size, error ; + + if ( lenalloc != -1 ) + { +#ifdef DEBUG_MALLOC + if( ModeTraceMalloc ) + { + fh = fopen( "c:\\malloc.lst","a+t" ) ; + if( fh != NULL ) + { + regs.x.eax = 0x00000500 ; + sregs.es = FP_SEG( &MemInfo ) ; + sregs.ds = 0 ; + regs.x.edi = FP_OFF( &MemInfo ) ; + int386x( DPMI_INT, ®s, ®s, &sregs ) ; + size = MemInfo.LargestBlockAvail ; + + fprintf( fh, "Mem: %d\n", size ) ; + } + + error = mymalloc(lenalloc, &ptr) ; +// ptr = malloc( lenalloc ) ; + + if( fh != NULL ) + { + fprintf( fh, "Malloc: %d bytes at %X to %X\n", lenalloc, ptr, (LONG)ptr+lenalloc ) ; + if( error ) + fprintf( fh, "Error: %X\n", error ) ; + + regs.x.eax = 0x00000500 ; + sregs.es = FP_SEG( &MemInfo ) ; + sregs.ds = 0 ; + regs.x.edi = FP_OFF( &MemInfo ) ; + int386x( DPMI_INT, ®s, ®s, &sregs ) ; + size = MemInfo.LargestBlockAvail ; + + fprintf( fh, "Mem: %d\n", size ) ; + + fclose( fh ) ; + } + } + else +#endif + { + ptr = malloc( lenalloc ) ; + } + + return( ptr ) ; + + } + regs.x.eax = 0x00000500 ; + sregs.es = FP_SEG( &MemInfo ) ; + sregs.ds = 0 ; + regs.x.edi = FP_OFF( &MemInfo ) ; + + int386x( DPMI_INT, ®s, ®s, &sregs ) ; + + return( (void *)MemInfo.LargestBlockAvail ) ; +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +void Free( void *buffer ) +{ + union REGS regs ; + struct SREGS sregs ; + void *ptr ; + FILE *fh ; + ULONG size, error ; + +#ifdef DEBUG_MALLOC + if( ModeTraceMalloc ) + { + fh = fopen( "c:\\malloc.lst","a+t" ) ; + if( fh != NULL ) + { + regs.x.eax = 0x00000500 ; + sregs.es = FP_SEG( &MemInfo ) ; + sregs.ds = 0 ; + regs.x.edi = FP_OFF( &MemInfo ) ; + int386x( DPMI_INT, ®s, ®s, &sregs ) ; + size = MemInfo.LargestBlockAvail ; + + fprintf( fh, "Mem: %d\n", size ) ; + } + + error = myfree( buffer ) ; +// free( buffer ) ; + + if( fh != NULL ) + { + fprintf( fh, "Free: %X\n", buffer ) ; + if( error ) + fprintf( fh, "Error: %X\n", error ) ; + + regs.x.eax = 0x00000500 ; + sregs.es = FP_SEG( &MemInfo ) ; + sregs.ds = 0 ; + regs.x.edi = FP_OFF( &MemInfo ) ; + int386x( DPMI_INT, ®s, ®s, &sregs ) ; + size = MemInfo.LargestBlockAvail ; + + fprintf( fh, "Mem: %d\n", size ) ; + + fclose( fh ) ; + } + } + else +#endif + { + free( buffer ) ; + } +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +void *Mshrink( void *buffer, ULONG taille ) +{ + return _expand( buffer, (size_t)taille ) ; +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ diff --git a/LIB386/LIB_SYS/SYSTEM.C b/LIB386/LIB_SYS/SYSTEM.C new file mode 100644 index 0000000..7a562a6 --- /dev/null +++ b/LIB386/LIB_SYS/SYSTEM.C @@ -0,0 +1,60 @@ +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_svga\lib_svga.h" + +#include +#include +#include +#include + + +//extern void __interrupt NewInt24(void) ; + + +/*--------------------------------------------------------------------------*/ +void InitSystem() +{ +// union REGS r ; +// struct SREGS sr ; +// void far *fh ; + +/*----- Install New Protected Vector 24 --------*/ +// r.x.eax = 0x2524 ;/* Function 25h for int 24 */ +// fh = (void far*)NewInt24 ;/* Get far Pointer */ +// r.x.edx = FP_OFF( fh ) ;/* Get Offset */ +// sr.ds = FP_SEG( fh ) ;/* Get Segment */ +// sr.es = 0 ;/* Security ( ... ) */ +// int386x( 0x21, &r, &r, &sr ) ;/* Invoke DOS 21h */ +} +/*--------------------------------------------------------------------------*/ +void ClearSystem() +{ +// Inutile de restorer l'int 24h +} +/*--------------------------------------------------------------------------*/ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LIB386/LIB_SYS/TIMER.C b/LIB386/LIB_SYS/TIMER.C new file mode 100644 index 0000000..992cffb --- /dev/null +++ b/LIB386/LIB_SYS/TIMER.C @@ -0,0 +1,112 @@ +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_svga\lib_svga.h" +#include +#include +#include +#include + + +#define DIVISOR 23864 /* 1193180 / 50 */ +#define FREQUENCE 50 /* 1193180 / 23864 */ + + +#define OLD_DIVISOR 0xFFFF + + +extern void __interrupt NewIntPM08(void) ; + +ULONG Old_PM08_Off ; +UWORD Old_PM08_Sel ; + +//UWORD Old_RM08_Off ; +//UWORD Old_RM08_Seg ; + + +//UWORD Old_RMF2_Off ; +//UWORD Old_RMF2_Seg ; + + +/*-------------------------------------------------------------------------*/ + +void InitTimer() +{ + union REGS r ; + struct SREGS sr ; + void far *fh ; + +/*----- Save Old Real Mode Vector F2 -----------*/ +// r.x.eax = 0x0200 ;/* DPMI Get Real Mode Vect */ +// r.h.bl = 0xF2 ;/* Interrupt Number */ +// int386( 0x31, &r, &r ) ;/* Invoke DPMI */ +// Old_RMF2_Seg = (UWORD)r.x.ecx ;/* CX:DX=Old Interrupt F2 */ +// Old_RMF2_Off = (UWORD)r.x.edx ; + +/*----- Save Old Real Mode Vector 08 -----------*/ +// r.x.eax = 0x0200 ;/* DPMI Get Real Mode Vect */ +// r.h.bl = 0x08 ;/* Interrupt Number */ +// int386( 0x31, &r, &r ) ;/* Invoke DPMI */ +// Old_RM08_Seg = (UWORD)r.x.ecx ;/* CX:DX=Old Interrupt 08 */ +// Old_RM08_Off = (UWORD)r.x.edx ; + +/*----- Install it as New Real Vector F2 -------*/ +// r.x.eax = 0x0201 ;/* DPMI Set Real Mode Vect */ +// r.h.bl = 0xF2 ;/* Interrupt Number */ +// int386( 0x31, &r, &r ) ; + +/*----- Save Old Protected Mode Vector 08 ------*/ + r.x.eax = 0x3508 ;/* Function 35h, for Int 08*/ + sr.ds = sr.es = 0 ;/* Security (kill the cat) */ + int386x( 0x21, &r, &r, &sr ) ;/* Call Int 21 */ + Old_PM08_Sel = (UWORD)sr.es ;/* ES:EBX=Old Interrupt 08 */ + Old_PM08_Off = r.x.ebx ; + +/*----- Install New Protected Vector 08 --------*/ + r.x.eax = 0x2508 ;/* Function 25h for int 08 */ + fh = (void far*)NewIntPM08 ;/* Get far Pointer */ + r.x.edx = FP_OFF( fh ) ;/* Get Offset */ + sr.ds = FP_SEG( fh ) ;/* Get Segment */ + sr.es = 0 ;/* Security ( ... ) */ + int386x( 0x21, &r, &r, &sr ) ;/* Invoke DPMI */ + +/*----- It's Ok, Now I can accelerate Timer 08 */ + + SetTimer( DIVISOR ) ; +} + +/*-------------------------------------------------------------------------*/ + +void ClearTimer() +{ + union REGS r ; + struct SREGS sr ; + +/*----- Ok, it's finish, stop running... -------*/ + + SetTimer( OLD_DIVISOR ) ; + +/*----- Restore Old Protected Vector 08 --------*/ + r.x.eax = 0x2508 ;/* Set Vector Interupt PM08*/ + r.x.edx = Old_PM08_Off ;/* Adr Old Interrupt 08 */ + sr.ds = Old_PM08_Sel ; + sr.es = 0 ;/* ... (...) */ + int386x( 0x21, &r, &r, &sr ) ;/* Invoke int 21 */ + +/*----- Restore Old Real Mode Vector 08 -----------*/ +// r.x.eax = 0x0200 ;/* DPMI Get Real Mode Vect */ +// r.h.bl = 0xF2 ;/* Interrupt Number */ +// int386( 0x31, &r, &r ) ;/* Invoke DPMI */ + +// r.x.eax = 0x0201 ;/* DPMI Set Real Mode Vect */ +// r.h.bl = 0x08 ;/* Interrupt Number */ +// int386( 0x31, &r, &r ) ; + +/*----- Restore Old Real Mode Vector F2 -----------*/ +// r.x.eax = 0x0201 ;/* DPMI Get Real Mode Vect */ +// r.h.bl = 0xF2 ;/* Interrupt Number */ +// r.x.ecx = Old_RMF2_Seg ;/* CX:DX=Old Interrupt F2 */ +// r.x.edx = Old_RMF2_Off ; +// int386( 0x31, &r, &r ) ;/* Invoke DPMI */ +} + +/*-------------------------------------------------------------------------*/ diff --git a/LIB386/LIB_SYS/TIMER_A.ASM b/LIB386/LIB_SYS/TIMER_A.ASM new file mode 100644 index 0000000..bd71a03 --- /dev/null +++ b/LIB386/LIB_SYS/TIMER_A.ASM @@ -0,0 +1,179 @@ +;---------------------------------------------------------------------------- +; TIMER_A.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386p + + .model SMALL, SYSCALL + + .data + +DIVISOR equ 23864 ; 1193180 (Base Freq) / 50 +FREQUENCE equ 50 ; 1193180 (Base Freq) / 23864 + + public NoLanguage TimerSystem + public NoLanguage TimerRef + public NoLanguage NbFramePerSecond + public NoLanguage WaitNbTicks + public NoLanguage CmptFrame + public NoLanguage Cmpt_18 + +TimerRef dd 0000 +NbFramePerSecond dw 00 +WaitNbTicks dw 1 +CmptFrame dw 00 +Cmpt_18 dw 00 +TimerSystem dd 0000 + + .data + + extrn NoLanguage Old_PM08_Sel:WORD + extrn NoLanguage Old_PM08_Off:DWORD + + .code + + public NoLanguage SetTimer + public NoLanguage NewIntPM08 + public NoLanguage NewProc08 + +;---------------------------------------------------------------------------- +SetTimer proc ,\ + counter:DWORD + + cli + + mov ecx, counter + mov al, 36h + out 43h, al + mov al, cl + out 40h, al + mov al, ch + out 40h, al + + sti + ret +SetTimer endp + +;---------------------------------------------------------------------------- +comment @ + +NewIntPM08 proc far + + push eax + push ds + + mov ax, DGROUP + mov ds, ax + + inc dword ptr [TimerSystem] + inc dword ptr [TimerRef] + + dec word ptr [WaitNbTicks] + jnz short noevaluate + + mov word ptr [WaitNbTicks], FREQUENCE + + mov ax, word ptr [CmptFrame] + mov word ptr [NbFramePerSecond], ax + + mov word ptr [CmptFrame], 0 +noevaluate: + add word ptr [Cmpt_18], DIVISOR + jc short oldint08 + + mov al, 20h + out 20h, al + + pop ds + pop eax + iretd +oldint08: + pop ds + pop eax + + int 0F2h ; old int08 + + iretd + +NewIntPM08 endp + + @ + +;---------------------------------------------------------------------------- +NewIntPM08 proc far + + push eax + push ecx + push ds + + mov ax, DGROUP + mov ds, ax + + inc dword ptr [TimerSystem] + inc dword ptr [TimerRef] + + dec word ptr [WaitNbTicks] + jnz short noevaluate + + mov word ptr [WaitNbTicks], FREQUENCE + + mov ax, word ptr [CmptFrame] + mov word ptr [NbFramePerSecond], ax + + mov word ptr [CmptFrame], 0 +noevaluate: + add word ptr [Cmpt_18], DIVISOR + jc short oldint08 + + mov al, 20h + out 20h, al + + pop ds + pop ecx + pop eax + iretd +oldint08: + xor eax, eax + mov ecx, [Old_PM08_Off] + mov ax, [Old_PM08_Sel] + + xchg ecx, [esp+4] + xchg eax, [esp+8] + + pop ds + retf + +NewIntPM08 endp + +;---------------------------------------------------------------------------- + +NewProc08 proc + + push eax + push ds + + mov ax, DGROUP + mov ds, ax + + inc dword ptr [TimerRef] + inc dword ptr [TimerSystem] + + dec word ptr [WaitNbTicks] + jnz short noevaluate + + mov word ptr [WaitNbTicks], FREQUENCE + mov ax, word ptr [CmptFrame] + mov word ptr [NbFramePerSecond], ax + mov word ptr [CmptFrame], 0 +noevaluate: + + pop ds + pop eax + + ret + +NewProc08 endp + +;---------------------------------------------------------------------------- +; The + End \ No newline at end of file diff --git a/LIB386/LIB_SYS/WINBOX.H b/LIB386/LIB_SYS/WINBOX.H new file mode 100644 index 0000000..956056d --- /dev/null +++ b/LIB386/LIB_SYS/WINBOX.H @@ -0,0 +1,69 @@ + +#define SELECT_NO_FLAG 0 +#define SELECT_SHOW_EXT 1 + +#define NO_FLAG 0 +#define FLAG_PUSHED 0x0001 +#define FLAG_RED 0x0002 +#define FLAG_NO_PUSH 0x0004 +#define FLAG_CENTRE 0x0100 +#define FLAG_CONTOUR 0x0200 + +typedef struct { WORD X1 ; /* size/pos pixel box */ + WORD Y1 ; + WORD X2 ; + WORD Y2 ; + + WORD Handle ; /* info retourn‚e si != -1 */ + WORD Flags ; /* texte centr‚... */ + + UBYTE *PtrString ; + + } T_CLICK_BOX ; + + +typedef struct { WORD NbBox ; + WORD MaxBox ; + WORD LastClicked ; + WORD LastSelected ; + T_CLICK_BOX *PtrMallocList ; + + WORD Largeur ; /* en caractere */ + WORD Hauteur ; + + WORD X1 ; + WORD Y1 ; + WORD X2 ; + WORD Y2 ; + + WORD Flags ; + + } T_MENU ; + + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +WORD OpenMenu( T_MENU *ptrmenu, + WORD largeur, WORD hauteur, + WORD maxbox ) ; + +WORD AddButton( T_MENU *ptrmenu, + WORD handle, + WORD x1, WORD y1, + WORD largeur, WORD hauteur, + WORD flags, + UBYTE *ptrstring ) ; + +void DrawMenu( T_MENU *ptrmenu, WORD x1, WORD y1 ) ; + +WORD GereMenu( T_MENU *ptrmenu, WORD flagwaitclick ) ; + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void ChangeButtonFlags( T_MENU *ptrmenu, WORD handle, WORD flags, WORD flagaff ) ; +WORD GetButtonFlags( T_MENU *ptrmenu, WORD handle ) ; + +void ChangeButtonString( T_MENU *ptrmenu, WORD handle, UBYTE *string, WORD flagaff ) ; +UBYTE* GetButtonString( T_MENU *ptrmenu, WORD handle ) ; + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..277abbd --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# Little Big Adventure 1 - Engine source code +Little Big Adventure (aka Relentless: Twinsen's Adventure) is an action-adventure game, developed by Adeline Software International in 1994. + +We are releasing this code with preservation in mind, as this piece of work was exceptional for the time and we believe it can be a valuable source of education. + +The engine uses Assembly code and was originally compiled with non-open source libraries which have been excluded from the project. + +### Licence +This source code is licensed under the [GNU General Public License](https://github.com/2point21/lba1-classic/blob/main/LICENSE). + +Please note this license only applies to **Little Big Adventure 1** engine source code. **Little Big Adventure 1** game assets (art, models, textures, audio, etc.) are not open-source and therefore aren't redistributable. + +## How can I contribute ? +This project is the historic version of the open source project and meant to be kept as it was developed in 1994 ! Pull requests to this repository are **not** accepted. + +You can contribute to the community project here : https://github.com/2point21/lba1-classic-community + +You can also help to build the official documentation here : https://github.com/2point21/lba-classic-doc + +## Links: +**Official Website:** https://www.2point21.com/games/little-big-adventure-twinsen + +**Discord:** https://discord.gg/wQse6WB6 + +**Docs:** https://lba-classic-doc.readthedocs.io/ + +## Buy the game: + [[GoG]](https://www.gog.com/game/little_big_adventure) [[Steam]](https://store.steampowered.com/app/397330/Little_Big_Adventure__Enhanced_Edition/?l=french) + +## Original Dev Team +Direction: Frédérick Raynal + +Programming: Frédérick Raynal / Laurent Salmeron / Serge Plagnol / Frantz Cournil / Olivier Lhermite + +3D Objects & Animation: Didier Chanfray + +Scenery Graphics: Yaël Barroz / Jean-Marc Torroella + +Story & Design: Frédérick Raynal / Yaël Barroz / Jean-Jacques Poncet / Didier Chanfray / Laurent Salmeron + +Dialogs: Jean-Jacques Poncet + +Story Coding: Sébastien Viannay / Frantz Cournil / Jean-Jacques Poncet + +Video Sequences: Frédéric Taquet / Didier Chanfray + +Music & Sound FX: Philippe Vachey + +Testing: Nicolas Viannay / Alexis Madinier / Lionel Chaze / Vijay Maharaj + +Quality Control: Emmanuel Oualid + +## Copyright +The intellectual property is currently owned by [2.21]. Copyright [2.21] + +Originaly developed by Adeline Software International in 1994 diff --git a/SOURCES/ADFLI_A.ASM b/SOURCES/ADFLI_A.ASM new file mode 100644 index 0000000..2672b3d --- /dev/null +++ b/SOURCES/ADFLI_A.ASM @@ -0,0 +1,244 @@ +;---------------------------------------------------------------------------- +; +;' ADFLI.ASM 386 +;' (c) Adeline 1994 +; +;---------------------------------------------------------------------------- + .386P + .model SMALL, SYSCALL +;---------------------------------------------------------------------------- + .data +;---------------------------------------------------------------------------- + include \projet\lib386\lib_svga\svga.ash +;---------------------------------------------------------------------------- + .code + + public NoLanguage DrawFrame + public NoLanguage UpdateFrame + public NoLanguage BlackFrame + public NoLanguage CopyFrame + +; public NoLanguage SetPal +; public NoLanguage CpyPal + +;---------------------------------------------------------------------------- +DrawFrame proc uses esi edi ebx,\ + ptframe:DWORD, deltax:DWORD, deltay:DWORD + + mov esi, ptframe + mov edi, Log + mov edx, edi + xor eax, eax +NewLine: + lodsb ; Nb Block + or al, al + je EndLine + mov bl, al +SameLine: + lodsb + test al, al + js short CopyPix ; + mov ecx, eax +;---------------------- + lodsb + rep stosb +;---------------------- + dec bl + jne short SameLine + jmp short EndLine +CopyPix: +;---------------------- + neg al + mov ecx, eax + shr ecx, 2 + rep movsd + mov cl, al + and cl, 11b + rep movsb +;---------------------- + dec bl + jne short SameLine + +EndLine: + add edx, [deltax] + mov edi, edx + dec dword ptr [deltay] + jne short NewLine +EndDrawFrame: + ret +DrawFrame endp +;---------------------------------------------------------------------------- +UpdateFrame proc uses esi edi ebx,\ + ptframe:DWORD, deltax:DWORD + + local cptline :WORD + + mov esi, ptframe + mov edi, Log + xor eax, eax + + lodsw + mov edx, deltax + imul edx + add edi, eax + mov edx, edi + lodsw + mov [cptline], ax + xor eax, eax +NewLine: + lodsb ; Nb Block + or al, al + je EndLine + mov bl, al +SameLine: + lodsb + add edi, eax + + lodsb + test al, al + js short RepeatPix ; + + mov ecx, eax + shr ecx, 2 + rep movsd + mov cl, al + and cl, 11b + rep movsb + + dec bl + jne short SameLine + jmp short EndLine +RepeatPix: + neg al + mov ecx, eax + lodsb + rep stosb + + dec bl + jne short SameLine +EndLine: + add edx, deltax + mov edi, edx + dec word ptr [cptline] + jne short NewLine +EndUpdateFrame: + ret +UpdateFrame endp +;---------------------------------------------------------------------------- +BlackFrame proc uses edi + + mov edi, Log + xor eax, eax + mov edx, 200 +NextLine: + mov ecx, 320/4 + rep stosd + add edi, 320 + dec edx + jne NextLine + ret +BlackFrame endp +;---------------------------------------------------------------------------- +CopyFrame proc uses esi edi,\ + ptsrc:DWORD + + mov esi, ptsrc + mov edi, Log + mov edx, 200 +NextLine: + mov ecx, 320/4 + rep movsd + add edi, 320 + dec edx + jne NextLine + + ret +CopyFrame endp +;---------------------------------------------------------------------------- + +comment # +SetPal proc uses esi edi ebx,\ + ptsrc:DWORD + + mov esi, ptsrc + xor edi, edi + + lodsw + mov bx, ax + test bx, bx + je EndSetPal +Again: + xor eax, eax + lodsb + add di, ax + lodsb + mov ecx, eax + or ecx, ecx + jne PlusLoin + mov ecx, 256 +PlusLoin: + mov dx, 3C8h + mov ax, di + out dx, al + inc di + inc dx + lodsb + out dx, al + lodsb + out dx, al + lodsb + out dx, al + loop PlusLoin + + dec bx + jne Again +EndSetPal: + ret +SetPal endp + +;---------------------------------------------------------------------------- +CpyPal proc uses esi edi ebx,\ + ptsrc:DWORD, ptdst:DWORD + + mov esi, ptsrc + mov edi, ptdst + lodsw + mov bx, ax + test bx, bx + je EndCpyPal +Again: + xor eax, eax + lodsb + add di, ax + add di, ax + add di, ax + lodsb + or al, al + jne PlusLoin + mov eax, 256 +PlusLoin: + mov ecx, eax + add ecx, eax + add ecx, eax +mfp0: lodsb + shl al, 2 + stosb + loop mfp0 +; rep movsb + dec bx + jne Again +EndCpyPal: + ret +CpyPal endp + + # + +;---------------------------------------------------------------------------- +; The + End + + + + + + diff --git a/SOURCES/AMBIANCE.C b/SOURCES/AMBIANCE.C new file mode 100644 index 0000000..aebc149 --- /dev/null +++ b/SOURCES/AMBIANCE.C @@ -0,0 +1,504 @@ + +#include "c_extern.h" +#include "Balance.h" + +#ifdef CDROM +extern LONG FlagVoiceCD ; +LONG CurrentMusicCD = -1 ; +ULONG EndMusicCD = 0 ; +#endif + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßßÛ ÛÜ ÜÛ ÛßßÛ Û ÛßßßÛ ÛÛÜ Û Ûßßßß Ûßßßß + ÛÛßßÛ ÛÛß Û ÛÛßßÛ ÛÛ ÛÛßßÛ ÛÛßÛÛ ÛÛ ÛÛßß + ßß ß ßß ß ßßßßß ßß ßß ß ßß ß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +ULONG HQ_MixSample( WORD numsample, WORD decalage, WORD repeat, WORD volleft, WORD volright ) +{ + UBYTE string[256] ; + ULONG retvalue ; + UBYTE *ptr ; + + retvalue = -1 ; + + if( !SamplesEnable ) return -1 ; + + if ( numsample == -1 ) return -1 ;/* Loran ( Come from GereSceneMenu)*/ + + ptr = HQR_GetSample( HQR_Samples, numsample ) ; + if( ptr ) + { + retvalue = + WavePlay( numsample, decalage, repeat, 0, volleft, volright, ptr ) ; + } + + return retvalue ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +void HQ_StopSample() +{ + WaveStop() ; +} +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +void HQ_StopOneSample(WORD num) +{ + WaveStopOne( num ) ; +} +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +WORD GiveBalance( WORD xp, WORD yp, LONG volume, ULONG *volleft, ULONG *volright ) +{ + LONG balance ; + int flag = 0 ; + + if( (yp > 240+480) + OR (yp < -240) ) return FALSE ; + + // baisse volume vers le haut … partir de Y<0 jusqu'a -480 + if( yp < 0 ) + { + volume = RegleTrois32( 0, volume, 240, 240+yp ) ; + flag = 1 ; + } + // baisse volume vers le bas … partir de Y>479 jusqu'a 480+480 + if( yp > 479 ) + { + volume = RegleTrois32( 0, volume, 240, 240+480-yp ) ; + flag = 1 ; + } + + // gere attenuation du volume sur le cote gauche + // utilise le volume eventuellement deja ajuste sur Y + if( (xp >= -320) AND (xp < 0) ) + { + *volleft = RegleTrois32( 0, (volume*100)/128, 320, xp+320 ) ; +// *volleft = RegleTrois32( 0, volume, 320, xp+320 ) ; + *volright = 0 ; + return TRUE ; + } + + // gere attenuation du volume sur le cote droit + if( (xp >= 640) AND (xp < 640+320) ) + { + *volleft = 0 ; + *volright = RegleTrois32( 0, (volume*100)/128, 320, 320+640-xp ) ; +// *volright = RegleTrois32( 0, volume, 320, 320+640-xp ) ; + return TRUE ; + } + + // sinon gere la balance gauche/droite sur l'ecran + // l'eventuelle attenuation du volume sur Y est toujour la + if( (xp >= 0) AND (xp < 640) ) + { + if (flag) volume = (volume*100)/128; + + balance = RegleTrois32( 0,256, 640, xp ) ; + Balance( balance, volume, + volleft, volright ) ; + return TRUE ; + } + + return FALSE ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void HQ_3D_MixSample( WORD numsample, WORD decalage, WORD repeat, + WORD x, WORD y, WORD z ) +{ + ULONG volleft, volright, longhandle ; + LONG balance ; + + if( !SamplesEnable ) return ; + + ProjettePoint( x-WorldXCube, + y-WorldYCube, + z-WorldZCube ) ; + + if( GiveBalance( Xp, Yp, 128, &volleft, &volright ) ) + { + longhandle = HQ_MixSample( numsample, decalage, repeat, + volleft, volright ) ; + + WaveGiveInfo0( longhandle, (LONG)Xp<<16 + Yp ) ; + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void HQ_ChangeBalanceSamples( WORD oldxporg, WORD oldyporg ) +{ + LONG n, nbsamp ; + T_WAVE *ptrlist ; + LONG deltaxp, newxp ; + LONG deltayp, newyp ; + ULONG volleft, volright ; + + return ; +#ifdef TANTPIS + if( !SamplesEnable ) return ; + + nbsamp = WaveGetSnap( &ptrlist ) ; + + deltaxp = XpOrgw - oldxporg ; + deltaxp = YpOrgw - oldyporg ; + + for( n=0; nLongHandle != 123456 ) // son ambiance + { + newxp = ptrlist->Info0>>16 - deltaxp ; + newyp = ptrlist->Info0&0xFFFF - deltayp ; + + if( GiveBalance( newxp, newyp, 128, &volleft, &volright ) ) + { + WaveChangeVolume( ptrlist->LongHandle, volleft, volright ) ; + WaveGiveInfo0( ptrlist->LongHandle, newxp<<16 + newyp ) ; + } + else + { + // coupe ce sample longhandle plus tard + WaveStopOne( ptrlist->LongHandle & 0xFFFF ) ; + } + } + ptrlist++ ; + } +#endif +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void GereAmbiance() +{ + LONG sample ; + LONG numsample ; + LONG n ; + LONG decal ; + LONG repeat ; + ULONG longhandle ; + + if( !SamplesEnable ) return ; + + if( TimerRef >= TimerNextAmbiance ) + { + sample = Rnd( 4 ) ; /* 0 1 2 3 */ + + for( n=0; n<4; n++ ) + { + if( !(SamplePlayed & (1<=0; n-=2 ) + { + Vsync() ; + FadePal( 0,0,0, ptrpal, n ) ; + } + } + FlagBlackPal = TRUE ; +} + +void WhiteFade() +{ + UBYTE workpal[768] ; + LONG n,m ; + + for( n=0; n<=255; n++ ) + { + memset( workpal, n, 768 ) ; + Vsync() ; + Palette( workpal ) ; + } +} + +void FadeWhiteToPal( UBYTE *ptrpal ) +{ + LONG n ; + + for( n=0; n<=100; n+=1 ) + { + Vsync() ; + FadePal( 255,255,255, ptrpal, n ) ; + } +} + +void FadeToPal( UBYTE *ptrpal ) +{ + LONG n ; + + for( n=0; n<=100; n+=2 ) + { + Vsync() ; + FadePal( 0,0,0, ptrpal, n ) ; + } + FlagBlackPal = FALSE ; +} + +void SetBlackPal() +{ + LONG n ; + + for( n=0; n<256; n++ ) + { + PalOne( n, 0,0,0 ) ; + } + FlagBlackPal = TRUE ; +} + +void FadePalToPal( UBYTE *ptrpal, UBYTE *ptrpal1 ) +{ + UBYTE workpal[768] ; + LONG n,m ; + + for( m=0; m<=100; m++ ) + { + for( n=0; n<256; n++ ) + { + workpal[n*3+0] = RegleTrois32( ptrpal[n*3+0], ptrpal1[n*3+0], 100, m ) ; + workpal[n*3+1] = RegleTrois32( ptrpal[n*3+1], ptrpal1[n*3+1], 100, m ) ; + workpal[n*3+2] = RegleTrois32( ptrpal[n*3+2], ptrpal1[n*3+2], 100, m ) ; + } + Vsync() ; + Palette( workpal ) ; + } +} + +void FadeToRed( UBYTE *ptrpal ) +{ + LONG n ; + + for( n=100; n>=0; n-=2 ) + { + Vsync() ; + FadePal( 255,0,0, ptrpal, n ) ; + } +} + +void FadeRedToPal( UBYTE *ptrpal ) +{ + LONG n ; + + for( n=0; n<=100; n+=2 ) + { + Vsync() ; + FadePal( 255,0,0, ptrpal, n ) ; + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛÜ ÜÛ Û ÛßßßÜ Û + ÛÛß Û ÛÛ ÛÛ Û ÛÛ + ßß ß ßß ßßßß ßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#ifdef CDROM + +void StopMusicCD( void ) +{ + StopCDR() ; + CurrentMusicCD = -1 ; +} + +#endif + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void FadeMusicMidi( ULONG t ) +{ + FadeMidiDown( t ) ; + NumXmi = -1 ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void StopMusicMidi() +{ + StopMidi() ; + NumXmi = -1 ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void PlayMusic( WORD num ) +{ + if( num == -1 ) + { +#ifdef CDROM + StopMusicCD() ; +#endif + StopMusicMidi() ; + return ; + } + +#ifdef CDROM + + if( FlagVoiceCD // voix sur CD music fm + OR (num < 1) + OR (num > 9) ) // ou jingle que FM + { + PlayMidiFile( num ) ; + } + else // voix sur HD ponheur + { + PlayCdTrack( num ) ; // 1ere track = 2 + } + +#else + PlayMidiFile( num ) ; +#endif +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void PlayMidiFile( WORD num ) +{ + if( !Midi_Driver_Enable ) return ;// hum si on peut + +#ifdef CDROM + StopMusicCD() ; +#endif + + if( (num != NumXmi) + OR (!IsMidiPlaying()) ) + { + StopMusicMidi() ; +// HQR_Reset_Ressource( HQR_Midi ) ; + PtrXmi = HQR_Get( HQR_Midi, num ) ; + NumXmi = num ; + PlayMidi( PtrXmi ) ; + VolumeMidi( 100 ) ; + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#ifdef CDROM +LONG GetMusicCD() +{ + if ( TimerSystem > EndMusicCD) CurrentMusicCD = -1 ; + return CurrentMusicCD ; +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void PlayCdTrack( WORD num ) +{ + LONG t ; + + SaveTimer() ; + + FadeMusicMidi( 1 ) ; + NumXmi = -1 ; + + if (num != GetMusicCD()) + { + StopMusicCD() ; + EndMusicCD = ( GetLengthTrackCDR( num+1 ) * 50 ) / 75 + 50 ; + PlayTrackCDR( num + 1 ) ; + EndMusicCD += TimerSystem ; + CurrentMusicCD = num ; + } + + RestoreTimer() ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void PlayAllMusic( WORD num ) +{ + if( Midi_Driver_Enable ) + { + if( (num != NumXmi) + OR (!IsMidiPlaying()) ) + { + StopMusicMidi() ; + PtrXmi = HQR_Get( HQR_Midi, num ) ; + NumXmi = num ; + PlayMidi( PtrXmi ) ; + VolumeMidi( 100 ) ; + } + } + +// if( (n=num+1) != GetMusicCDR() ) + if( num != GetMusicCD() ) + { + StopMusicCD() ; + EndMusicCD = ( GetLengthTrackCDR( num+1 ) * 50 ) / 75 + 50 ; + PlayTrackCDR( num+1 ) ; + EndMusicCD += TimerSystem ; + CurrentMusicCD = num ; + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#endif diff --git a/SOURCES/AMBIANCE.DEF b/SOURCES/AMBIANCE.DEF new file mode 100644 index 0000000..e4abbd2 --- /dev/null +++ b/SOURCES/AMBIANCE.DEF @@ -0,0 +1,20 @@ +extern unsigned long HQ_MixSample(short ,short ,short ,short ,short ); +extern void HQ_StopSample(void); +extern void HQ_StopOneSample(short ); +extern short GiveBalance(short ,short ,long ,unsigned long *,unsigned long *); +extern void HQ_3D_MixSample(short ,short ,short ,short ,short ,short ); +extern void HQ_ChangeBalanceSamples(short ,short ); +extern void GereAmbiance(void); +extern void FadePal(unsigned char ,unsigned char ,unsigned char ,unsigned char *,short ); +extern void FadeToBlack(unsigned char *); +extern void WhiteFade(void); +extern void FadeWhiteToPal(unsigned char *); +extern void FadeToPal(unsigned char *); +extern void SetBlackPal(void); +extern void FadePalToPal(unsigned char *,unsigned char *); +extern void FadeToRed(unsigned char *); +extern void FadeRedToPal(unsigned char *); +extern void FadeMusicMidi(unsigned long ); +extern void StopMusicMidi(void); +extern void PlayMusic(short ); +extern void PlayMidiFile(short ); diff --git a/SOURCES/BALANCE.ASM b/SOURCES/BALANCE.ASM new file mode 100644 index 0000000..d9160ba --- /dev/null +++ b/SOURCES/BALANCE.ASM @@ -0,0 +1,72 @@ + + .386p + jumps + + .model SMALL, SYSCALL + + .data + + extrn NoLanguage P_SinTab:WORD + + .code + + public NoLanguage Balance + public NoLanguage BalanceWord + + +Balance PROC uses ebx,\ + bal:DWORD, vol:DWORD, volleft:DWORD, volright:DWORD + + mov eax, bal + shl eax, 1 + mov edx, vol + + xor ecx, ecx + mov cx, word ptr[P_SinTab + eax] + imul ecx, edx + shr ecx, 14 + + mov ebx, volright + mov dword ptr[ebx], ecx + + xor ecx, ecx + mov cx, word ptr[P_SinTab + 512 + eax] + imul ecx, edx + shr ecx, 14 + + mov ebx, volleft + mov dword ptr[ebx], ecx + + ret + +Balance ENDP + + +BalanceWord PROC uses ebx,\ + bal:DWORD, vol:DWORD, volleft:DWORD, volright:DWORD + + mov eax, bal + shl eax, 1 + mov edx, vol + + xor ecx, ecx + mov cx, word ptr[P_SinTab + eax] + imul ecx, edx + shr ecx, 14 + + mov ebx, volright + mov word ptr[ebx], cx + + xor ecx, ecx + mov cx, word ptr[P_SinTab + 512 + eax] + imul ecx, edx + shr ecx, 14 + + mov ebx, volleft + mov word ptr[ebx], cx + + ret + +BalanceWord ENDP + + END diff --git a/SOURCES/BALANCE.H b/SOURCES/BALANCE.H new file mode 100644 index 0000000..9bad0fb --- /dev/null +++ b/SOURCES/BALANCE.H @@ -0,0 +1,4 @@ +/* balance between 0 and 256, volume between 0 and 128 */ +void Balance( ULONG balance, ULONG volume, ULONG *vol_left, ULONG *vol_right ) ; +void BalanceWord( ULONG balance, ULONG volume, UWORD *vol_left, UWORD *vol_right ) ; + diff --git a/SOURCES/BUBSORT.C b/SOURCES/BUBSORT.C new file mode 100644 index 0000000..c180a12 --- /dev/null +++ b/SOURCES/BUBSORT.C @@ -0,0 +1,29 @@ +void BubbleSort( UBYTE *base, + size_t nelem, + size_t width, + int (*fcmp)(const void *, const void *)) +{ + int i, j; + register UBYTE *o1, *o2, *s; + UBYTE *temp=&base[width*nelem]; + + o1 = base ; + for(i=1; i0) + s = o2 ; + o2 += width; + } + if (s!=o1) + { + memcpy(temp, o1, width); + memcpy(o1, s, width); + memcpy(s, temp, width); + } + o1 += width; + } +} \ No newline at end of file diff --git a/SOURCES/COMMON.H b/SOURCES/COMMON.H new file mode 100644 index 0000000..aab7356 --- /dev/null +++ b/SOURCES/COMMON.H @@ -0,0 +1,561 @@ +/*---------------- RESSOURCE (RESS_HQR) ------------------*/ + +#define RESS_PAL 0 +#define RESS_FONT_GPM 1 +#define RESS_EMPTY 2 +#define RESS_GOODIES_GPC 3 +#define RESS_SHADOW_GPH 4 + +#define RESS_HOLOMAP_PAL 5 +#define RESS_HOLOMAP_HMT 6 +#define RESS_HOLOMAP_HMG 7 +#define RESS_HOLOMAP_POS 8 +#define RESS_HOLO_TWINKEL 9 +#define RESS_HOLO_FLECHE 10 +#define RESS_HOLO_BODYFLECHE 11 + +#define RESS_BUMPER_PCR 12 +#define RESS_BUMPER_PAL 13 +#define RESS_MENU_PCR 14 + +#define RESS_TWINSUN_PCR 15 +#define RESS_TWINSUN_PAL 16 +#define RESS_INTRO_2_PCR 17 +#define RESS_INTRO_2_PAL 18 +#define RESS_INTRO_3_PCR 19 +#define RESS_INTRO_3_PAL 20 + +#define RESS_GAME_OVER 21 +#define RESS_PAL_ALARM 22 +#define RESS_FLA_PCX 23 +#define RESS_PAL_MUSEE 24 + +#define RESS_SENDELL_PCR 25 +#define RESS_SENDELL_PAL 26 +#define RESS_LOGO_PCR 27 +#define RESS_LOGO_PAL 28 + +#define RESS_HOLO_CONE 29 +#define RESS_HOLOMAP_TRAJ 30 + +#define RESS_HOLO_VEHICULE 31 +// vehicule de 31 … 48 + +#define RESS_BUMPER2_PCR 49 +#define RESS_BUMPER2_PAL 50 + +#define RESS_INIT_PLASMA 51 + +#define RESS_BUMPER_EA_PCR 52 +#define RESS_BUMPER_EA_PAL 53 + +/*----------------- CUBE ----------------------*/ + + +#define SIZE_CUBE_X 64 +#define SIZE_CUBE_Y 25 +#define SIZE_CUBE_Z 64 + +#define SIZE_BRICK_XZ 512 +#define SIZE_BRICK_Y 256 +#define DEMI_BRICK_XZ 256 +#define DEMI_BRICK_Y 128 + +#define VIEW_X0 -50 +#define VIEW_Y0 -30 +#define VIEW_X1 680 +#define VIEW_Y1 580 + +/*---------------- FLAG_GAME ------------------*/ + +#define FLAG_HOLOMAP 0 +#define FLAG_BALLE_MAGIQUE 1 +#define FLAG_SABRE_MAGIQUE 2 +#define FLAG_TROMPE 3 +#define FLAG_TUNIQUE 4 +#define FLAG_LIVRE_BU 5 +#define FLAG_MEDAILLON 6 +#define FLAG_FLACON_EAU_CLAIRE 7 + +#define FLAG_MECA_PINGOUIN 14 + +#define FLAG_CARBURANT 15 +#define FLAG_CLOVER 27 + +#define FLAG_CONSIGNE 70 + +/*---------------- SAMPLES ------------------*/ + +#define MAX_SAMPLES 300 + +/*---------------- OBJECTS ------------------*/ + +#define MAX_OBJETS 100 + +#define MAX_EXTRAS 50 + +#define SIZE_NAME 19 + +#define MAX_ANIMS 400 +#define MAX_BODYS 200 + +#define MAX_FLAGS 255 + +#define MAX_ZONES 255 +/*#define MAX_CODES 255 */ +#define MAX_TRACKS 255 + +#define MAX_FLAGS_CUBE 80 +#define MAX_FLAGS_GAME 255 + +#define MAX_INVENTORY 28 + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#define MAX_CLOVER_BOX 10 + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* type objet pour affscene */ + +#define TYPE_OBJ_3D (1024*0) +#define TYPE_FLAG_RED (1024*1) +#define TYPE_FLAG_YELLOW (1024*2) +#define TYPE_SHADOW (1024*3) +#define TYPE_OBJ_SPRITE (1024*4) +#define TYPE_ZONE_DEC (1024*5) +#define TYPE_EXTRA (1024*6) + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + + +/* work flags */ + +#define WAIT_HIT_FRAME 1 +#define OK_HIT 2 +#define ANIM_END 4 +#define NEW_FRAME 8 + +#define WAS_DRAWN 16 + +#define OBJ_DEAD 32 +#define AUTO_STOP_DOOR 64 + +#define ANIM_MASTER_ROT 128 + +#define FALLING 256 + +/* Flags */ + +#define CHECK_OBJ_COL 1 // test des collisions et hit obj +#define CHECK_BRICK_COL 2 // test des collisions decors +#define CHECK_ZONE 4 // test des zones scenariques +#define SPRITE_CLIP 8 // (portes) zone de clip fixe +#define PUSHABLE 16 // poussable +#define COL_BASSE 32 // 1 = pas test des collisions hautes TWINSEN + +#define CHECK_CODE_JEU 64 // test la noyade + +#define INVISIBLE 512 // not drawn but all computed + +#define SPRITE_3D 1024 // un sprite pas un 3DO + +#define OBJ_FALLABLE 2048 // peut tomber +#define NO_SHADOW 4096 // pas d'ombre auto +#define OBJ_BACKGROUND 8192 // s'incruste dans le decor la 1er fois + +#define OBJ_CARRIER 16384 // peut porter et deplacer un obj + +#define MINI_ZV 32768 // zv carre sur plus petit cote (si 3DO) + +/* Option Flags */ + +#define EXTRA_MASK (16+32+64+128+256) + +#define EXTRA_GIVE_NOTHING 1 + +#define EXTRA_GIVE_MONEY 16 +#define EXTRA_GIVE_LIFE 32 +#define EXTRA_GIVE_MAGIC 64 +#define EXTRA_GIVE_KEY 128 +#define EXTRA_GIVE_CLOVER 256 + +/* FlagAnim */ + +#define ANIM_REPEAT 0 +#define ANIM_THEN 1 +#define ANIM_ALL_THEN 2 +#define ANIM_INSERT 3 +#define ANIM_SET 4 + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + + +#define EXTRA_TIME_OUT 1 +#define EXTRA_FLY 2 +#define EXTRA_END_OBJ 4 +#define EXTRA_END_COL 8 +#define EXTRA_STOP_COL 16 +#define EXTRA_TAKABLE 32 +#define EXTRA_FLASH 64 +#define EXTRA_SEARCH_OBJ 128 +#define EXTRA_IMPACT 256 +#define EXTRA_SEARCH_KEY 512 +#define EXTRA_TIME_IN 1024 +#define EXTRA_ONE_FRAME 2048 +#define EXTRA_EXPLO 4096 +#define EXTRA_WAIT_NO_COL 8192 +#define EXTRA_WAIT_SOME_TIME 16384 + + +typedef struct +{ + WORD Sprite ; /* num sprite */ + + WORD PosX ; + WORD PosY ; + WORD PosZ ; + + WORD OrgX ; + WORD OrgY ; + WORD OrgZ ; + + WORD Vx ; + WORD Vy ; + WORD Vz ; + + WORD Flags ; + + WORD Poids ; + + ULONG Timer ; /* memo timer 50hz */ + + WORD TimeOut ; /* life time */ + + WORD HitForce ; /* si !=0 force de frappe */ + + WORD Divers ; /* nombre pour zone giver */ + +} T_EXTRA ; + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +typedef struct +{ + WORD X0 ; + WORD Y0 ; + WORD Z0 ; + WORD X1 ; + WORD Y1 ; + WORD Z1 ; + WORD Type ; + WORD Num ; + WORD Info0 ; + WORD Info1 ; + WORD Info2 ; + WORD Info3 ; } T_ZONE ; + +typedef struct +{ + WORD Z ; + WORD NumObj ; + + WORD Xw ; + WORD Yw ; + + WORD Zw ; + WORD Num ; + + +/* WORD Xmin ; + WORD Ymin ; + WORD Zmin ; + WORD Xmax ; + WORD Ymax ; + WORD Zmax ; */ + + } T_SORT ; + +/*---------------- holomap -----------------*/ + +/* +#define MAX_HOLO_OBJ 50 + +typedef struct { WORD Alpha ; + WORD Beta ; + WORD Size ; + + WORD Obj ; + WORD Flag ; + WORD Info ; } T_HOLO_OBJ ; +*/ +#define MAX_HOLO_POS 150 + +typedef struct { WORD Alpha ; + WORD Beta ; + WORD Size ; + +// WORD XIsland ; +// WORD ZIsland ; + +// UBYTE Type ; + + WORD Mess ; +// WORD Fleche ; + } T_HOLO_POS ; + +/*---------------- incrust display ---------*/ + +#define MAX_INCRUST_DISP 10 + +#define INCRUST_SPRITE 0 +#define INCRUST_NUM 1 +#define INCRUST_CMPT 2 +#define INCRUST_OBJ 3 +#define INCRUST_TEXT 4 + +typedef struct { WORD Num ; + WORD X ; + WORD Y ; + WORD Type ; + WORD Info ; + WORD Move ; + ULONG TimerEnd ; } T_INCRUST_DISP ; + +/*---------------- divers ------------------*/ + +#define START_FILE_ISLAND 3 + +#define Rnd(n) (rand()%n) + +#define NUM_PERSO 0 + +#define C_NORMAL 0 +#define C_SPORTIF 1 +#define C_AGRESSIF 2 +#define C_DISCRET 3 +#define C_PROTOPACK 4 + +#define ACTIVE_LIFE 0 +#define ACTIVE_TRACK 1 + +#define MAX_TYPES_ZONE 7 + +#define POS_MIDDLE 1 +#define POS_LEFT 2 +#define POS_RIGHT 4 +#define POS_UP 8 +#define POS_DOWN 16 + +/*---------------- Script: defines ------------------*/ + +#define NO_MOVE 0 +#define MOVE_MANUAL 1 +#define MOVE_FOLLOW 2 +#define MOVE_TRACK 3 +#define MOVE_FOLLOW_2 4 +#define MOVE_TRACK_ATTACK 5 +#define MOVE_SAME_XZ 6 +#define MOVE_RANDOM 7 + +#define NB_MOVES 8 + + +/*---------------- Track: macros ------------------*/ + +#define TM_END 0 +#define TM_NOP 1 +#define TM_BODY 2 +#define TM_ANIM 3 +#define TM_GOTO_POINT 4 +#define TM_WAIT_ANIM 5 +#define TM_LOOP 6 +#define TM_ANGLE 7 +#define TM_POS_POINT 8 +#define TM_LABEL 9 +#define TM_GOTO 10 +#define TM_STOP 11 +#define TM_GOTO_SYM_POINT 12 +#define TM_WAIT_NB_ANIM 13 +#define TM_SAMPLE 14 +#define TM_GOTO_POINT_3D 15 +#define TM_SPEED 16 +#define TM_BACKGROUND 17 +#define TM_WAIT_NB_SECOND 18 +#define TM_NO_BODY 19 +#define TM_BETA 20 +#define TM_OPEN_LEFT 21 +#define TM_OPEN_RIGHT 22 +#define TM_OPEN_UP 23 +#define TM_OPEN_DOWN 24 +#define TM_CLOSE 25 +#define TM_WAIT_DOOR 26 +#define TM_SAMPLE_RND 27 +#define TM_SAMPLE_ALWAYS 28 +#define TM_SAMPLE_STOP 29 +#define TM_PLAY_FLA 30 +#define TM_REPEAT_SAMPLE 31 +#define TM_SIMPLE_SAMPLE 32 +#define TM_FACE_TWINKEL 33 +#define TM_ANGLE_RND 34 + +#define NB_MACROS_TRACK 35 + +/*---------------- Life: macro ------------------*/ + +/*---*/ +#define LM_END 0 +#define LM_NOP 1 +#define LM_SNIF 2 +#define LM_OFFSET 3 +#define LM_NEVERIF 4 + +#define LM_LABEL 10 +#define LM_RETURN 11 +#define LM_IF 12 +#define LM_SWIF 13 +#define LM_ONEIF 14 +#define LM_ELSE 15 +#define LM_ENDIF 16 +#define LM_BODY 17 +#define LM_BODY_OBJ 18 +#define LM_ANIM 19 +#define LM_ANIM_OBJ 20 +#define LM_SET_LIFE 21 +#define LM_SET_LIFE_OBJ 22 +#define LM_SET_TRACK 23 +#define LM_SET_TRACK_OBJ 24 +#define LM_MESSAGE 25 +#define LM_FALLABLE 26 +#define LM_SET_DIR 27 +#define LM_SET_DIR_OBJ 28 +#define LM_CAM_FOLLOW 29 +#define LM_COMPORTEMENT_HERO 30 +#define LM_SET_FLAG_CUBE 31 +#define LM_COMPORTEMENT 32 +#define LM_SET_COMPORTEMENT 33 +#define LM_SET_COMPORTEMENT_OBJ 34 +#define LM_END_COMPORTEMENT 35 +#define LM_SET_FLAG_GAME 36 +#define LM_KILL_OBJ 37 +#define LM_SUICIDE 38 +#define LM_USE_ONE_LITTLE_KEY 39 +#define LM_GIVE_GOLD_PIECES 40 +#define LM_END_LIFE 41 +#define LM_STOP_L_TRACK 42 +#define LM_RESTORE_L_TRACK 43 +#define LM_MESSAGE_OBJ 44 +#define LM_INC_CHAPTER 45 +#define LM_FOUND_OBJECT 46 +#define LM_SET_DOOR_LEFT 47 +#define LM_SET_DOOR_RIGHT 48 +#define LM_SET_DOOR_UP 49 +#define LM_SET_DOOR_DOWN 50 +#define LM_GIVE_BONUS 51 +#define LM_CHANGE_CUBE 52 +#define LM_OBJ_COL 53 +#define LM_BRICK_COL 54 +#define LM_OR_IF 55 +#define LM_INVISIBLE 56 +#define LM_ZOOM 57 +#define LM_POS_POINT 58 +#define LM_SET_MAGIC_LEVEL 59 +#define LM_SUB_MAGIC_POINT 60 +#define LM_SET_LIFE_POINT_OBJ 61 +#define LM_SUB_LIFE_POINT_OBJ 62 +#define LM_HIT_OBJ 63 +#define LM_PLAY_FLA 64 +#define LM_PLAY_MIDI 65 +#define LM_INC_CLOVER_BOX 66 +#define LM_SET_USED_INVENTORY 67 +#define LM_ADD_CHOICE 68 +#define LM_ASK_CHOICE 69 +#define LM_BIG_MESSAGE 70 +#define LM_INIT_PINGOUIN 71 +#define LM_SET_HOLO_POS 72 +#define LM_CLR_HOLO_POS 73 +#define LM_ADD_FUEL 74 +#define LM_SUB_FUEL 75 +#define LM_SET_GRM 76 +#define LM_SAY_MESSAGE 77 +#define LM_SAY_MESSAGE_OBJ 78 +#define LM_FULL_POINT 79 +#define LM_BETA 80 +#define LM_GRM_OFF 81 +#define LM_FADE_PAL_RED 82 +#define LM_FADE_ALARM_RED 83 +#define LM_FADE_ALARM_PAL 84 +#define LM_FADE_RED_PAL 85 +#define LM_FADE_RED_ALARM 86 +#define LM_FADE_PAL_ALARM 87 +#define LM_EXPLODE_OBJ 88 +#define LM_BULLE_ON 89 +#define LM_BULLE_OFF 90 +#define LM_ASK_CHOICE_OBJ 91 +#define LM_SET_DARK_PAL 92 +#define LM_SET_NORMAL_PAL 93 +#define LM_MESSAGE_SENDELL 94 +#define LM_ANIM_SET 95 +#define LM_HOLOMAP_TRAJ 96 +#define LM_GAME_OVER 97 +#define LM_THE_END 98 +#define LM_MIDI_OFF 99 +#define LM_PLAY_CD_TRACK 100 +#define LM_PROJ_ISO 101 +#define LM_PROJ_3D 102 +#define LM_TEXT 103 +#define LM_CLEAR_TEXT 104 +#define LM_BRUTAL_EXIT 105 + +#define NB_MACROS_LIFE 106 + +/*---*/ +#define LF_COL 0 +#define LF_COL_OBJ 1 +#define LF_DISTANCE 2 +#define LF_ZONE 3 +#define LF_ZONE_OBJ 4 +#define LF_BODY 5 +#define LF_BODY_OBJ 6 +#define LF_ANIM 7 +#define LF_ANIM_OBJ 8 +#define LF_L_TRACK 9 +#define LF_L_TRACK_OBJ 10 +#define LF_FLAG_CUBE 11 +#define LF_CONE_VIEW 12 +#define LF_HIT_BY 13 +#define LF_ACTION 14 +#define LF_FLAG_GAME 15 +#define LF_LIFE_POINT 16 +#define LF_LIFE_POINT_OBJ 17 +#define LF_NB_LITTLE_KEYS 18 +#define LF_NB_GOLD_PIECES 19 +#define LF_COMPORTEMENT_HERO 20 +#define LF_CHAPTER 21 +#define LF_DISTANCE_3D 22 +#define LF_MAGIC_LEVEL 23 +#define LF_MAGIC_POINT 24 +#define LF_USE_INVENTORY 25 +#define LF_CHOICE 26 +#define LF_FUEL 27 +#define LF_CARRY_BY 28 +#define LF_CDROM 29 + +#define NB_FUNCS_LIFE 30 + +/*---*/ +#define LT_EQUAL 0 +#define LT_SUP 1 +#define LT_LESS 2 +#define LT_SUP_EQUAL 3 +#define LT_LESS_EQUAL 4 +#define LT_DIFFERENT 5 + +#define NB_TESTS_LIFE 6 + +/*---------------- The End: error ------------------*/ + +#define ERROR_FILE_NOT_FOUND 0 +#define NOT_ENOUGH_MEM 1 +#define PROGRAM_OK 2 +#define NAME_NOT_FOUND 3 diff --git a/SOURCES/CPYMASK.ASM b/SOURCES/CPYMASK.ASM new file mode 100644 index 0000000..34cb7d0 --- /dev/null +++ b/SOURCES/CPYMASK.ASM @@ -0,0 +1,376 @@ +;---------------------------------------------------------------------------- +; Mask_A.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386P + jumps + .model SMALL, SYSCALL +;---------------------------------------------------------------------------- + .data +;---------------------------------------------------------------------------- + include \projet\lib386\lib_svga\svga.ash +comment @ + DWORD TabOffset[] + Brick: + - BYTE Delta X + - BYTE Delta Y + Line(Delta Y): + - BYTE NbBlock + Block 0: Nb Zero to Jump + Block 1: Nb Zero to Write + Block 2: Nb Zero to Jump + etc... +@ + +BufferClip db 512 dup(?) +OffsetBegin dd 0 +NbPix dd 0 + +save_esi dd ? + +extrn NoLanguage Screen:DWORD + +;---------------------------------------------------------------------------- + .code + + public NoLanguage CopyMask + +;---------------------------------------------------------------------------- +CopyMask proc uses esi edi ebx ebp,\ + nummask:DWORD, xmask:DWORD, ymask:DWORD, \ + bankmask:DWORD, ptsrc:DWORD + + mov esi, ptsrc + + mov eax, nummask + mov ebx, xmask + mov ecx, ymask + mov ebp, bankmask + + add ebp, [ebp+eax*4] ; EBP = Begin Data + + xor eax, eax + mov al, [ebp+2] ; Hot X + add ebx, eax + mov al, [ebp+3] ; Hot Y + add ecx, eax + +;----------------------------------------------- + + xor edx, edx + mov dl, [ebp] ; Delta X + mov al, [ebp+1] ; Nb Line ( Delta Y ) + add ebp, 4 ; Jump Hot X & Hot Y + +;----------------------------------------------- Test Clipping + + add edx, ebx + add eax, ecx + dec edx + dec eax + + cmp ebx, ClipXmin + jl ClippingMask + cmp ecx, ClipYmin + jl ClippingMask + cmp edx, ClipXmax + jg ClippingMask + cmp eax, ClipYmax + jg ClippingMask + + inc edx + inc eax + sub edx, ebx + sub eax, ecx + +;----------------------------------------------- Calcul Offset Ecran + add ebx, TabOffLine[ecx*4] + + mov edi, Log + + add esi, ebx + add edi, ebx + + mov bh, al ; BH = NbLine + sub edx, Screen_X ; EDX = Offset Screen + neg edx ; EDX = Screen_X-edx + xor ecx, ecx ; Maz Compteur +;----------------------------------------------- Init NbBlock for this line +NextLine: mov bl, [ebp] ; BL = Nb Block for this line + inc ebp +;----------------------------------------------- Manage One Line +SameLine: mov cl, [ebp] ; Nb Zero to Jump + add edi, ecx ; Incrust on Log + add esi, ecx ; And on PtSrc + + dec bl + je EndBlock + + mov cl, [ebp+1] ; Nb Zero to Write + add ebp, 2 + + mov al, cl + shr cl, 2 + and al, 11b + rep movsd ; Write Datas From PtSrc + mov cl, al + rep movsb + + dec bl ; Nb Block-- + jne SameLine ; Continue Same Line + add edi, edx ; EDI += Offset Screen + add esi, edx + dec bh ; NbLine-- + jne NextLine ; Next Line + ret +EndBlock: + inc ebp + add edi, edx ; EDI += Offset Screen + add esi, edx + dec bh ; NbLine-- + jne NextLine ; Next Line + ret + +;-------------------------------------------------------------------- Clipping +; Graph : ( EBX, ECX ) ( EDX, EAX ) + +ClippingMask: + cmp ebx, ClipXmax + jg EndMask + cmp ecx, ClipYmax + jg EndMask + cmp edx, ClipXmin + jl EndMask + cmp eax, ClipYmin + jl EndMask + + cmp ecx, ClipYmin + jge PasHaut + +;---------------------- Clipping Haut, Saute ClipYmin-ECX Line(s) + + sub ecx, ClipYMin + neg ecx + + mov esi, eax + + xor eax, eax +NextH: mov al, [ebp] + lea ebp, [ebp+1+eax] + dec ecx + jnz NextH + + mov eax, esi + + mov ecx, ClipYMin + +;---------------------- Clipping Bas +PasHaut: cmp eax, ClipYmax + jle PasBas + mov eax, ClipYmax +;---------------------- Clipping Gauche +Pasbas: mov OffsetBegin, 0 + cmp ebx, ClipXmin + jge PasGauche + + mov esi, ClipXmin + sub esi, ebx + mov OffsetBegin, esi + +;---------------------- Clipping Droit +PasGauche: + mov esi, edx + sub esi, ebx + sub esi, OffsetBegin + inc esi + mov NbPix, esi + + cmp edx, ClipXmax + jle PasDroit + + sub edx, ClipXmax + sub NbPix, edx + mov edx, ClipXmax +;---------------------- + + +PasDroit: ; ESI debut data Y ok pas X + ; EBX not clipped X0 + ; ECX good Y0 + ; EAX clipped Y1 + ; NbPix real X nb pix + ; OffsetBegin start X ( !!!!! < 128 ) + + mov edx, TabOffLine[ecx*4] + add edx, ebx + add edx, [OffsetBegin] + + lea ebx, [eax+1] + + mov eax, edx ; good Y offset screen + add edx, Log + add eax, Screen ; Screen + + sub ebx, ecx + + xor ecx, ecx + + jmp start + + + +aplus: mov cl, bl + add ebp, ecx + +aplus2: shr ebx, 16 + dec bl + jz EndMask + +l1: inc ebp + + add eax, 640 + add edx, 640 +start: + shl ebx, 16 + + mov cl, byte ptr[OffsetBegin]; start x + ; cl = nb pix count + + mov bh, byte ptr[NbPix] ; nb point … copier + + mov esi, eax + mov edi, edx ; new pos screen + + mov bl, [ebp] ; nb blocs + +l0: inc ebp + dec bl + jz aplus2 + sub cl, [ebp] ; nb pix to jump + jc rptj ; reste pix to jump + jz okdraw ; tombe pile + + inc ebp + dec bl + sub cl, [ebp] ; nb copy point + jc rgtc ; reste graph to copy + jz okjump2 + + or bl, bl + jnz l0 + + shr ebx, 16 + dec bl ; nb lig-- + jnz l1 + ret +rptj: + ; cl = - nb pix to jump + add bh, cl ; reste … ecrire + jle aplus + neg cl + jmp okdraw2 + +rgtc: + neg cl ; cl nb pix to copy + sub bh, cl ; reste … ecrire + jc cpt ; copy pas tout + rep movsb ; copy + jz aplus + +okjump2: or bl, bl + jz aplus2 + +okjump: inc ebp + dec bl + jz aplus2 + mov cl, [ebp] ; nb pix to jump + sub bh, cl ; reste … ecrire + jle aplus ; fini +okdraw2: + add edi, ecx + add esi, ecx + +okdraw: inc ebp + dec bl ; nb bloc-- + mov cl, [ebp] ; nb pix to copy + sub bh, cl ; reste … ecrire + jc cpt ; copy pas tout + rep movsb ; copy + jz aplus ; tombe pile + or bl, bl + jnz okjump + + shr ebx, 16 + dec bl ; nb lig-- + jnz l1 + ret + +cpt: add cl, bh + rep movsb + + ; ligne finie + + mov cl, bl + add ebp, ecx + + shr ebx, 16 + dec bl ; nb lig-- + jnz l1 +EndMask: ret + +comment # + add ebx, TabOffLine[ecx*4] + mov edi, Log + add edi, ebx + + sub eax, ecx + inc al + mov bh, al ; BH NbLine + xor ecx, ecx + mov ebp, edi +;---------------------------------------------- + ; ESI = DATAS LINE +NextL: lea edi, BufferClip ; EDI = BUFFERCLIP + lodsb ; NbBlock + mov bl, al +SameL: lodsb + mov cl, al + mov al, 1 + rep stosb + dec bl + je EndLine + lodsb + mov cl, al + xor al, al + rep stosb + dec bl + jne SameL +;---------------------- +EndLine: push esi ; SAVE ESI + lea esi, BufferClip ; ESI = BUFFERCLIP + mov edi, ebp ; EDI = SCREEN + mov ecx, OffsetBegin + add esi, ecx + add edi, ecx + mov ecx, NbPix +;---------------------- +Again: + lodsb + or al, al + jne Incrust + mov [edi], al +Incrust: inc edi + loop Again + + add ebp, 640 + pop esi + dec bh + jne NextL +;---------------------- + # + +CopyMask endp + +;---------------------------------------------------------------------------- +; The + End diff --git a/SOURCES/C_EXTERN.H b/SOURCES/C_EXTERN.H new file mode 100644 index 0000000..dc2677d --- /dev/null +++ b/SOURCES/C_EXTERN.H @@ -0,0 +1,352 @@ +#include "defines.h" + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#include "ambiance.def" +#include "diskfunc.def" +#include "extra.def" +#include "fiche.def" +#include "flipbox.def" +#include "gamemenu.def" +#include "gerelife.def" +#include "geretrak.def" +#include "grille.def" +#include "holomap.def" +#include "incrust.def" +#include "message.def" +#include "object.def" +#include "perso.def" +#include "playfla.def" + +/* prototype */ + +char *GetMultiText( LONG text, char *dst ) ; + +WORD GiveObjSelect( WORD type, LONG xm, LONG ym ) ; + +UBYTE WorldColBrick( WORD xw, WORD yw, WORD zw ) ; + +WORD ThrowExtra( WORD owner, + WORD x, WORD y, WORD z, WORD num, + WORD alpha, WORD beta, WORD vitesse, WORD poids, + WORD hitforce ) ; +WORD GetValue() ; + +WORD GetListObjet( WORD x0, WORD y0 ) ; + +LONG SceReadWord() ; +WORD SearchLastZoneSce() ; + +ULONG HQ_MixSample( WORD numsample, WORD decalage, WORD repeat, WORD volleft, WORD volright ) ; +void HQ_StopOneSample( WORD num ) ; + +void *LoadTestMalloc( char *filename ) ; + +WORD InitAnim( UBYTE gen_anim, WORD flag, UBYTE gen_nextanim, WORD numobj ) ; +WORD SearchAnim( UBYTE numanim, WORD numobj ) ; +WORD SearchBody( UBYTE numbody, WORD numobj ) ; +void LoadFic( UBYTE indexfileobjet, WORD numobj ) ; + +/*--------- divers ---------------------------------------------*/ + +extern UWORD *BufOrder ; +extern UBYTE *BufText ; +extern UBYTE *BufSpeak ; + +extern UBYTE GamePathname[] ; + +extern WORD ComportementDebug; + +extern UBYTE *LbaFont ; +extern UBYTE *Screen ; +extern UBYTE PalettePcx[] ; +extern UBYTE *PtrPal ; + +extern WORD MyJoy ; +extern WORD MyFire ; +extern WORD MyKey ; + +extern WORD LastFire ; + +extern LONG FlagVsync ; +extern WORD FlagMCGA ; +extern LONG FlagCredits ; + +extern UBYTE String[] ; +extern UBYTE EditString[] ; +extern WORD Value ; + +extern LONG SampleVolume, MusicVolume, CDVolume, LineVolume, MasterVolume ; +extern WORD SamplesEnable ; +extern UBYTE *PtrSample[] ; + +extern WORD QuickMessage ; +extern LONG FlecheForcee ; + +extern WORD FlagPalettePcx ; +extern WORD FlagFade ; +extern WORD FlagMessageShade ; +extern WORD Bulle ; +extern WORD FlagBlackPal ; + +extern WORD FlaFromCD ; +extern UBYTE PathFla[] ; + +extern LONG Version_US ; + +/*-------- RESSOURCES ---------------------------------------------*/ + +extern T_HQR_HEADER *HQR_Samples ; +extern T_HQR_HEADER *HQR_Midi ; +extern T_HQR_HEADER *InventoryObj ; + +/*-------- DISKFUNC.C ---------------------------------------------*/ + +extern char PleaseWait[] ; + +extern UBYTE ProgDrive[] ; +extern UBYTE ProgDir[] ; + +extern ULONG OrgDrive ; +extern UBYTE OrgDir[] ; + +extern UBYTE Drive[] ; +extern UBYTE Dir[] ; +extern UBYTE Name[] ; +extern UBYTE Ext[] ; + +extern UBYTE OrgPathname[] ; +extern UBYTE ProgramPathname[] ; + +extern UBYTE Pathname[] ; + +extern UBYTE FliPathname[_MAX_PATH] ; + +/*-------- SCRIPT.C ---------------------------------------------*/ + +extern UBYTE FicName[] ; +extern UBYTE *PtrFiche ; +extern UBYTE *PtrCommand ; +extern UBYTE *PtrFicName ; + +/*-------- FLIP_BOX.C ---------------------------------------------*/ + +extern WORD NbPhysBox ; +extern WORD NbOptPhysBox ; + +/*-------- LIB_SVGA ---------------------------------------------*/ + +extern WORD NbPolyPoints ; + +/*-------- life tool ---------------------------------------------*/ + +extern WORD ErrorFlag ; + +extern WORD FlagInfos ; + +extern WORD Modif ; + +extern UBYTE DefPathname[] ; +extern UBYTE ScePathname[] ; +extern UBYTE PcxPathname[] ; + +extern WORD FlagFrame ; + +extern T_ZONE *ListZone ; +extern WORD NbZones ; + +extern WORD IndexZone ; +extern WORD EditNumZone ; +extern WORD EditTypeZone ; +extern WORD VisuTypeZone ; + +extern UBYTE *ListTypeZone[] ; + +extern T_TRACK *ListBrickTrack ; +extern WORD NbBrickTrack ; + +extern WORD IndexBrickTrack ; +extern WORD EditNumTrack ; + +extern WORD ActiveEdit ; + +/* +extern T_FLAG ListFlagCube[] ; +extern T_FLAG ListFlagGame[] ; +*/ +extern UBYTE ListFlagCube[] ; +extern UBYTE ListFlagGame[] ; + +extern UBYTE ListFlagInventory[] ; + + +extern UBYTE *ListMove[] ; + +/*--------- holomap ----------------------------*/ + +//extern T_HOLO_OBJ ListHoloObj[MAX_HOLO_OBJ] ; +//extern WORD NbHoloObj ; + +extern T_HOLO_POS *ListHoloPos ; // [MAX_HOLO_POS] ; +extern UBYTE TabHoloPos[] ; + +/*--------- menus -----------------------------*/ + +extern WORD GameChoice ; +extern WORD GameNbChoices ; +extern WORD GameListChoice[] ; + +/*--------- perso ----------------------------*/ + +extern WORD FlagTheEnd ; + +extern WORD ActionNormal ; +extern WORD InventoryAction ; +extern WORD Weapon ; + +extern WORD Comportement ; +extern WORD AnimRien ; +extern WORD AnimRienNormal, AnimRienSportif, AnimRienAgressif, AnimRienDiscret, AnimRienProtopack ; + +extern UBYTE *PtrFile3dNormal ; +extern UBYTE *PtrFile3dSportif ; +extern UBYTE *PtrFile3dAgressif ; +extern UBYTE *PtrFile3dDiscret ; +extern UBYTE *PtrFile3dProtopack ; + +extern WORD SceZoom ; +extern WORD Shadow ; +extern WORD ShadowX, ShadowY, ShadowZ ; +extern UBYTE ShadowCol ; + +extern WORD NumHolomapTraj ; +extern WORD FlagChgCube, NewCube, NumCube ; +extern WORD NewPosX, NewPosY, NewPosZ ; +extern WORD SceneStartX, SceneStartY, SceneStartZ ; +extern WORD CubeStartX, CubeStartY, CubeStartZ ; +extern WORD GameOverCube ; + +extern WORD CombatAuto ; +extern WORD MagicBall ; +extern WORD MagicBallType ; +extern WORD MagicBallCount ; + +extern WORD MagicLevel ; +extern WORD MagicPoint ; +extern WORD NbGoldPieces ; +extern WORD NbLittleKeys ; +extern WORD Chapitre ; +extern UBYTE Island ; +extern WORD Fuel ; +extern WORD NumPingouin ; + +extern WORD NbFourLeafClover ; +extern WORD NbCloverBox ; + +extern WORD FlagClimbing ; +extern WORD StartYFalling ; +extern T_REAL_VALUE RealFalling ; +extern WORD StepFalling ; + +extern UBYTE CodeJeu ; +extern WORD FlagWater ; + +// perso sauvegarde entr‚e cube + +extern WORD SaveCube ; +extern WORD SaveComportement ; + +extern char SaveStringBody[SIZE_NAME+1] ; +extern BYTE SaveGenBody ; + +extern WORD SaveBeta ; +extern WORD SaveNbGoldPieces ; +extern WORD SaveMagicLevel ; +extern WORD SaveMagicPoint ; +extern WORD SaveLifePoint ; +extern WORD SaveChapitre ; +extern WORD SaveNbCloverBox ; +extern WORD SaveNbFourLeafClover ; + +/*--------- Extra objs ----------------------------*/ + +extern T_EXTRA ListExtra[] ; + +//extern UBYTE *PtrSpriteExtra ; +extern T_HQR_HEADER *HQRPtrSpriteExtra ; +extern WORD *PtrZvExtra ; + +/*---------------- incrust display ----------------*/ + +extern T_INCRUST_DISP ListIncrustDisp[] ; + +/*-------- Moteur 3D ---------------------------------------------*/ + +extern UBYTE *BufferShadow ; + +extern UBYTE *BufferAnim ; +extern UBYTE *PtrBufferAnim ; + +extern LONG NbBodys ; +extern UBYTE *PtrBody[] ; +extern T_HQR_HEADER *HQR_Anims ; + +extern LONG NbObjets ; +extern T_OBJET ListObjet[] ; + +extern T_SORT ListTri[] ; + +extern WORD NumObjFollow ; + +/*--------- ambiance ----------------------------*/ + +extern WORD SampleAmbiance[] ; +extern WORD SampleRepeat[] ; +extern WORD SampleRnd[] ; +extern WORD SamplePlayed ; +extern ULONG TimerNextAmbiance ; +extern WORD SecondEcart ; +extern WORD SecondMin ; +extern WORD CubeJingle ; +extern UBYTE *PtrXmi ; +extern WORD NumXmi ; + +/*-------- Brick ISO ---------------------------------------------*/ + +#ifdef BRICK_HQR +extern UBYTE *BufferBrick ; +#endif +extern UBYTE *BufCube ; + +extern WORD FirstTime ; +extern WORD CameraZone ; + +extern LONG StartXCube ; +extern LONG StartYCube ; +extern LONG StartZCube ; + +extern LONG WorldXCube ; +extern LONG WorldYCube ; +extern LONG WorldZCube ; + +extern WORD XpOrgw ; +extern WORD YpOrgw ; + +extern WORD LastXmBrickSelected ; +extern WORD LastYmBrickSelected ; +extern WORD LastZmBrickSelected ; + +extern UBYTE *BufCollis ; + +extern WORD CubeClip ; +extern WORD CubeClipX, CubeClipY, CubeClipZ ; + +extern WORD FlagAffGrille ; +/*--------- Message ---------------------------------------------*/ + +extern WORD NumObjSpeak ; +extern LONG FlagSpeak ; + + + diff --git a/SOURCES/DEFINES.H b/SOURCES/DEFINES.H new file mode 100644 index 0000000..8d2f5da --- /dev/null +++ b/SOURCES/DEFINES.H @@ -0,0 +1,259 @@ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßßÜ Ûßßßß Ûßßßß Û ÛÛÜ Û Ûßßßß ÛÛßßß + ÛÛ Û ÛÛßß ÛÛßß ÛÛ ÛÛßÛÛ ÛÛßß ßßßßÛ + ßßßß ßßßßß ßß ßß ßß ß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +// Cdrom Version si pas define version disk +//#define CDROM 1 + +// mettre ce define pour une version travail seulement +// en cdrom pas d'importance ATTENTION … supprimer pour version disk +// #define MAGOUILLE_FLA_HD 1 + +/*----------------*/ + +// demo 3 cubes +// #define DEMO 1 + +// sauvegarde ecran/acceleration/infos +//#define DEBUG_TOOLS 1 + +/*----------------*/ + +// Brick, Gri et Bll dans .HQR +#define BRICK_HQR 1 +// samples dans .HQR +#define SAMPLE_HQR 1 +// midi music dans .HQR +#define MIDI_HQR 1 +// samples des FLAs dans .HQR +#define SAMPLE_FLA_HQR 1 + +// tous fichiers dans mˆme dir +#define ONE_GAME_DIRECTORY 1 + +//path des ressources +#define PATH_RESSOURCE "" + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#include +#include +#include +#include +#include + +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_svga\lib_svga.h" +#include "\projet\lib386\lib_3D\lib_3D.h" +#include "\projet\lib386\lib_mix\lib_mix.h" +#include "\projet\lib386\lib_samp\lib_wave.h" +#include "\projet\lib386\lib_midi\lib_midi.h" +#include "\projet\lib386\lib_cd\lib_cd.h" + +#include "common.h" + +/*---------------- macros ------------------*/ + +#ifdef DEBUG_TOOLS + +extern ULONG UsedHQMemory ; + +#define CHECK_MEMORY \ + if( (Size_HQM_Memory-Size_HQM_Free) > UsedHQMemory )\ + {\ + UsedHQMemory = Size_HQM_Memory-Size_HQM_Free ;\ + } +#else + +#define CHECK_MEMORY /* coucou */ + +#endif + +/*---------------- CONSTANTE ------------------*/ + +#define SIZE_CUBE_X 64 +#define SIZE_CUBE_Y 25 +#define SIZE_CUBE_Z 64 + +#define SIZE_BRICK_XZ 512 +#define SIZE_BRICK_Y 256 +#define DEMI_BRICK_XZ 256 +#define DEMI_BRICK_Y 128 + +/*---------------- FENETRE ------------------*/ + +#define VIEW_X0 -50 +#define VIEW_Y0 -30 +#define VIEW_X1 680 +#define VIEW_Y1 580 + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#define MAX_CLOVER_BOX 10 + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* type objet pour affscene */ + +#define TYPE_OBJ_3D (1024*0) +#define TYPE_FLAG_RED (1024*1) +#define TYPE_FLAG_YELLOW (1024*2) +#define TYPE_SHADOW (1024*3) +#define TYPE_OBJ_SPRITE (1024*4) +#define TYPE_ZONE_DEC (1024*5) +#define TYPE_EXTRA (1024*6) + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#define FILE_3D_NORMAL 0 +#define FILE_3D_SPORTIF 1 +#define FILE_3D_AGRESSIF 2 +#define FILE_3D_DISCRET 3 +#define FILE_3D_PROTOPACK 4 + +#define NO_BODY 255 + +#define GEN_BODY_NORMAL 0 +#define GEN_BODY_TUNIQUE 1 +#define GEN_BODY_SABRE 2 + +#define NO_ANIM 255 + +#define GEN_ANIM_RIEN 0 +#define GEN_ANIM_MARCHE 1 +#define GEN_ANIM_RECULE 2 +#define GEN_ANIM_GAUCHE 3 +#define GEN_ANIM_DROITE 4 +#define GEN_ANIM_ENCAISSE 5 +#define GEN_ANIM_CHOC 6 +#define GEN_ANIM_TOMBE 7 +#define GEN_ANIM_RECEPTION 8 +#define GEN_ANIM_RECEPTION_2 9 +#define GEN_ANIM_MORT 10 +#define GEN_ANIM_ACTION 11 +#define GEN_ANIM_MONTE 12 +#define GEN_ANIM_ECHELLE 13 +#define GEN_ANIM_SAUTE 14 +#define GEN_ANIM_LANCE 15 +#define GEN_ANIM_CACHE 16 +#define GEN_ANIM_COUP_1 17 +#define GEN_ANIM_COUP_2 18 +#define GEN_ANIM_COUP_3 19 +#define GEN_ANIM_TROUVE 20 +#define GEN_ANIM_NOYADE 21 +#define GEN_ANIM_CHOC2 22 +#define GEN_ANIM_SABRE 23 +#define GEN_ANIM_DEGAINE 24 + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +typedef struct +{ + UBYTE GenBody ; // 0 … 254 mais je veux -1 + UBYTE GenAnim ; + UBYTE NextGenAnim ; + + UBYTE Col ; /* brick en collision (inutile?) */ + + UBYTE *PtrAnimAction ; + + WORD Sprite ; + + WORD OffsetLabelTrack ; + +// divers + + UBYTE *PtrFile3D ; + +// constantes + + WORD OptionFlags ; /* flag d'init 2 */ +/* B*/ WORD NbBonus ; /* nb bonus to give */ +/* B*/ WORD Armure ; /* resistance */ + WORD CoulObj ; /* couleur dominante de l'objet */ + +/* game infos */ + + WORD Body ; /* num body ou sprite dans la base */ + + WORD PosObjX ; /* pos world en cours */ + WORD PosObjY ; + WORD PosObjZ ; + + WORD OldPosX ; /* old pos world */ + WORD OldPosY ; + WORD OldPosZ ; + + WORD Xmin ; /* ZV */ + WORD Xmax ; + WORD Ymin ; + WORD Ymax ; + WORD Zmin ; + WORD Zmax ; + + WORD Beta ; /* angle en cours */ + + WORD SRot ; /* vitesse de rotation */ + + T_REAL_VALUE RealAngle ; /* valeur real time de rotation */ +/* B*/ WORD Move ; /* type de deplacement */ + + UBYTE *PtrTrack ; /* ptr track prog */ + WORD OffsetTrack ; /* offset dans la track */ + + UBYTE *PtrLife ; + WORD OffsetLife ; /* offset dans la vie */ + + WORD Info ; /* infos pour DoDir */ + WORD Info1 ; + WORD Info2 ; + WORD Info3 ; + +/* B*/ WORD ObjCol ; /* num obj en collision */ +/* B*/ WORD CarryBy ; + + WORD ZoneSce ; /* zone declenchement scenarique */ +/* B*/ WORD LabelTrack ; /* dernier label de track */ +/* B*/ WORD MemoLabelTrack ; /* memo dernier label de track */ + + WORD Flags ; /* flags divers permanent */ + WORD WorkFlags ; /* flags de gestion */ + +/* B*/ WORD HitBy ; /* frappe par */ + +/* B*/ WORD HitForce ; /* si !=0 force de frappe anim */ + +/* B*/ WORD LifePoint ; /* point de vie en cours */ + +/* B*/ WORD AnimStepBeta ; /* step de rotation par anim */ + WORD AnimStepX ; /* step de dep par anim */ + WORD AnimStepY ; + WORD AnimStepZ ; + + WORD DoorWidth ; // pour les DOOR peut reservir + + WORD Anim ; /* anim en cours */ +/* B*/ WORD Frame ; /* frame en cours */ +/* B*/ WORD FlagAnim ; /* type d'anim en cours (dans flags?) */ + + UBYTE CodeJeu ; // brick sp‚ciale sample ou action + +} T_OBJET ; + +/* +typedef struct +{ + UBYTE Bit ; } T_FLAG ; +*/ + +typedef struct +{ + WORD X ; + WORD Y ; + WORD Z ; } T_TRACK ; + diff --git a/SOURCES/DISKFUNC.C b/SOURCES/DISKFUNC.C new file mode 100644 index 0000000..6c37a67 --- /dev/null +++ b/SOURCES/DISKFUNC.C @@ -0,0 +1,228 @@ +#include "c_extern.h" +#include "direct.h" + +#include + +UBYTE *PtrSce ; +UBYTE *PtrScene ; + +#define GET_BYTE (*PtrSce++) +#define GET_WORD (*(WORD*)PtrSce) ; PtrSce+=2 + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßßÜ Û ÛÛßßß Û Üß Ûßßßß Û Û ÛÛÜ Û Ûßßßß + ÛÛ Û ÛÛ ßßßßÛ ÛÛßÜ ÛÛßß ÛÛ Û ÛÛßÛÛ ÛÛ + ßßßß ßß ßßßßß ßß ß ßßßßß ßß ßßßßß ßß ß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void GetDiskEnv( UBYTE *progpath ) +{ + _splitpath( (char*)progpath, ProgDrive, ProgDir, Name, Ext ) ; + getcwd( OrgDir, _MAX_DIR ) ; + _dos_getdrive( &OrgDrive ) ; +} + +void RestoreDiskEnv() +{ + ULONG total ; + + _dos_setdrive( OrgDrive, &total ) ; + chdir( OrgDir ) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛÛßßß Ûßßßß Ûßßßß ÛÛÜ Û Ûßßßß Ûßßßß Û Û Ûßßßß + ßßßßÛ ÛÛ ÛÛßß ÛÛßÛÛ ÛÛßß ÛÛßß ÛÛ ÛÛ ÛÛßß + ßßßßß ßßßßß ßßßßß ßß ß ßßßßß ßßßßß ßß ßß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +WORD LoadScene( WORD numscene ) +{ + T_OBJET *ptrobj ; + WORD n, info3 ; + UBYTE string[256] ; + UBYTE mess[256] ; + WORD sizetoload ; + WORD indexfile3d ; + +// PtrScene = PtrSce = LoadMalloc_HQR( PATH_RESSOURCE"scene.hqr", numscene ) ; + + HQRM_Load( PATH_RESSOURCE"scene.hqr", numscene, &PtrScene ) ; + CHECK_MEMORY + + PtrSce = PtrScene ; + + if( !PtrSce ) + { + Message( "Scene.Hqr introuvable ou pas assez mem", TRUE ) ; + } + +// info world: INFO_WORLD + + NewCube = numscene ; + + Island = GET_BYTE ; + + GameOverCube = GET_BYTE ; + + n = GET_WORD ; + n = GET_WORD ; + +// ListHoloObj[NUM_PERSO].Alpha = GET_WORD ; +// ListHoloObj[NUM_PERSO].Beta = GET_WORD ; +// ListHoloObj[NUM_PERSO].Size = GET_WORD ; + +// ambiance: AMBIANCE + + AlphaLight = GET_WORD ; + BetaLight = GET_WORD ; + + SampleAmbiance[0] = GET_WORD ; + SampleRepeat[0] = GET_WORD ; + SampleRnd[0] = GET_WORD ; + SampleAmbiance[1] = GET_WORD ; + SampleRepeat[1] = GET_WORD ; + SampleRnd[1] = GET_WORD ; + SampleAmbiance[2] = GET_WORD ; + SampleRepeat[2] = GET_WORD ; + SampleRnd[2] = GET_WORD ; + SampleAmbiance[3] = GET_WORD ; + SampleRepeat[3] = GET_WORD ; + SampleRnd[3] = GET_WORD ; + SecondMin = GET_WORD ; + SecondEcart = GET_WORD ; + + CubeJingle = GET_BYTE ; +// PlayMidiFile( CubeJingle ) ; + +// hero inits: HERO_START + + ptrobj = ListObjet ; + + CubeStartX = GET_WORD ; + CubeStartY = GET_WORD ; + CubeStartZ = GET_WORD ; + + sizetoload = GET_WORD ; + ptrobj->PtrTrack = PtrSce ; + PtrSce += sizetoload ; + + sizetoload = GET_WORD ; + ptrobj->PtrLife = PtrSce ; + PtrSce += sizetoload ; + + ptrobj++ ; + +// objets: OBJECT + + NbObjets = GET_WORD ; + for( n=1; nFlags = GET_WORD ; + + indexfile3d = GET_WORD ; + + if( !(ptrobj->Flags & SPRITE_3D) ) + { + + HQRM_Load( PATH_RESSOURCE"File3D.hqr", indexfile3d, &ptrobj->PtrFile3D ) ; + CHECK_MEMORY + +/* ptrobj->PtrFile3D = + LoadMalloc_HQR( + PATH_RESSOURCE"File3D.hqr", + indexfile3d ) ; +*/ + + } + + ptrobj->GenBody = GET_BYTE ; + ptrobj->GenAnim = GET_BYTE ; +/* +if( n==5 ) +{ + CoulText( 15,0 ) ; + Text( 10, 300, "obj 5 org anim: %d", ptrobj->GenAnim ) ; +} +*/ + + ptrobj->Sprite = GET_WORD ; + + ptrobj->OldPosX = ptrobj->PosObjX = GET_WORD ; + ptrobj->OldPosY = ptrobj->PosObjY = GET_WORD ; + ptrobj->OldPosZ = ptrobj->PosObjZ = GET_WORD ; + ptrobj->HitForce = GET_BYTE ; + ptrobj->OptionFlags = GET_WORD ; + ptrobj->OptionFlags &= ~EXTRA_GIVE_NOTHING ; + ptrobj->Beta = GET_WORD ; + ptrobj->SRot = GET_WORD ; + ptrobj->Move = GET_WORD ; + + ptrobj->Info = GET_WORD ; + ptrobj->Info1 = GET_WORD ; + ptrobj->Info2 = GET_WORD ; + ptrobj->Info3 = GET_WORD ; + + ptrobj->NbBonus = GET_BYTE ; + ptrobj->CoulObj = GET_BYTE ; + ptrobj->Armure = GET_BYTE ; + ptrobj->LifePoint = GET_BYTE ; + + sizetoload = GET_WORD ; + ptrobj->PtrTrack = PtrSce ; + PtrSce = PtrSce + sizetoload ; + + sizetoload = GET_WORD ; + ptrobj->PtrLife = PtrSce ; + PtrSce = PtrSce + sizetoload ; + } + +// zone declechement: ZONE + + NbZones = GET_WORD ; + ListZone = (T_ZONE*)PtrSce ; + PtrSce += NbZones * 12 * 2 ; + +// point track: TRACK + + NbBrickTrack = GET_WORD ; + ListBrickTrack = (T_TRACK*)PtrSce ; + + return TRUE ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßßÜ Ûßßßß ÛßßÛ Û Û Ûßßßß + ÛÛ Û ÛÛßß ÛÛßßÛ ÛÛ Û ÛÛ ßÛ + ßßßß ßßßßß ßßßßß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +/* +void *LoadTestMalloc( char *filename ) +{ + void *ptr ; + UBYTE string[256] ; + + ptr = LoadMalloc( filename ) ; + + if( !ptr ) + { + strcpy( string, "ARG ! Mem:" ) ; + strcat( string, Itoa( (ULONG)Malloc(-1) ) ) ; + strcat( string, " fichier:" ) ; + strcat( string, filename ) ; + + Message( string, TRUE ) ; + } + return ptr ; +} +*/ + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + diff --git a/SOURCES/DISKFUNC.DEF b/SOURCES/DISKFUNC.DEF new file mode 100644 index 0000000..07e2027 --- /dev/null +++ b/SOURCES/DISKFUNC.DEF @@ -0,0 +1,3 @@ +extern void GetDiskEnv(unsigned char *); +extern void RestoreDiskEnv(void); +extern short LoadScene(short ); diff --git a/SOURCES/EXTRA.C b/SOURCES/EXTRA.C new file mode 100644 index 0000000..15ac106 --- /dev/null +++ b/SOURCES/EXTRA.C @@ -0,0 +1,1275 @@ +#include "c_extern.h" + +extern WORD YMap ; + +extern LONG EX0, EY0 ; + +WORD BigStar[] = { 10, /* nb points */ + 0,-20, 4,-6, 19,-6, 7,2, 12,16, + 0,7, -12,16, -7,2, -19,-6, -4,-6 } ; +/* +WORD Star[] = { 10, // nb points + 0,-10, 2,-3, 9,-3, 3,1, 6,8, + 0,3, -6,8, -3,1, -9,-3, -2,-3 } ; +*/ + +WORD Poff[] = { 18, /* nb points */ + 0,-20, 6,-16, 8,-10, 14,-12, 20,-4, + 18,4, 12,4, 16,8, 8,16, 2,12, + -4,18, -10,16, -12,8, -16,10, -20,4, + -12,-8, -6,-6, -10,-12 } ; + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Ûßßßß ßÜ Üß ßßÛßß ÛßßßÛ ÛßßßÛ + ÛÛßß ÜßÜ ÛÛ ÛÛßÛß ÛÛßßÛ + ßßßßß ß ß ßß ßß ß ßß ß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void InitFly( T_EXTRA *ptrextra, WORD alpha, WORD beta, WORD vitesse, WORD poids ) +{ + ptrextra->Flags |= EXTRA_FLY ; + + ptrextra->OrgX = ptrextra->PosX ; + ptrextra->OrgY = ptrextra->PosY ; + ptrextra->OrgZ = ptrextra->PosZ ; + + Rotate( vitesse,0, alpha ) ; + ptrextra->Vy = -Y0 ; + + Rotate( 0, X0, beta ) ; + ptrextra->Vx = X0 ; + ptrextra->Vz = Y0 ; + + ptrextra->Poids = poids ; + + ptrextra->Timer = TimerRef ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void BounceExtra( T_EXTRA *ptrextra, WORD oldx, WORD oldy, WORD oldz ) +{ + WORD vx, vy, vz ; + + vx = ptrextra->Vx ; + vy = ptrextra->Vy ; + vz = ptrextra->Vz ; + + // test under last pos + if( WorldColBrick( oldx, ptrextra->PosY, oldz ) ) + { + ptrextra->Vy = -ptrextra->Vy ; + } + + // test left & right + if( WorldColBrick( ptrextra->PosX, oldy, oldz ) ) + { + ptrextra->Vx = -ptrextra->Vx ; + } + + // test up & down + if( WorldColBrick( oldx, oldy, ptrextra->PosZ ) ) + { + ptrextra->Vz = -ptrextra->Vz ; + } + +/* // recherche last pos ok + do + { + ptrextra->PosX -= vx ; + ptrextra->PosY -= vy ; + ptrextra->PosZ -= vz ; + + } + while( WorldColBrick( ptrextra->PosX, ptrextra->PosY, ptrextra->PosZ ) ) ; + ptrextra->PosY -= *(&PtrZvExtra[ ptrextra->Sprite*8 + 2 ]+3) ; +*/ + + ptrextra->OrgX = ptrextra->PosX = oldx ; + ptrextra->OrgY = ptrextra->PosY = oldy ; + ptrextra->OrgZ = ptrextra->PosZ = oldz ; + + ptrextra->Timer = TimerRef ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +WORD ExtraBonus( WORD x, WORD y, WORD z, + WORD alpha, WORD beta, + WORD num, WORD nb ) +{ + T_EXTRA *ptrextra ; + WORD n ; + + ptrextra = ListExtra ; + + for( n=0; nSprite != -1 ) continue ; + /* slot libre */ + + ptrextra->Sprite = num ; + + ptrextra->Flags = EXTRA_STOP_COL +// + EXTRA_WAIT_NO_COL + + EXTRA_WAIT_SOME_TIME + + EXTRA_TAKABLE ; + + /* Special for Key ( Beurk cause detect with sprite number ! ) */ + + if ( num != 6 ) ptrextra->Flags += EXTRA_TIME_OUT + + EXTRA_FLASH ; + + ptrextra->PosX = x ; + ptrextra->PosY = y ; + ptrextra->PosZ = z ; + +// ESSAI bonus qui coince moins ??? + InitFly( ptrextra, alpha, beta, 40, 15 ) ; +// InitFly( ptrextra, alpha, beta, 40, 16 ) ; + + ptrextra->HitForce = 0 ; + + ptrextra->Timer = TimerRef ; + ptrextra->TimeOut = 50 * 20 ; /* 20 secondes */ + + ptrextra->Divers = nb ; + return n ; + } + return -1 ; +} +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +WORD ExtraExplo( WORD x, WORD y, WORD z ) +{ + T_EXTRA *ptrextra ; + WORD n ; + + ptrextra = ListExtra ; + + for( n=0; nSprite != -1 ) continue ; + /* slot libre */ + + ptrextra->Sprite = 97 ; // explo + + ptrextra->Flags = EXTRA_TIME_OUT + EXTRA_EXPLO ; + + ptrextra->PosX = x ; + ptrextra->PosY = y ; + ptrextra->PosZ = z ; + ptrextra->HitForce = 0 ; + + ptrextra->Timer = TimerRef ; + ptrextra->TimeOut = 40 ; + + return n ; + } + return -1 ; +} +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +WORD SearchBonusKey() +{ + T_EXTRA *ptrextra ; + WORD n ; + + ptrextra = ListExtra ; + for( n=0; nSprite == 6 ) // Key !!!!! + { + return n ; + } + } + return -1 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +WORD ExtraSearch( WORD owner, WORD x, WORD y, WORD z, WORD num, + WORD numobj, WORD speed, WORD hitforce ) +{ + T_EXTRA *ptrextra ; + WORD n ; + + ptrextra = ListExtra ; + + for( n=0; nSprite != -1 ) continue ; + /* slot libre */ + + /* TimeOut: num obj throw + /* WORD Timer: num obj search */ + /* &OrgX = RealValue + (OrgY, OrgZ, Vx, Vy */ + /* Vz = speed */ +/* +{ +UBYTE string[256] ; + +strcpy( string, "ThrowSearch from " ) ; +strcat( string, itoa( owner, " ",10 ) ) ; +Message( string, FALSE ) ; +} +*/ + ptrextra->Sprite = num ; + + ptrextra->Flags = EXTRA_SEARCH_OBJ ; + ptrextra->Divers = 0 ; + + ptrextra->PosX = x ; + ptrextra->PosY = y ; + ptrextra->PosZ = z ; + + ptrextra->TimeOut = owner ; + ptrextra->Timer = (LONG)numobj ; + + ptrextra->Vz = speed ; + ptrextra->HitForce = hitforce ; + + InitRealValue( 0, speed, 50, (T_REAL_VALUE*)&ptrextra->OrgX ) ; + + // memo last angle + ptrextra->Poids = GetAngle( x,z, + ListObjet[numobj].PosObjX, + ListObjet[numobj].PosObjZ ) ; + return n ; + } + return -1 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +WORD ExtraSearchKey( WORD owner, WORD x, WORD y, WORD z, + WORD num, WORD numobj ) +{ + T_EXTRA *ptrextra ; + WORD n ; + + ptrextra = ListExtra ; + + for( n=0; nSprite != -1 ) continue ; + /* slot libre */ + + /* TimeOut: num obj throw + /* WORD Timer: num obj search */ + /* &OrgX = RealValue + (OrgY, OrgZ, Vx, Vy */ + /* Vz = speed */ + + ptrextra->Sprite = num ; + + ptrextra->Flags = EXTRA_SEARCH_KEY ; + ptrextra->Divers = 0 ; + + ptrextra->PosX = x ; + ptrextra->PosY = y ; + ptrextra->PosZ = z ; + + ptrextra->TimeOut = owner ; + ptrextra->Timer = (LONG)numobj ; + + ptrextra->Vz = 4000 ; + ptrextra->HitForce = 0 ; + + InitRealValue( 0, 4000, 50, (T_REAL_VALUE*)&ptrextra->OrgX ) ; + + // memo last angle + ptrextra->Poids = GetAngle( x,z, + ListExtra[numobj].PosX, + ListExtra[numobj].PosZ ) ; + + return n ; + } + return -1 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +WORD ExtraCheckObjCol( T_EXTRA *ptrextra, WORD owner ) +{ + WORD n ; + T_OBJET *ptrobjt ; + WORD xw, yw, zw ; + WORD x0,y0,z0, x1,y1,z1 ; + WORD xt0,yt0,zt0, xt1,yt1,zt1 ; + WORD *ptr ; + + xw = ptrextra->PosX ; + yw = ptrextra->PosY ; + zw = ptrextra->PosZ ; + + ptr = &PtrZvExtra[ ptrextra->Sprite*8 + 2 ] ; + + x0 = *ptr++ + xw ; + x1 = *ptr++ + xw ; + y0 = *ptr++ + yw ; + y1 = *ptr++ + yw ; + z0 = *ptr++ + zw ; + z1 = *ptr++ + zw ; + + ptrobjt = ListObjet ; + + for( n=0; nBody != -1) +// AND (!(ptrobjt->Flags&INVISIBLE)) + AND (n != owner) ) + { + + xt0 = ptrobjt->PosObjX + ptrobjt->Xmin ; + xt1 = ptrobjt->PosObjX + ptrobjt->Xmax ; + yt0 = ptrobjt->PosObjY + ptrobjt->Ymin ; + yt1 = ptrobjt->PosObjY + ptrobjt->Ymax ; + zt0 = ptrobjt->PosObjZ + ptrobjt->Zmin ; + zt1 = ptrobjt->PosObjZ + ptrobjt->Zmax ; + + if( x0 < xt1 + AND x1 > xt0 + AND y0 < yt1 + AND y1 > yt0 + AND z0 < zt1 + AND z1 > zt0 ) + { + if( ptrextra->HitForce != 0 ) + { + HitObj( owner, n, ptrextra->HitForce, -1 ) ; + } + return n ; + } + } + ptrobjt++ ; + } + return -1 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/* +WORD ExtraFullCheckObjCol( T_EXTRA *ptrextra, WORD owner ) +{ + WORD n ; + T_OBJET *ptrobjt ; + WORD xw, yw, zw ; + WORD x0,y0,z0, x1,y1,z1 ; + WORD xt0,yt0,zt0, xt1,yt1,zt1 ; + WORD *ptr ; + + xw = ptrextra->PosX ; + yw = ptrextra->PosY ; + zw = ptrextra->PosZ ; + + ptr = &PtrZvExtra[ ptrextra->Sprite*8 + 2 ] ; + + x0 = *ptr++ + xw ; + x1 = *ptr++ + xw ; + y0 = *ptr++ + yw ; + y1 = *ptr++ + yw ; + z0 = *ptr++ + zw ; + z1 = *ptr++ + zw ; + + ptrobjt = ListObjet ; + + for( n=0; nBody != -1) +// AND (!(ptrobjt->Flags&INVISIBLE)) + AND (n != owner) ) + { + + xt0 = ptrobjt->PosObjX + ptrobjt->Xmin ; + xt1 = ptrobjt->PosObjX + ptrobjt->Xmax ; + yt0 = ptrobjt->PosObjY + ptrobjt->Ymin ; + yt1 = ptrobjt->PosObjY + ptrobjt->Ymax ; + zt0 = ptrobjt->PosObjZ + ptrobjt->Zmin ; + zt1 = ptrobjt->PosObjZ + ptrobjt->Zmax ; + + if( x0 < xt1 + AND x1 > xt0 + AND y0 < yt1 + AND y1 > yt0 + AND z0 < zt1 + AND z1 > zt0 ) + { + if( ptrextra->HitForce != 0 ) + { + HitObj( owner, n, ptrextra->HitForce, -1 ) ; + } + return n ; + } + } + ptrobjt++ ; + } + return -1 ; +} +*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +WORD ExtraCheckExtraCol( T_EXTRA *ptrextra, WORD owner ) +{ + WORD n ; + T_EXTRA *ptrobjt ; + WORD xw, yw, zw ; + WORD xwt, ywt, zwt ; + WORD x0,y0,z0, x1,y1,z1 ; + WORD xt0,yt0,zt0, xt1,yt1,zt1 ; + WORD *ptr ; + + xw = ptrextra->PosX ; + yw = ptrextra->PosY ; + zw = ptrextra->PosZ ; + + ptr = &PtrZvExtra[ ptrextra->Sprite*8 + 2 ] ; + + x0 = *ptr++ + xw ; + x1 = *ptr++ + xw ; + y0 = *ptr++ + yw ; + y1 = *ptr++ + yw ; + z0 = *ptr++ + zw ; + z1 = *ptr++ + zw ; + + ptrobjt = ListExtra ; + + for( n=0; nSprite != -1) + AND (n != owner) ) + { + xwt = ptrobjt->PosX ; + ywt = ptrobjt->PosY ; + zwt = ptrobjt->PosZ ; + + ptr = &PtrZvExtra[ ptrobjt->Sprite*8 + 2 ] ; + + xt0 = *ptr++ + xwt ; + xt1 = *ptr++ + xwt ; + yt0 = *ptr++ + ywt ; + yt1 = *ptr++ + ywt ; + zt0 = *ptr++ + zwt ; + zt1 = *ptr++ + zwt ; + + if( x0 < xt1 + AND x1 > xt0 + AND y0 < yt1 + AND y1 > yt0 + AND z0 < zt1 + AND z1 > zt0 ) + { + return n ; + } + } + ptrobjt++ ; + } + return -1 ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +UBYTE FullWorldColBrick( WORD oldx, WORD oldy, WORD oldz, + WORD newx, WORD newy, WORD newz ) +{ + WORD x0, y0, z0 ; + WORD x1, y1, z1 ; + WORD x2, y2, z2 ; + + if( WorldColBrick( newx,newy,newz ) ) return 1 ; + + x0 = (newx+oldx)/2 ; + y0 = (newy+oldy)/2 ; + z0 = (newz+oldz)/2 ; + + if( WorldColBrick( x0,y0,z0 ) ) return 1 ; + + x1 = (newx+x0)/2 ; + y1 = (newy+y0)/2 ; + z1 = (newz+z0)/2 ; + + if( WorldColBrick( x1,y1,z1 ) ) return 1 ; + + x2 = (x0+oldx)/2 ; + y2 = (y0+oldy)/2 ; + z2 = (z0+oldz)/2 ; + + if( WorldColBrick( x2,y2,z2 ) ) return 1 ; + + return 0 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛÛßßß ÛßßßÛ Ûßßßß Ûßßßß Û ÛßßßÛ Û + ßßßßÛ ÛÛßßß ÛÛßß ÛÛ ÛÛ ÛÛßßÛ ÛÛ + ßßßßß ßß ßßßßß ßßßßß ßß ßß ß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void ClearScreenMinMax() +{ + ScreenXmin = 32000 ; + ScreenXmax = -32000 ; + ScreenYmin = 32000 ; + ScreenYmax = -32000 ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void AdjustScreenMax() +{ + if( Xp < ScreenXmin ) ScreenXmin = Xp ; + if( Xp > ScreenXmax ) ScreenXmax = Xp ; + if( Yp < ScreenYmin ) ScreenYmin = Yp ; + if( Yp > ScreenYmax ) ScreenYmax = Yp ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void Aff2DShape( WORD *ptr, + WORD xs, WORD ys, + WORD coul, WORD angle, WORD zoom ) +{ + WORD x0, y0, x1, y1, x2, y2 ; + WORD x, y, n, nb ; + + ClearScreenMinMax() ; + + nb = *ptr++ ; + + x = (*ptr++) * zoom / 16 ; + y = (*ptr++) * zoom / 16 ; + Rotate( x, y, angle ) ; + Xp = x0 = X0 + xs ; + Yp = y0 = Y0 + ys ; + AdjustScreenMax() ; + + for( n=1; nSprite & 32767 ) + { + case 0: // hit star + Aff2DShape( BigStar, xs, ys, + 15, (WORD)((TimerRef<<5) & 1023), 4 ) ; + break ; + + case 1: // impact + zoom = 1+(WORD)(TimerRef - ptrextra->Timer) ; + if( zoom > 32 ) zoom = 32 ; // peut etre moins + Aff2DShape( Poff, xs, ys, + 15, 0, zoom ) ; + break ; + + case 2: // fontaine + break ; + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void InitSpecial( WORD x, WORD y, WORD z, WORD num ) +{ + T_EXTRA *ptrextra ; + WORD n ; + + ptrextra = ListExtra ; + + for( n=0; nSprite != -1 ) continue ; + /* slot libre */ + + ptrextra->Sprite = num + 32768 ; + + ptrextra->Divers = 0 ; + + /* star */ + switch( num ) + { + case 0: /* small star */ + + ptrextra->Flags = EXTRA_TIME_OUT + + EXTRA_END_COL ; + + ptrextra->PosX = x ; + ptrextra->PosY = y ; + ptrextra->PosZ = z ; + + InitFly( ptrextra, Rnd(256)+128, Rnd(1024), 50, 20 ) ; + + ptrextra->HitForce = 0 ; + + ptrextra->Timer = TimerRef ; + ptrextra->TimeOut = 50 * 2 ; /* 2 secondes */ + + return ; + + case 1: /* impact */ + + ptrextra->Flags = EXTRA_TIME_OUT ; + + ptrextra->PosX = x ; + ptrextra->PosY = y ; + ptrextra->PosZ = z ; + + ptrextra->HitForce = 0 ; + + ptrextra->Timer = TimerRef ; + ptrextra->TimeOut = 5 ; + + return ; + + } + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +LONG CoulRetourBalle( T_EXTRA *ptrextra ) +{ + LONG sprite = 44 ; // jaune ou feu + + if( ptrextra->Sprite == 42 ) sprite = 109 ; // vert + if( ptrextra->Sprite == 43 ) sprite = 110 ; // rouge + + return sprite ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Ûßßßß ÛßßßÛ ÛÜ ÜÛ Ûßßßß Ûßßßß ÛßßßÛ Û Û ÛÛßßß + ÛÛ ßÛ ÛÛßßÛ ÛÛß Û ÛÛßß ÛÛ ÛÛßßÛ ÛÛ ÛÛ ßßßßÛ + ßßßßß ßß ß ßß ß ßßßßß ßßßßß ßßßßß ßß ß ßßßßß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void ClearExtra() +{ + WORD n ; + + for( n=0; nSprite != -1 ) continue ; /* slot libre */ + + ptrextra->Sprite = num ; + + ptrextra->Flags = EXTRA_END_OBJ + + EXTRA_END_COL + + EXTRA_WAIT_NO_COL + + EXTRA_IMPACT ; + + ptrextra->PosX = x ; + ptrextra->PosY = y ; + ptrextra->PosZ = z ; + + InitFly( ptrextra, alpha, beta, vitesse, poids ) ; + + ptrextra->HitForce = hitforce ; + + ptrextra->TimeOut = owner ; + + ptrextra->Timer = TimerRef ; + + ptrextra->Divers = 0 ; + + return n ; + } + return -1 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void GiveExtraBonus( T_OBJET *ptrobj ) +{ + WORD n, m ; + UBYTE tabbonus[5] ; + + m = 0 ; + for( n=0; n<5; n++ ) + { + if( ptrobj->OptionFlags & (1<<(n+4)) ) + { + tabbonus[m] = n ; + m++ ; + } + } + + if( !m ) return ; + + n = tabbonus[ Rnd( m ) ] ; + + if( (MagicLevel == 0) AND (n==2) ) n = 1 ; // si pas magie -> coeur + + if( ptrobj->WorkFlags & OBJ_DEAD ) // obj mort + { + ExtraBonus( ptrobj->PosObjX, + ptrobj->PosObjY, + ptrobj->PosObjZ, + 256, 0, + n + 3, /* 3 offset spr bonus */ + ptrobj->NbBonus ) ; + + HQ_3D_MixSample( 11, 0x1000, 1, + ptrobj->PosObjX, ptrobj->PosObjY, ptrobj->PosObjZ ) ; + + } + else // obj vivant + { + ExtraBonus( ptrobj->PosObjX, + ptrobj->PosObjY+ptrobj->Ymax, + ptrobj->PosObjZ, + 200, + GetAngle( ptrobj->PosObjX, + ptrobj->PosObjZ, + ListObjet[NUM_PERSO].PosObjX, + ListObjet[NUM_PERSO].PosObjZ ) , + n + 3, /* 3 offset spr bonus */ + ptrobj->NbBonus ) ; + + HQ_3D_MixSample( 11, 0x1000, 1, + ptrobj->PosObjX, ptrobj->PosObjY+ptrobj->Ymax, ptrobj->PosObjZ ) ; + + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void ZoneGiveExtraBonus( T_ZONE *ptrz ) +{ + WORD n, m, x,y,z, p ; + UBYTE tabbonus[5] ; + + if( ptrz->Info2 ) return ; /* d‚j… pris */ + + m = 0 ; + for( n=0; n<5; n++ ) + { + if( ptrz->Info0 & (1<<(n+4)) ) + { + tabbonus[m] = n ; + m++ ; + } + } + + if( !m ) return ; + + n = tabbonus[ Rnd( m ) ] ; + + if( (MagicLevel == 0) AND (n==2) ) n = 1 ; // si pas magie -> coeur + + x = (ptrz->X0+ptrz->X1)/2 ; + z = (ptrz->Z0+ptrz->Z1)/2 ; + + p = ExtraBonus( x, ptrz->Y1, z, + 180, + GetAngle( x, z, + ListObjet[NUM_PERSO].PosObjX, + ListObjet[NUM_PERSO].PosObjZ ) , + n + 3, /* 3 offset spr bonus */ + ptrz->Info1 ) ; /* nb */ + + if( p != -1 ) + { + ListExtra[p].Flags |= EXTRA_TIME_IN ; + ptrz->Info2 = 1 ; /* marque prise */ + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void GereExtras() +{ + T_EXTRA *ptrextra ; + WORD n ; + WORD oldx, oldy, oldz ; + LONG time ; + WORD *ptr ; + WORD alpha, beta, angle, s, owner, search ; + LONG flagcol ; + + ptrextra = ListExtra ; + + for( n=0; nSprite == -1 ) continue ; + + if( ptrextra->Flags & EXTRA_TIME_OUT ) + { + if( TimerRef >= ptrextra->Timer + ptrextra->TimeOut ) + { + /* bye bye */ + ptrextra->Sprite = -1 ; + continue ; + } + } + + if( ptrextra->Flags & EXTRA_ONE_FRAME ) + { + ptrextra->Sprite = -1 ; + continue ; + } + + if( ptrextra->Flags & EXTRA_EXPLO ) + { + ptrextra->Sprite = BoundRegleTrois( 97,100,30,TimerRef - ptrextra->Timer ) ; + continue ; + } + + if( ptrextra->Flags & EXTRA_FLY ) + { + time = TimerRef - ptrextra->Timer ; + + oldx = ptrextra->PosX ; + oldy = ptrextra->PosY ; + oldz = ptrextra->PosZ ; + + ptrextra->PosX = ptrextra->Vx*time + ptrextra->OrgX ; + ptrextra->PosY = ptrextra->Vy*time + + ptrextra->OrgY + - (ptrextra->Poids*time*time)/16 ; + ptrextra->PosZ = ptrextra->Vz*time + ptrextra->OrgZ ; + + /* securite */ + if( (ptrextra->PosY < 0) + OR (ptrextra->PosX < 0) + OR (ptrextra->PosX > SIZE_BRICK_XZ * (SIZE_CUBE_X-1)) + OR (ptrextra->PosZ < 0) + OR (ptrextra->PosZ > SIZE_BRICK_XZ * (SIZE_CUBE_Z-1)) ) + { + if( n == MagicBall ) + { + /* init retour balle */ + MagicBall = ExtraSearch( -1,ptrextra->PosX,ptrextra->PosY,ptrextra->PosZ, + CoulRetourBalle( ptrextra ), + NUM_PERSO, 10000, 0 ) ; + } + if( ptrextra->Flags & EXTRA_TAKABLE ) + { + ptrextra->Flags &= ~(EXTRA_FLY+EXTRA_STOP_COL) ; + } + else + { + ptrextra->Sprite = -1 ; + } + continue ; + } + } + + if( ptrextra->Flags & EXTRA_WAIT_SOME_TIME ) + { + if( (TimerRef - ptrextra->Timer) > 40 ) + { + ptrextra->Flags &= ~EXTRA_WAIT_SOME_TIME ; + } + continue ; + } + + if( ptrextra->Flags & EXTRA_SEARCH_OBJ ) + { + /* TimeOut: owner */ + /* (WORD)Timer: numobj search */ + /* &OrgX = RealValue + (OrgY, OrgZ, Vx, Vy */ + /* Vz = speed */ + /* Poids = last angle beta */ + + search = (WORD)ptrextra->Timer ; + owner = ptrextra->TimeOut ; + + oldx = ListObjet[search].PosObjX ; + oldy = ListObjet[search].PosObjY+1000 ; + oldz = ListObjet[search].PosObjZ ; + + beta = GetAngle( ptrextra->PosX, + ptrextra->PosZ, + oldx, oldz ) ; + + angle = (beta - ptrextra->Poids)&1023 ; + if( (angle < 600) AND (angle > 400) ) + { + // si angle retourn‚ obj consid‚r‚ comme touch‚ + if( ptrextra->HitForce != 0 ) + { + HitObj( owner, search, ptrextra->HitForce, -1 ) ; + } + if( n == MagicBall ) + { + MagicBall = -1 ; + } + /* bye bye */ + ptrextra->Sprite = -1 ; + continue ; + } + + alpha = GetAngle( ptrextra->PosY,0, + oldy,Distance ) ; + + s = GetRealValue( (T_REAL_VALUE*)&ptrextra->OrgX ) ; + if( !s ) s = 1 ; + /* s = vitesse (distance/temps) */ + + Rotate( s,0, alpha ) ; + ptrextra->PosY -= Y0 ; + Rotate( 0, X0, beta ) ; + ptrextra->PosX += X0 ; + ptrextra->PosZ += Y0 ; + + InitRealValue( 0, ptrextra->Vz, + 50, (T_REAL_VALUE*)&ptrextra->OrgX ) ; + +// if( ExtraFullCheckObjCol( ptrextra, owner ) == search ) + if( ExtraCheckObjCol( ptrextra, owner ) == search ) + { + if( n == MagicBall ) + { + MagicBall = -1 ; + } + /* bye bye */ + ptrextra->Sprite = -1 ; + continue ; + } + } + + if( ptrextra->Flags & EXTRA_SEARCH_KEY )// QUE magic ball ONLY + { + /* TimeOut: owner */ + /* (WORD)Timer: numobj search */ + /* &OrgX = RealValue + (OrgY, OrgZ, Vx, Vy */ + /* Vz = speed */ + + search = (WORD)ptrextra->Timer ; + owner = ptrextra->TimeOut ; + + oldx = ListExtra[search].PosX ; + oldy = ListExtra[search].PosY ; + oldz = ListExtra[search].PosZ ; + + beta = GetAngle( ptrextra->PosX, + ptrextra->PosZ, + oldx, oldz ) ; + + angle = (beta - ptrextra->Poids)&1023 ; + if( (angle < 600) AND (angle > 400) ) + { + goto key_found ; + } + + alpha = GetAngle( ptrextra->PosY,0, + oldy,Distance ) ; + + s = GetRealValue( (T_REAL_VALUE*)&ptrextra->OrgX ) ; + if( !s ) s = 1 ; + /* s = vitesse (distance/temps) */ + + Rotate( s,0, alpha ) ; + ptrextra->PosY -= Y0 ; + Rotate( 0, X0, beta ) ; + ptrextra->PosX += X0 ; + ptrextra->PosZ += Y0 ; + + InitRealValue( 0, ptrextra->Vz, + 50, (T_REAL_VALUE*)&ptrextra->OrgX ) ; + + if( ExtraCheckExtraCol( ptrextra, MagicBall ) == search ) + { +key_found: + // trouve clef + HQ_3D_MixSample( 97, 0x1000, 1, + ptrextra->PosX, ptrextra->PosY, ptrextra->PosZ ) ; + + // incruste pendant 2 sec le bonus trouve + if( ListExtra[search].Divers > 1 ) + { + ProjettePoint( ptrextra->PosX-WorldXCube, ptrextra->PosY-WorldYCube, ptrextra->PosZ-WorldZCube ) ; + InitIncrustDisp( INCRUST_NUM, + ListExtra[search].Divers, + Xp, Yp, + 158, 0, 2 ) ; + } + InitIncrustDisp( INCRUST_SPRITE, + 6, // key + 10, 30, + 0, 0, 2 ) ; + + NbLittleKeys += ListExtra[search].Divers ; + ListExtra[search].Sprite = -1 ; + + // init retour balle + MagicBall = ExtraSearch(-1,ptrextra->PosX,ptrextra->PosY,ptrextra->PosZ, + 6, // key + NUM_PERSO, 8000, 0 ) ; + ptrextra->Sprite = -1 ; + continue ; + } + + if( ListExtra[search].Sprite == -1 ) // clef prise entre temps + { + // init retour balle + MagicBall = ExtraSearch(-1,ptrextra->PosX,ptrextra->PosY,ptrextra->PosZ, + CoulRetourBalle( ptrextra ), + NUM_PERSO, 8000, 0 ) ; + ptrextra->Sprite = -1 ; + continue ; + } + } + + if( ptrextra->Flags & EXTRA_END_OBJ ) /* hit force */ + { + if( ExtraCheckObjCol( ptrextra, ptrextra->TimeOut/*owner*/ ) != -1 ) + { + if( n == MagicBall ) + { + // sample choc balle sur obj ? + + /* init retour balle */ + MagicBall = ExtraSearch( -1,ptrextra->PosX,ptrextra->PosY,ptrextra->PosZ, + CoulRetourBalle( ptrextra ), + NUM_PERSO, 10000, 0 ) ; + } + /* bye bye */ + ptrextra->Sprite = -1 ; + continue ; + } + } + + if( ptrextra->Flags & EXTRA_END_COL ) + { + + flagcol = FALSE ; + if( FullWorldColBrick( oldx, + oldy, + oldz, + ptrextra->PosX, + ptrextra->PosY, + ptrextra->PosZ ) ) + { + if( !(ptrextra->Flags & EXTRA_WAIT_NO_COL) ) + { + flagcol = TRUE ; + } + } + else + { + if( ptrextra->Flags & EXTRA_WAIT_NO_COL ) + { + ptrextra->Flags &= ~EXTRA_WAIT_NO_COL ; + } + } + + if( flagcol ) +// if( WorldColBrick( ptrextra->PosX,ptrextra->PosY,ptrextra->PosZ ) ) + { + if( ptrextra->Flags & EXTRA_IMPACT ) + { + // impact + InitSpecial( oldx,oldy,oldz, 1 ) ; + } + if( n == MagicBall ) + { + // sample rebond retour balle + HQ_3D_MixSample( 86, 0x1000+Rnd(300)-150, 1, + ptrextra->PosX, ptrextra->PosY, ptrextra->PosZ ) ; + + switch( MagicBallType ) + { + case 0: + // init retour balle + MagicBall = ExtraSearch(-1,ptrextra->PosX,ptrextra->PosY,ptrextra->PosZ, + CoulRetourBalle( ptrextra ), + NUM_PERSO, 10000, 0 ) ; + ptrextra->Sprite = -1 ; + continue ; + break ; + + case 1: + if( !MagicBallCount-- ) + { + // init retour balle + MagicBall = ExtraSearch(-1,ptrextra->PosX,ptrextra->PosY,ptrextra->PosZ, + CoulRetourBalle( ptrextra ), + NUM_PERSO, 10000, 0 ) ; + ptrextra->Sprite = -1 ; + continue ; + } + else + { + // forcement pass‚ par EXTRA_FLY + BounceExtra( ptrextra, oldx, oldy, oldz ) ; + } + break ; + } + } + else // pas magic ball + { + // bye bye + ptrextra->Sprite = -1 ; + continue ; + } + } + } + + if( ptrextra->Flags & EXTRA_STOP_COL ) + { + flagcol = FALSE ; + if( FullWorldColBrick( oldx, + oldy, + oldz, + ptrextra->PosX, + ptrextra->PosY, + ptrextra->PosZ ) ) + { + if( !(ptrextra->Flags & EXTRA_WAIT_NO_COL) ) + { +//Message( "bloque", FALSE ) ; + flagcol = TRUE ; + } + } + else + { + if( ptrextra->Flags & EXTRA_WAIT_NO_COL ) + { +/* +Message( "supprime flag", FALSE ) ; +Text( 0, 0, "%Foldx:%d oldy:%d oldz:%d ", oldx, oldy, oldz ) ; +Text( 0, 9, "%Fnewx:%d newy:%d newz:%d ", ptrextra->PosX, ptrextra->PosY, ptrextra->PosZ ) ; +Text( 0,18, "%Forgx:%d orgy:%d orgz:%d ", ptrextra->OrgX, ptrextra->OrgY, ptrextra->OrgZ ) ; +*/ + ptrextra->Flags &= ~EXTRA_WAIT_NO_COL ; + } + } + + if( flagcol ) + { + ptr = &PtrZvExtra[ ptrextra->Sprite*8 + 2 ] ; + ptr+=2 ; + ptrextra->PosY = YMap * SIZE_BRICK_Y + SIZE_BRICK_Y - *ptr ; + ptrextra->Flags &= ~(EXTRA_FLY+EXTRA_STOP_COL) ; + continue ; + } + } + + if( ptrextra->Flags & EXTRA_TAKABLE ) + { + if( !(ptrextra->Flags & EXTRA_FLY) ) /* no take while flying */ + { + if( ExtraCheckObjCol( ptrextra, -1 ) == NUM_PERSO ) + { + HQ_3D_MixSample( 97, 0x1000, 1, + ptrextra->PosX, ptrextra->PosY, ptrextra->PosZ ) ; + + // incruste pendant 2 sec le bonus trouve + if( ptrextra->Divers > 1 ) + { + ProjettePoint( ptrextra->PosX-WorldXCube, ptrextra->PosY-WorldYCube, ptrextra->PosZ-WorldZCube ) ; + InitIncrustDisp( INCRUST_NUM, + ptrextra->Divers, + Xp, Yp, + 158, 0, 2 ) ; + } + InitIncrustDisp( INCRUST_SPRITE, + ptrextra->Sprite, + 10, 30, + 0, 0, 2 ) ; + + /* give money/life/magic/key/clover to perso */ + + if( ptrextra->Sprite == 3 ) /* Money */ + { + NbGoldPieces += ptrextra->Divers ; + if( NbGoldPieces > 999 ) + NbGoldPieces = 999 ; + } + + + if( ptrextra->Sprite == 4 ) /* Life points */ + { + ListObjet[NUM_PERSO].LifePoint += ptrextra->Divers ; + if( ListObjet[NUM_PERSO].LifePoint > 50 ) + { + ListObjet[NUM_PERSO].LifePoint = 50 ; + } + } + + if( ptrextra->Sprite == 5 ) /* Magic points */ + { + if( MagicLevel ) // … voir ? + { + MagicPoint += ptrextra->Divers*2 ; + if( MagicPoint > (MagicLevel*20) ) + MagicPoint = (MagicLevel*20) ; + } + } + + if( ptrextra->Sprite == 6 ) /* Little Key */ + NbLittleKeys += ptrextra->Divers ; + + if( ptrextra->Sprite == 7 ) /* four leaf clover */ + { + NbFourLeafClover += ptrextra->Divers ; + + if( NbFourLeafClover > NbCloverBox ) + { + NbFourLeafClover = NbCloverBox ; + } + } + + /* bye bye */ + ptrextra->Sprite = -1 ; + continue ; + } + } + } + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ diff --git a/SOURCES/EXTRA.DEF b/SOURCES/EXTRA.DEF new file mode 100644 index 0000000..0e45824 --- /dev/null +++ b/SOURCES/EXTRA.DEF @@ -0,0 +1,21 @@ +extern void InitFly(T_EXTRA *,short ,short ,short ,short ); +extern void BounceExtra(T_EXTRA *,short ,short ,short ); +extern short ExtraBonus(short ,short ,short ,short ,short ,short ,short ); +extern short ExtraExplo(short ,short ,short ); +extern short SearchBonusKey(void); +extern short ExtraSearch(short ,short ,short ,short ,short ,short ,short ,short ); +extern short ExtraSearchKey(short ,short ,short ,short ,short ,short ); +extern short ExtraCheckObjCol(T_EXTRA *,short ); +extern short ExtraCheckExtraCol(T_EXTRA *,short ); +extern unsigned char FullWorldColBrick(short ,short ,short ,short ,short ,short ); +extern void ClearScreenMinMax(void); +extern void AdjustScreenMax(void); +extern void Aff2DShape(short *,short ,short ,short ,short ,short ); +extern void AffSpecial(short ,short ,short ); +extern void InitSpecial(short ,short ,short ,short ); +extern long CoulRetourBalle(T_EXTRA *); +extern void ClearExtra(void); +extern short ThrowExtra(short ,short ,short ,short ,short ,short ,short ,short ,short ,short ); +extern void GiveExtraBonus(T_OBJET *); +extern void ZoneGiveExtraBonus(T_ZONE *); +extern void GereExtras(void); diff --git a/SOURCES/FICHE.C b/SOURCES/FICHE.C new file mode 100644 index 0000000..58a9bb9 --- /dev/null +++ b/SOURCES/FICHE.C @@ -0,0 +1,689 @@ +#include "c_extern.h" +#include + +#ifdef COMPILATOR +extern UBYTE *PtrCompil ; +extern WORD FlagCompilator ; +#endif + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛÛßßß Ûßßßß ÛßßßÛ Û ÛßßßÛ ßßÛßß + ßßßßÛ ÛÛ ÛÛßÛß ÛÛ ÛÛßßß ÛÛ + ßßßßß ßßßßß ßß ß ßß ßß ßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +WORD SearchBonusKey() ; + +UBYTE *SearchPtrAnimAction ; + +WORD M_Xmin = -32000 ; +WORD M_Xmax, M_Ymin, M_Ymax, M_Zmin, M_Zmax ; + +UBYTE MagicHitForce[] = { 2, 3, 4, 6, 8 } ; + +#define BASE_STEP_SOUND 126 + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void ThrowMagicBall( WORD x, WORD y, WORD z, + WORD alpha, WORD beta, + WORD vitesse, UBYTE poids ) +{ + UBYTE sprite ; + UBYTE force ; + WORD search ; + + /* ici on determine le type de tir et la force */ + + switch( MagicLevel ) + { + case 0: + case 1: + sprite = 1 ; + force = 4 ; + break ; + + case 2: + sprite = 42 ; + force = 6 ; + break ; + + case 3: + sprite = 43 ; + force = 8 ; + break ; + + case 4: + sprite = 13 ; + force = 10 ; + break ; + } + + MagicBallType = ((MagicPoint-1) / 20) + 1 ; + if( MagicPoint == 0 ) MagicBallType = 0 ; + + // si clef trouv‚e + if( (search = SearchBonusKey()) != -1 ) + { + MagicBallType = 5 ; + } + + switch( MagicBallType ) + { + case 0: // balle normale directe + MagicBall = + ThrowExtra( NUM_PERSO, x,y,z, + sprite, + alpha, beta, + vitesse, poids, + force ) ; + break ; + + case 1: // balle qui rebondit + MagicBallCount = 4 ; + MagicBall = + ThrowExtra( NUM_PERSO, x,y,z, + sprite, + alpha, beta, + vitesse, poids, + force ) ; + break ; + + case 2: // balle qui rebondit + MagicBallType = 1 ; + MagicBallCount = 4 ; + MagicBall = + ThrowExtra( NUM_PERSO, x,y,z, + sprite, + alpha, beta, + vitesse, poids, + force ) ; + break ; + + case 3: // balle qui rebondit + MagicBallType = 1 ; + MagicBallCount = 4 ; + MagicBall = + ThrowExtra( NUM_PERSO, x,y,z, + sprite, + alpha, beta, + vitesse, poids, + force ) ; + break ; + + case 4: // balle qui rebondit + MagicBallType = 1 ; + MagicBallCount = 4 ; + MagicBall = + ThrowExtra( NUM_PERSO, x,y,z, + sprite, + alpha, beta, + vitesse, poids, + force ) ; + break ; + + case 5: // cherche Key + MagicBall = ExtraSearchKey( NUM_PERSO, x,y,z, + sprite, search ) ; + break ; + } + + // la balle magique coute 1 point de magie + if( MagicPoint > 0 ) MagicPoint-- ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +/*----------------------------------------------------------------------*/ +/* recherche des options d'anims */ + +#define GET_BYTE (*ptrc++) +#define GET_WORD (*(WORD*)ptrc) ; ptrc+=2 + +void GereAnimAction( T_OBJET *ptrobj, WORD numobj ) +{ + WORD sample ; + WORD decal ; + WORD anim ; + WORD point, x,y,z ; + WORD sprite ; + WORD alpha ; + WORD beta ; + WORD vitesse ; + WORD poids ; + WORD force ; + WORD repeat ; + WORD search ; + WORD dist ; + WORD balltype ; + UBYTE *ptrc ; + WORD n, nb ; + + anim = ptrobj->Anim ; + + ptrc = ptrobj->PtrAnimAction ; + + nb = *ptrc++ ; + for( n=0; nFrame == *ptrc++ - 1 ) + { + ptrobj->HitForce = GET_BYTE ; + ptrobj->WorkFlags |= OK_HIT ; + } + else ptrc++ ; + break ; + + case 6: /* sample */ + +// Message( "Sample Action", FALSE ) ; + + if( ptrobj->Frame == *ptrc++ ) + { + HQ_3D_MixSample( *(WORD*)ptrc, 0x1000, 1, + ptrobj->PosObjX, ptrobj->PosObjY, ptrobj->PosObjZ ) ; + } + ptrc += 2 ; + break ; + + case 7: /* sample_rnd */ + if( ptrobj->Frame == *ptrc++ ) + { + sample = GET_WORD ; + decal = GET_WORD ; + HQ_3D_MixSample( sample, 0x1000+Rnd(decal)-(decal/2), 1, + ptrobj->PosObjX, ptrobj->PosObjY, ptrobj->PosObjZ ) ; + } + else ptrc += 4 ; + break ; + + case 8: /* throw */ + + + + if( ptrobj->Frame == *ptrc++ ) + { + point = GET_WORD ; + sprite = GET_BYTE ; + alpha = GET_WORD ; + beta = ptrobj->Beta + GET_WORD ; + vitesse = GET_WORD ; + poids = GET_BYTE ; + force = GET_BYTE ; + + ThrowExtra( numobj, + ptrobj->PosObjX,ptrobj->PosObjY+point,ptrobj->PosObjZ, + sprite, + alpha, beta, vitesse, poids, + force ) ; + } + else ptrc += 11 ; + break ; + + case 9: /* throw_magic */ + if( MagicBall == -1 ) // pas de balle en cours + { + + if( ptrobj->Frame == *ptrc++ ) // frame ok ? + { + point = GET_WORD ; + alpha = GET_WORD ; + vitesse = GET_WORD ; + poids = GET_BYTE ; + + ThrowMagicBall( ptrobj->PosObjX, + ptrobj->PosObjY + point, + ptrobj->PosObjZ, + alpha, + ptrobj->Beta, + vitesse, + poids ) ; + } + else ptrc += 7 ; + + } + else ptrc += 8 ; + + break ; + + case 10: /* sample_repeat */ + if( ptrobj->Frame == *ptrc++ ) + { + sample = GET_WORD ; + repeat = GET_WORD ; + HQ_3D_MixSample( sample, 0x1000, repeat, + ptrobj->PosObjX, ptrobj->PosObjY, ptrobj->PosObjZ ) ; + } + else ptrc += 4 ; + break ; + + case 11: /* throw_search */ + if( ptrobj->Frame == *ptrc++ ) + { + point = GET_WORD ; + sprite = GET_BYTE ; + search = GET_BYTE ; + vitesse = GET_WORD ; + force = GET_BYTE ; + + ExtraSearch( numobj, ptrobj->PosObjX,ptrobj->PosObjY+point,ptrobj->PosObjZ, + sprite, + search, vitesse, force ) ; + } + else ptrc += 6 ; + break ; + + case 12: /* throw_alpha */ + if( ptrobj->Frame == *ptrc++ ) + { + dist = Distance2D(ptrobj->PosObjX, + ptrobj->PosObjZ, + ListObjet[NUM_PERSO].PosObjX, + ListObjet[NUM_PERSO].PosObjZ ) ; + + alpha = GetAngle(ptrobj->PosObjY,0, + ListObjet[NUM_PERSO].PosObjY, + dist ) ; + + point = GET_WORD ; + sprite = GET_BYTE ; + alpha += GET_WORD ; + beta = ptrobj->Beta + GET_WORD ; + vitesse = GET_WORD ; + poids = GET_BYTE ; + force = GET_BYTE ; + + ThrowExtra( numobj, + ptrobj->PosObjX,ptrobj->PosObjY+point,ptrobj->PosObjZ, + sprite, + alpha, beta, vitesse, poids, + force ) ; + } + else ptrc += 11 ; + break ; + + case 13: /* sample_stop */ + + if( ptrobj->Frame == *ptrc++ ) + { + sample = GET_WORD ; + HQ_StopOneSample( sample ) ; + } + else ptrc += 2 ; + break ; + + case 15: // left_step + if( ptrobj->Frame == *ptrc++ ) /* frame */ + { +/* sample = WorldCodeBrick( ptrobj->PosObjX, + ptrobj->PosObjY-1, + ptrobj->PosObjZ ) ; +*/ + sample = ptrobj->CodeJeu ; + + if( sample != 0xF0 ) // rien + { + + if( (sample & 0xF0) == 0xF0 ) // code jeu + { + } + else + { + HQ_3D_MixSample( (sample>>4) + BASE_STEP_SOUND, + 0x1000+Rnd(1000)-500, + 1, + ptrobj->PosObjX, ptrobj->PosObjY, ptrobj->PosObjZ ) ; + } + } + } + break ; + + case 16: // right_step + if( ptrobj->Frame == *ptrc++ ) + { +/* sample = WorldCodeBrick( ptrobj->PosObjX, + ptrobj->PosObjY-1, + ptrobj->PosObjZ ) ; +*/ + sample = ptrobj->CodeJeu ; + + if( sample != 0xF0 ) // rien + { + if( (sample & 0xF0) == 0xF0 ) // code jeu + { + } + else + { + HQ_3D_MixSample( + (sample&0x0F) + BASE_STEP_SOUND + 15, + 0x1000+Rnd(1000)-500, + 1, + ptrobj->PosObjX, ptrobj->PosObjY, ptrobj->PosObjZ ) ; + } + } + } + break ; + + case 17: /* hit_twinkel */ + if( ptrobj->Frame == *ptrc++ - 1 ) + { + ptrobj->HitForce = MagicHitForce[ MagicLevel ] ; + ptrobj->WorkFlags |= OK_HIT ; + + } + break ; + + case 18: /* throw_3D */ + if( ptrobj->Frame == *ptrc++ ) + { + x = GET_WORD ; + y = GET_WORD ; + z = GET_WORD ; + + Rotate( x,z, ptrobj->Beta ) ; + + x = X0 + ptrobj->PosObjX ; + y += ptrobj->PosObjY ; + z = Y0 + ptrobj->PosObjZ ; + + sprite = GET_BYTE ; + alpha = GET_WORD ; + beta = ptrobj->Beta + GET_WORD ; + vitesse = GET_WORD ; + poids = GET_BYTE ; + force = GET_BYTE ; + + ThrowExtra( numobj, + x,y,z, + sprite, + alpha, beta, vitesse, poids, + force ) ; + } + else ptrc += 15 ; + break ; + + case 19: /* throw_3D_alpha */ + if( ptrobj->Frame == *ptrc++ ) + { + dist = Distance2D(ptrobj->PosObjX, + ptrobj->PosObjZ, + ListObjet[NUM_PERSO].PosObjX, + ListObjet[NUM_PERSO].PosObjZ ) ; + + alpha = GetAngle(ptrobj->PosObjY,0, + ListObjet[NUM_PERSO].PosObjY, + dist ) ; + + x = GET_WORD ; + y = GET_WORD ; + z = GET_WORD ; + + Rotate( x,z, ptrobj->Beta ) ; + + x = X0 + ptrobj->PosObjX ; + y += ptrobj->PosObjY ; + z = Y0 + ptrobj->PosObjZ ; + + sprite = GET_BYTE ; + alpha += GET_WORD ; + beta = ptrobj->Beta + GET_WORD ; + vitesse = GET_WORD ; + poids = GET_BYTE ; + force = GET_BYTE ; + + ThrowExtra( numobj, + x,y,z, + sprite, + alpha, beta, vitesse, poids, + force ) ; + } + else ptrc += 15 ; + break ; + + case 20: /* throw_3D_search */ + if( ptrobj->Frame == *ptrc++ ) + { + x = GET_WORD ; + y = GET_WORD ; + z = GET_WORD ; + + Rotate( x,z, ptrobj->Beta ) ; + + x = X0 + ptrobj->PosObjX ; + y += ptrobj->PosObjY ; + z = Y0 + ptrobj->PosObjZ ; + + sprite = GET_BYTE ; + search = GET_BYTE ; + vitesse = GET_WORD ; + force = GET_BYTE ; + + ExtraSearch( numobj, + x,y,z, + sprite, + search, vitesse, force ) ; + } + else ptrc += 11 ; + break ; + + case 21: /* throw_3D_magic */ + if( MagicBall == -1 ) // pas de balle en cours + { + + if( ptrobj->Frame == *ptrc++ ) + { + x = GET_WORD ; + y = GET_WORD ; + z = GET_WORD ; + + Rotate( x,z, ptrobj->Beta ) ; + + x = X0 + ptrobj->PosObjX ; + y += ptrobj->PosObjY ; + z = Y0 + ptrobj->PosObjZ ; + + alpha = GET_WORD ; + vitesse = GET_WORD ; + poids = GET_BYTE ; + + ThrowMagicBall( x,y,z, + alpha, + ptrobj->Beta, + vitesse, + poids ) ; + } + else ptrc += 11 ; + + } + else ptrc += 12 ; + + break ; + + default: + return ; + } + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +WORD SearchAnim( UBYTE numanim, WORD numobj ) +{ + UBYTE command ; + T_OBJET *ptrobj ; + WORD hqranim ; + UBYTE *ptrc ; + UBYTE numgene ; + + ptrobj = &ListObjet[numobj] ; + ptrc = ptrobj->PtrFile3D ; + + SearchPtrAnimAction = 0 ; + + while( (command = *ptrc++) != 255 ) + { + switch( command ) + { + case 3: /* ANIM */ + numgene = *ptrc++ ; // lit num name generique + + if( numanim == numgene ) // ok trouve + { + ptrc++ ; // saute size anim + + hqranim = *(WORD*)ptrc ; + +/*if( numobj==2) +{ +CoulText( 15, 0 ) ; +Text( 10,110, "%FSearchAnim GenAnim:%d HqrAnim:%d ", numanim, hqranim ) ; +}*/ + + + ptrc += 2 ; + + if( *ptrc++ ) // anim possede action ? + { + SearchPtrAnimAction = ptrc-1 ; + } + + return hqranim ; + } + else + { + ptrc += *ptrc ; // next anim + } + break ; + default: + ptrc++ ; // gen + ptrc += *ptrc ; + } + } + return -1 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +WORD SearchBody( UBYTE numbody, WORD numobj ) +{ + UBYTE command ; + T_OBJET *ptrobj ; + UWORD hqrbody ; + UBYTE *ptrc ; + UBYTE numgene ; + + ptrobj = &ListObjet[numobj] ; + ptrc = ptrobj->PtrFile3D ; + +/* if( (numobj == NUM_PERSO) + AND (numbody == GEN_BODY_NORMAL) + AND (Weapon == 1) ) + { + numbody = GEN_BODY_SABRE ; + } +*/ + while( (command = *ptrc++) != 255 ) + { + switch( command ) + { + case 1: /* BODY */ + numgene = *ptrc++ ; // lit num name generique + + if( numbody == numgene ) // ok trouve + { + ptrc++ ; // saute size body + + hqrbody = *(UWORD*)ptrc ; + + if( hqrbody & (1<<15) ) // already loaded + { + hqrbody &= ~(1<<15) ; +//CoulText( 15, 0 ) ; +//Text( 10,110, "%FSearchBody d‚j… charg‚ %d", hqrbody ) ; + } + else + { + +//Text( 10,120, "%FSearchBody new %d", hqrbody ) ; + HQRM_Load( PATH_RESSOURCE"body.hqr", hqrbody, &PtrBody[NbBodys] ) ; + CHECK_MEMORY + +/* PtrBody[NbBodys] + = LoadMalloc_HQR( + PATH_RESSOURCE"body.hqr", + hqrbody ) ; +*/ + if( !PtrBody[NbBodys] ) TheEnd( NOT_ENOUGH_MEM, "Body.HQR in HQ_Mem" ) ; + + PatchObjet( PtrBody[NbBodys] ) ; + hqrbody = NbBodys ; + NbBodys++ ; +//Text( 10,130, "%FNbBodys %d", NbBodys ) ; + + *(UWORD*)ptrc = hqrbody + (1<<15) ; + } + ptrc += 2 ; + + M_Xmin = -32000 ; + + if( *ptrc++ ) // body possede action ? + { + if( *ptrc++ == 14 ) // ZV + { + M_Xmin = *(WORD*)ptrc ; + ptrc += 2 ; + M_Ymin = *(WORD*)ptrc ; + ptrc += 2 ; + M_Zmin = *(WORD*)ptrc ; + ptrc += 2 ; + M_Xmax = *(WORD*)ptrc ; + ptrc += 2 ; + M_Ymax = *(WORD*)ptrc ; + ptrc += 2 ; + M_Zmax = *(WORD*)ptrc ; + ptrc += 2 ; + } + } + + return hqrbody ; + } + else + { + ptrc += *ptrc ; // next body + } + break ; + + default: + ptrc++ ; // gen + ptrc += *ptrc ; + } + } + return -1 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +/* +void LoadFic( UBYTE indexfileobjet, WORD numobj ) +{ + T_OBJET *ptrobj ; + LONG size ; + + ptrobj = &ListObjet[numobj] ; + + ptrobj->PtrFile3D = LoadMalloc_HQR( + PATH_RESSOURCE"FILE3D.HQR", + indexfileobjet ) ; +} +*/ + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + diff --git a/SOURCES/FICHE.DEF b/SOURCES/FICHE.DEF new file mode 100644 index 0000000..738045d --- /dev/null +++ b/SOURCES/FICHE.DEF @@ -0,0 +1,4 @@ +extern void ThrowMagicBall(short ,short ,short ,short ,short ,short ,unsigned char ); +extern void GereAnimAction(T_OBJET *,short ); +extern short SearchAnim(unsigned char ,short ); +extern short SearchBody(unsigned char ,short ); diff --git a/SOURCES/FIRE.ASM b/SOURCES/FIRE.ASM new file mode 100644 index 0000000..247842b --- /dev/null +++ b/SOURCES/FIRE.ASM @@ -0,0 +1,177 @@ +; ------------------------------ FIRE.ASM ------------------------------ + + + .386p + + .model SMALL, SYSCALL + + .data + + include \projet\lib386\lib_svga\svga.ash + include \projet\lib386\lib_sys\lib_sys.ash + + public NoLanguage Imagen + + extrn NoLanguage BufSpeak:DWORD + +;Imagen DB 320*50 DUP (0) +;Imagen2 DB 320*50 DUP (0) + +Imagen dd 0000 +Imagen2 dd 0000 + +loopy dw 00 + + .code + + public NoLanguage DoFire + public NoLanguage ComputeFire + +ComputeFire proc uses esi edi ebx edx + + mov eax, [BufSpeak] + mov [Imagen], eax + add eax, 320*50 + mov [Imagen2], eax + + mov esi, [Imagen] + add esi, 321 + mov edi, [Imagen2] + add edi, 321 + +; mov esi, 321 + offset Imagen +; mov edi, 321 + offset Imagen2 + + MOV CX,48*320-2 + + XOR BH,BH +@@lp: + XOR AX,AX + ADD AL,-1[eSI] + ADC AH,BH + ADD AL,-320[eSI] + ADC AH,BH + ADD AL,-319[eSI] + ADC AH,BH + ADD AL,-321[eSI] + ADC AH,BH + ADD AL,1[eSI] + ADC AH,BH + ADD AL,320[eSI] + ADC AH,BH + ADD AL,319[eSI] + ADC AH,BH + ADD AL,321[eSI] + ADC AH,BH + ROR AX,3 + + TEST AH,65h ; Wanna know why 60h? Me too. + JNZ @@nx ; This is pure experience. + ; ok but it's better with 65 + + mov edx, [Imagen2] + add edx, 46*320 + + CMP edi, edx + +; cmp edi, 46*320 + offset Imagen2 + JNC @@dec + + OR AL,AL ; My dog coded here too. + JZ @@nx ; I helped my sister with this one. +@@dec: + DEC AL ; Yeah! Cool a bit, please. +@@nx: + inc esi + mov byte ptr[edi], al + + inc edi + + dec cx + jnz @@lp ; New image stored in Imagen2. + + mov esi, [Imagen2] + add esi, 320 + MOV edi, [Imagen] + +; mov esi, 320 + offset Imagen2 +; mov edi, offset Imagen + + MOV ecx, 160*48/2 + rep movsd + + mov esi, [Imagen2] + add esi, 320*39 + +; mov esi, offset Imagen2 + 320*39 + + mov ecx, 5*320 + mov ah, 11 +@@rcl: + mov al,[esi] + cmp al, 15 + jnc @@rcn + SUB AL,AH + NEG AL + MOV [eSI],AL +@@rcn: + INC eSI + dec cx + jnz @@rcl + + ret + +ComputeFire endp + + +DoFire proc uses esi edi ebx ebp ,\ + lig:dword, coul:dword + + call ComputeFire + + mov esi, [Imagen] + add esi, 5*320 + +; mov esi, offset Imagen + 5 * 320 + + mov edi, Log + + mov eax, lig + add edi, [TabOffLine + eax*4] + + mov ebx, Coul + mov bh, bl + add bh, 15 + + mov dx, 25 + +copy0: mov cx, 320 + +copy: mov al, [esi] + shr al, 1 + add al, bl + cmp al, bh + ja adcoul +adcrt: mov ah, al + mov [edi], ax + mov [edi+640], ax + inc esi + inc edi + inc edi + + dec cx + jnz copy + + add edi, 640 + + dec dx + jnz copy0 + + ret + +adcoul: mov al, bh + jmp adcrt + +DoFire endp + + END diff --git a/SOURCES/FLA.H b/SOURCES/FLA.H new file mode 100644 index 0000000..ee9aef6 --- /dev/null +++ b/SOURCES/FLA.H @@ -0,0 +1,138 @@ +#include "\projet\lib386\lib_X\lib_X.h" + +#define MAX_SAMPLES_FLA 255 +#define NOM_FICHIER_DEF_CONFIGURATION "C:\\ADELINE.DEF" + +#ifdef ONE_GAME_DIRECTORY +#define PATH_FICHIER_SAMPLE "FLA\\" +#else +#define PATH_FICHIER_SAMPLE "F:\\projet\\lba\\samples\\flasamp\\" +#endif + +#define NOM_FICHIER_TEMPORAIRE "Fla_" +#define NOM_FICHIER_FRAME_TEMPORAIRE "C:\\_Frame.tmp" + +#define FLI 2 +#define FLA 3 +#define X_POS_MENU_PRINCIPAL 480 +#define Y_POS_MENU_PRINCIPAL 10 +#define X_POS_MENU_STORYBOARD 0 +#define Y_POS_MENU_STORYBOARD 335 + +// Define pour les fichiers format FLI +#define FLI_COLOR 11 +#define FLI_LC 12 +#define FLI_BLACK 13 +#define FLI_BRUN 15 +#define FLI_COPY 16 + +// Structures utilis‚es pour les fichiers format FLI +typedef struct + { + LONG size ; + UWORD type ;/* = FLIH_MAGIC */ + UWORD frame_count ; + UWORD width ; + UWORD height ; + UWORD bits_a_pixel ; + WORD flags ; + WORD speed ; + LONG next_head ; + LONG frames_in_table ; + WORD file ; + LONG frame1_off ; + LONG strokes ; + LONG session ; + BYTE reserved[88] ; + } T_HEADER_FLI ; + +typedef struct + { + ULONG size ; + UWORD typedata ; + UBYTE image[] ; + } T_HEADER_IMAGE ; + +typedef struct + { + ULONG offset ; + UWORD signature ; + UWORD nbpasse ; + UBYTE reserved[6+2] ; + } T_HEADER_SUB ; + +// Define pour les fichiers format FLA +#define VERSION "V1.3" +#define FLA_PALETTE 1 +#define FLA_INFO 2 +#define FLA_SAMPLE 3 +#define FLA_SAMPLE_BALANCE 4 +#define FLA_SAMPLE_STOP 5 +#define FLA_LC 6 +#define FLA_BLACK 7 +#define FLA_BRUN 8 +#define FLA_COPY 9 + +// Structures utilis‚es pour les fichiers format FLA +typedef struct // entete de fichier FLA + { + char Version[5] ; + ULONG NbFrame ; + UBYTE CadenceAnimation; + UWORD ResolutionX ; + UWORD ResolutionY ; + } T_HEADER_FLA; + +typedef struct // header de passe + { + UBYTE NbPasse ; + ULONG OffsetFrameSuivante ; + } T_HEADER_FLA_PASSE; + +typedef struct // structure d'un type de passe + { + UBYTE Type; + UWORD OffsetPasseSuivante; + } T_FLA_TYPE; + +typedef struct // structure d'un element d'une liste de son + { + WORD NbSample; + WORD OffsetFrameOne; + } T_FLA_SAMPLE_LIST; + +typedef struct // structure d'une info + { + WORD Info ; + } T_FLA_INFO; + +typedef struct // structure d'un son + { + WORD Numero ; + WORD Decalage; + WORD Repetition; + UBYTE Balance; + UBYTE VolumeG; + UBYTE VolumeD; + } T_FLA_SAMPLE; + +typedef struct // structure d'un son + { + WORD Numero ; + UBYTE Offset ; + WORD Balance ; + UBYTE VolumeG ; + UBYTE VolumeD ; + } T_FLA_BALANCE; + +typedef struct // structure d'arret de son + { + UWORD Numero ; + } T_FLA_SAMPLE_STOP; + +typedef struct // structure d'une palette + { + UWORD NbCouleur; + UWORD CouleurDepart; + } T_FLA_PALETTE; + diff --git a/SOURCES/FLIPBOX.C b/SOURCES/FLIPBOX.C new file mode 100644 index 0000000..9530d28 --- /dev/null +++ b/SOURCES/FLIPBOX.C @@ -0,0 +1,140 @@ +#include "defines.h" + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Ûßßßß Û Û ÛßßßÛ ÛßßÛ ÛßßßÛ ßÜ Üß + ÛÛßß ÛÛ ÛÛ ÛÛßßß ÛÛßßÛ ÛÛ Û ÜßÜ + ßß ßßßßß ßß ßß ßßßßß ßßßßß ßßßßß ß ß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +extern UBYTE *Screen ; /* background clean */ + + +typedef struct +{ + WORD x0 ; + WORD y0 ; + WORD x1 ; + WORD y1 ; } T_PHYSBOX ; + + +T_PHYSBOX NewListBox[MAX_OBJETS+MAX_EXTRAS] ; +T_PHYSBOX OptListBox[(MAX_OBJETS+MAX_EXTRAS)*2] ; + +WORD NbPhysBox = 0 ; +WORD NbOptPhysBox = 0 ; + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void AddOptBox( WORD x0, WORD y0, WORD x1, WORD y1 ) +{ + T_PHYSBOX *ptr ; + WORD cx0, cy0, cx1, cy1 ; + WORD n ; + LONG totalsurface ; + LONG surfacecommune ; + LONG surfacetest ; + + surfacetest = (x1-x0) * (y1-y0) ; + ptr = OptListBox ; + for( n=0; nx0,x0) ; + cx1 = max(ptr->x1,x1) ; + cy0 = min(ptr->y0,y0) ; + cy1 = max(ptr->y1,y1) ; + + surfacecommune = (LONG)(cx1-cx0) * (cy1-cy0) ; + totalsurface = surfacetest + (ptr->x1-ptr->x0) * (ptr->y1-ptr->y0) ; + + if( surfacecommune < totalsurface ) + { + ptr->x0 = cx0 ; + ptr->y0 = cy0 ; + ptr->x1 = cx1 ; + ptr->y1 = cy1 ; + return ; + } + } + ptr->x0 = x0 ; + ptr->y0 = y0 ; + ptr->x1 = x1 ; + ptr->y1 = y1 ; + NbOptPhysBox++ ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void AddPhysBox( WORD x0, WORD y0, WORD x1, WORD y1 ) +{ + T_PHYSBOX *ptr ; + + if( x0 < 0 ) x0 = 0 ; + if( x1 > 639 ) x1 = 639 ; + if( y0 < 0 ) y0 = 0 ; + if( y1 > 479 ) y1 = 479 ; + if( x1 < x0 ) return ; + if( y1 < y0 ) return ; + + ptr = &NewListBox[NbPhysBox] ; + ptr->x0 = x0 ; + ptr->y0 = y0 ; + ptr->x1 = x1 ; + ptr->y1 = y1 ; + NbPhysBox++ ; + + AddOptBox( x0, y0, x1, y1 ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void FlipOptList() +{ + WORD n ; + T_PHYSBOX *ptr ; + + /* regenere optlistbox pour clear log + puis phys a la prochaine boucle*/ + ptr = NewListBox ; + NbOptPhysBox = 0 ; + for( n=0; nx0, ptr->y0, ptr->x1, ptr->y1 ) ; + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void FlipBoxes() +{ + WORD n ; + T_PHYSBOX *ptr ; + + /* copie liste optimis‚e vers phys */ + ptr = OptListBox ; + for( n=0; nx0, ptr->y0, ptr->x1, ptr->y1 ) ; + } + + FlipOptList() ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void ClsBoxes() +{ + WORD n ; + T_PHYSBOX *ptr ; + + /* efface ecran logique (copy depuis Screen org) */ + ptr = OptListBox ; + for( n=0; nx0, ptr->y0, ptr->x1, ptr->y1, Screen, + ptr->x0, ptr->y0, Log ) ; + +/* Box( ptr->x0, ptr->y0, ptr->x1, ptr->y1, 0 ) ; */ + } +} + diff --git a/SOURCES/FLIPBOX.DEF b/SOURCES/FLIPBOX.DEF new file mode 100644 index 0000000..2265518 --- /dev/null +++ b/SOURCES/FLIPBOX.DEF @@ -0,0 +1,5 @@ +extern void AddOptBox(short ,short ,short ,short ); +extern void AddPhysBox(short ,short ,short ,short ); +extern void FlipOptList(void); +extern void FlipBoxes(void); +extern void ClsBoxes(void); diff --git a/SOURCES/FUNC.ASM b/SOURCES/FUNC.ASM new file mode 100644 index 0000000..f9c20d4 --- /dev/null +++ b/SOURCES/FUNC.ASM @@ -0,0 +1,415 @@ + .386p + + .model SMALL, SYSCALL + + include f:\projet\lib386\lib_svga\svga.ash + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + .data +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + + extrn NoLanguage TabOffLine:DWORD + extrn NoLanguage Screen:DWORD + +IndexCoul0 db 4*16 +PalRed db 0 +PalGreen db 0 +PalBlue db 0 +PalXor db 0 + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + .code +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + + public NoLanguage SimpleInitMcga + public NoLanguage CopyBlockMCGA + public NoLanguage ShadeBox + public NoLanguage SmallSort +; public NoLanguage SpeedRam +; public NoLanguage TimerPalFx + public NoLanguage GetHDFreeSize + public NoLanguage ComputeTime + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +;SpeedRam proc ; pas remarquable +; +; mov al, 200 +; out 41, al +; ret +; +;SpeedRam endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +comment # + +TimerPalFx proc uses eax edx ecx + + xor byte ptr[PalXor], 1 + jnz tpf1 + + add byte ptr[PalBlue], 4 + + mov al, [IndexCoul0] + mov dx, 03c8h + out dx, al ; al=Num Color + + mov ah, [PalBlue] + + mov cx, 16 + +tpf0: mov dx, 03c9h + mov al, [PalRed] + out dx, al ; Red + mov al, [PalGreen] + out dx, al ; Green + mov al, ah + out dx, al ; Blue + + add ah, 8 + dec cx + jnz tpf0 + +tpf1: ret + +TimerPalFx endp + + # + +;---------------------------------------------------------------------------- +ComputeTime proc + local cpttime:DWORD + local cptdate:DWORD + + mov [cpttime], 0 + mov [cptdate], 0 + + mov ah, 2ch + int 21h + mov byte ptr [cpttime], ch ;'Heure + shl cpttime, 6 + or byte ptr [cpttime], cl ;'Minutes + shl cpttime, 5 + shr dh, 1 + or byte ptr [cpttime], dh ;'Secondes/2 + + mov ah, 2ah + int 21h + sub cx, 1980 + mov byte ptr [cptdate], cl ;' Annees + shl cptdate, 4 + or byte ptr [cptdate], dh ;' Mois + shl cptdate, 5 + or byte ptr [cptdate], dl ;' Jour + + mov eax, cpttime + add eax, cptdate + ret +ComputeTime endp +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +SmallSort proc uses esi edi ebx ebp,\ + objetlist:DWORD, nbobjets:DWORD, structsize:DWORD + + mov esi, objetlist + mov ecx, nbobjets + dec ecx + jle fintri + + mov edx, structsize + + ; ecx nb entite - 1 + ; esi start list sizeof structsize bytes + EVEN +tt0: mov ebp, ecx + mov eax, [esi] ; lit Z + + mov edi, esi + add edi, edx + xor ebx, ebx + +tt1: cmp [edi], ax + jl plusgrand +cont: add edi, edx + loop tt1 + + or ebx, ebx + jz short noexchg + +; mov eax, [ebx] +; xchg [esi], eax ; permutte +; mov [ebx], eax + + mov edi, esi + push edx + shr edx, 2 + EVEN +permute: mov eax, [ebx] + xchg [edi], eax ; permutte + mov [ebx], eax + add ebx, 4 + add edi, 4 + dec dx + jnz permute + + pop edx + +noexchg: add esi, edx + mov ecx, ebp + loop tt0 + +fintri: ret + +plusgrand: mov ebx, edi + mov eax, [edi] + jmp short cont + +SmallSort endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +SimpleInitMcga proc uses esi edi ebp ebx + + mov ax, 13h + int 10h + ret + +SimpleInitMcga endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +CopyBlockMCGA proc uses esi edi ebx ebp,\ + x0:DWORD, y0:DWORD, x1:DWORD, y1:DWORD, src:DWORD,\ + xd:DWORD, yd:DWORD, dst:DWORD + + mov ebx, y0 + mov esi, TabOffLine[ebx*4] ; y0 + add esi, src + add esi, x0 ; SI Offset Src + +; mov edi, yd +; mov eax, edi +; shl edi, 2 ; *4 +; add edi, eax ; *5 +; shl edi, 6 ; *320 +; add edi, dst +; add edi, xd ; DI Offset Dst + + mov edi, dst + + mov ebx, y1 ; y0 <=> y1 + sub ebx, y0 + inc ebx ; BX Delta Y + + mov eax, x1 + sub eax, x0 + inc eax ; AX Delta X + + mov edx, 320 + sub edx, eax ; DX Delta Screen + mov ebp, 640 + sub ebp, eax +Again: + mov ecx, eax + shr ecx, 2 + rep movsd + mov ecx, eax + and ecx, 11b + rep movsb + + add esi, ebp + add edi, edx + dec ebx + jne short Again + + ret +CopyBlockMCGA endp + +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + +ShadeBox proc uses esi edi ebp ebx,\ + x0:DWORD, y0:DWORD, x1:DWORD, y1:DWORD,\ + deccoul:DWORD + + mov eax, x0 + mov ebx, y0 + mov ecx, x1 + mov edx, y1 + +;---------------------- + + cmp eax, ClipXmax + jg Box_End + cmp ecx, ClipXmin + jl Box_End + cmp ebx, ClipYmax + jg Box_End + cmp edx, ClipYmin + jl Box_End +TestLeft: + cmp eax, ClipXmin + jge TestRight + mov eax, ClipXmin +TestRight: + cmp ecx, ClipXmax + jle TestUp + mov ecx, ClipXmax +TestUp: + cmp ebx, ClipYmin + jge TestDown + mov ebx, ClipYmin +TestDown: + cmp edx, ClipYmax + jle OkNoClip + mov edx, ClipYmax +OkNoClip: +;---------------------- + mov edi, ebx ; Y0 + mov edi, TabOffLine[edi*4] + add edi, Log + add edi, eax ; EDI Offset Src +;---------------------- + sub edx, ebx ; Init Delta Y + mov ebx, edx + inc ebx + + mov edx, ecx ; Init Delta X + sub edx, eax + inc edx + + mov esi, Screen_X + sub esi, edx ; ebp Delta Screen + + mov ecx, deccoul + +Again: mov ebp, edx + +loopx: mov al, byte ptr[edi] + mov ah, al +; and ah, 0F0h +; and al, 00Fh + and ax, 0F00Fh + sub al, cl + jc lesszero + + add al, ah + + mov byte ptr[edi], al + inc edi + + dec ebp + jnz loopx + + add edi, esi + dec ebx + jne Again +Box_End: + ret + +lesszero: mov al, ah + mov byte ptr[edi], al + inc edi + + dec ebp + jnz loopx + + add edi, esi + dec ebx + jne Again + + ret + +ShadeBox endp + + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +comment # + +DesintegreClip proc uses ebx edi esi ebp + level:DWORD + + mov eax, ClipXmin + mov ecx, ClipXmax + mov ebx, ClipYmin + mov edx, ClipYmax + +;---------------------- + + mov edi, ebx ; Y0 + mov edi, TabOffLine[edi*4] + add edi, eax ; EDI Offset Src + mov esi, edi + add edi, Log + add esi, Screen +;---------------------- + + sub edx, ebx ; Init Delta Y + mov ebx, edx + inc ebx + + mov edx, ecx ; Init Delta X + sub edx, eax + inc edx + + mov eax, Screen_X + sub eax, edx ; ebp Delta Screen + mov [offsety], ecx + + +Again: mov ebp, edx + +loopx: + + mov al, byte ptr[esi] + + mov ebx, esi + and ebx, 7 + and al, byte ptr[ebx] ; plus tard table + + + mov byte ptr[edi], al + + inc edi + inc esi + + dec ebp + jnz loopx + + add edi, [offsety] + dec ebx + jne Again + + ret + +DesintegreClip proc + + # + +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +GetHDFreeSize proc uses ebx + + xor eax, eax ;' Cause IMUL + mov ebx, eax ;' Cause IMUL + mov ecx, eax ;' Cause IMUL + + mov ah, 36h + mov dl, 0 ;' Current Drive + int 21h ;' Get Free Space + + imul ebx + imul ecx ;' Bytes*Sectors*Clusters + + ret + +GetHDFreeSize endp +;*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* +;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + END diff --git a/SOURCES/GAMEMENU.C b/SOURCES/GAMEMENU.C new file mode 100644 index 0000000..c3dc592 --- /dev/null +++ b/SOURCES/GAMEMENU.C @@ -0,0 +1,2849 @@ +#include "c_extern.h" + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + + LONG MixMusic = 1 ; // Flag Mixer for Music +extern LONG MaxVolume ; // Max Music Volume if no Mixer + +#define HAUTEUR_STANDARD 50 +#define MENU_SPACE 6 + +#define COUL_TEXT_MENU 15 // trouver blanc palette jeu +#define COUL_SELECT_MENU 68 +#define COUL_INPUT_NAME 112 +#define COUL_LETTER_INPUT 15 + +WORD LargeurMenu = 550 ; + +UWORD GameMainMenu[] = { + 0, // selected + 4, // nb entries + 200, // y center + 0, // .dia num + 0, 20, // start a new game game + 0, 21, // continue game + 0, 23, // options + 0, 22 // ret dos + } ; + +UWORD GameQuitMenu[] = { + 0, // selected + 2, // nb entries + 240, // y center + 0, // .dia num + 0, 28, // continuer jeu + 0, 27 // abandonner partie + } ; + +UWORD GameOptionMenu[] = { + 0, // selected + 4, // nb entries + 0, // y from top. + 0, // .dia num + + 0, 24, // annuler + 0, 30, // reglages volumes + 0, 46, // gestion saved game + 0, 47 // advanced options + } ; + +UWORD GameAdvancedMenu[] = { + 0, // selected + 5, // nb entries + 0, // y from top. + 0, // .dia num + + 0, 26, // retour + 0, 4, // agressif auto/manuel + 6, 31, // niveau details + 7, 32, // ombres on/off + 8, 33 // zoom on/off + } ; + +UWORD GameVolumeMenu[] = { + 0, // selected + 7, // nb entries + 0, // y from top. + 0, // .dia num + + 0, 26, // retour prec + 1, 10, // type musvol / num text + 2, 11, // type sampvol + 3, 12, // type cdvol + 4, 13, // type linevol + 5, 14, // type mastervol + 0, 16 // save settings + + } ; + +UWORD SavedGameMenu[] = { + 0, // selected + 3, // nb entries + 0, // y from top. + 0, // .dia num + + 0, 26, // retour menu prec + 0, 41, // copier une sauvegarde + 0, 45 // d‚truire une sauvegarde + + } ; + +UWORD SavedConfirmMenu[] = { + 0, // selected + 2, // nb entries + 240, // y center. + 0, // .dia num + + 0, 24, // annuler + 0, 48 // d‚truire une sauvegarde + + } ; + +UWORD GameChoiceMenu[] = { + 0, // selected + 7, // nb entries + 0, // y from top. byte 8( + 0, // .dia num + + 0, 0, + 0, 1, + 0, 2, + 0, 3, + 0, 4, + 0, 5, + 0, 6 } ; + +ULONG TimerSample ; + +// save players games + +#define MAX_PLAYER 50 + +UBYTE NumVersion = 0 ; + +#define NB_CAR_H 14 +#define NB_CAR_V 5 + +#define MAX_SIZE_PLAYER_NAME 29 + +UBYTE GamePathname[_MAX_PATH] ; + +//UBYTE PlayerGameFile[_MAX_PATH] ; + +UBYTE PlayerName[MAX_SIZE_PLAYER_NAME+1] ; + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +// UBYTE TabInvOrder[] = { + +WORD ListBetaGame[MAX_FLAGS_GAME] ; + +#define SIZE_INV_OBJ_X 75 +#define SIZE_INV_OBJ_Y 65 + + +WORD InvSelect = 0 ; +WORD InvCoul = COUL_SELECT_MENU ; + +#define INV_START_X 17 +#define INV_START_Y 10 + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#define SIZE_FOUND_OBJ 130 + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +T_REAL_VALUE RealRot ; +UBYTE *Ptr3do ; +WORD TabAnim[4] ; +WORD FrameAnim[4] ; + +extern WORD ZoneGrm ; +extern WORD IndexGrm ; + +#define CTRL_X0 100 +#define CTRL_Y0 100 +#define CTRL_X1 550 +#define CTRL_Y1 290 + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void Init3DGame() +{ + SetIsoProjection( 320-8-1, 240, SIZE_BRICK_XZ ) ; + SetPosCamera( 0,0,0 ) ; + SetAngleCamera( 0,0,0 ) ; + SetLightVector( AlphaLight, BetaLight, 0 ) ; +} + +extern UBYTE *Imagen ; + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DrawFire( WORD x0, WORD y0, WORD x1, WORD y1, WORD coul ) +{ + DoFire( y0, coul ) ; + + if( !Rnd(5) ) + { + BufSpeak[ Rnd(320*10)+20*320 ] = 255 ; + } +} + +void WaitReleaseSpace() +{ + SaveTimer() ; + while( (Fire & F_SPACE) + OR (Key == K_ESC) ) ; + RestoreTimer() ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Ûßßßß ÛßßßÛ ÛÜ ÜÛ Ûßßßß ÛÜ ÜÛ Ûßßßß ÛÛÜ Û Û Û + ÛÛ ßÛ ÛÛßßÛ ÛÛß Û ÛÛßß ÛÛß Û ÛÛßß ÛÛßÛÛ ÛÛ Û + ßßßßß ßß ß ßß ß ßßßßß ßßßßß ßß ß ßßßßß ßß ß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void DrawObj3D( WORD x0, WORD y0, WORD x1, WORD y1, + WORD y3d , WORD betaflag , + UBYTE *ptr3do ) +{ + WORD beta ; + + SetIsoProjection( (x1+x0)/2, (y1+y0)/2, 0 ) ; + + SetClip( x0,y0, x1,y1 ) ; + + if( betaflag == -1 ) + { + beta = GetRealAngle( &RealRot ) ; + + if( RealRot.TimeValue == 0 ) + { + InitRealAngle( beta, beta-256, 50, &RealRot ) ; + } + } + else + { + beta = betaflag ; + } + + AffObjetIso( 0,y3d,0, 0,beta,0, ptr3do ) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void DrawCadre( WORD x0, WORD y0, WORD x1, WORD y1 ) +{ + Line( x0 , y0 , x1, y0, 79 ) ; + Line( x0 , y0 , x0, y1, 79 ) ; + Line( x1 , y0+1, x1, y1, 73 ) ; + Line( x0+1, y1 , x1, y1, 73 ) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Ûßßßß ÛßßßÛ ÛÜ ÜÛ ÛßßßÛ ÛßßßÛ ÛßßßÛ ßßÛßß Ûßßßß ÛÜ ÜÛ Ûßßßß ÛÛÜ Û ßßÛßß + ÛÛ ÛÛ Û ÛÛß Û ÛÛßßß ÛÛ Û ÛÛßÛß ÛÛ ÛÛßß ÛÛß Û ÛÛßß ÛÛßÛÛ ÛÛ + ßßßßß ßßßßß ßß ß ßß ßßßßß ßß ß ßß ßßßßß ßß ß ßßßßß ßß ß ßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DrawComportement( WORD comportement, WORD beta, WORD copyblock ) +{ + WORD x0, y0, x1, y1 ; + UBYTE *ptranim ; + WORD frameanim ; + + + x0 = CTRL_X0+10 + comportement * 110 ; + y0 = CTRL_Y0+10 ; + x1 = x0+99 ; + y1 = y0+119 ; + + ptranim = HQR_Get( HQR_Anims, TabAnim[comportement] ) ; + frameanim = FrameAnim[comportement] ; + + if( SetInterAnimObjet( frameanim, ptranim, Ptr3do ) ) + { + frameanim++ ; + if( frameanim == GetNbFramesAnim( ptranim ) ) + { + frameanim = GetBouclageAnim( ptranim ) ; + } + FrameAnim[comportement] = frameanim ; + } + + if( !copyblock ) /* init */ + { + DrawCadre( x0-1, y0-1, x1+1, y1+1 ) ; + } + + MemoClip() ; + UnSetClip() ; + + if( comportement != Comportement ) + { + + Box( x0,y0, x1,y1, 0 ) ; + +/* CopyBlock( x0,y0, x1,y1, Screen, x0, y0, Log ) ; + ShadeBox( x0,y0, x1,y1, 3 ) ; +*/ + } + else + { + + Box( x0,y0, x1,y1, 68 ) ; + +/* CopyBlock( CTRL_X0+10, CTRL_Y0+139, CTRL_X1-10, CTRL_Y0+139+40, Screen, + CTRL_X0+10, CTRL_Y0+139, Log ) ; + ShadeBox( CTRL_X0+10, CTRL_Y0+139, CTRL_X1-10, CTRL_Y0+139+40, 4 ) ; +*/ + Box( CTRL_X0+10, CTRL_Y0+139, CTRL_X1-10, CTRL_Y0+139+40, 0 ) ; + DrawCadre( CTRL_X0+10, CTRL_Y0+139, CTRL_X1-10, CTRL_Y0+139+40 ) ; + + CoulFont( 15 ) ; + if( Comportement == C_AGRESSIF + AND CombatAuto == TRUE ) + GetMultiText( 4, String ) ; + else + GetMultiText( Comportement, String ) ; + + Font( (CTRL_X1+CTRL_X0-SizeFont( String ))/2, CTRL_Y0+140, String ) ; + } + + DrawObj3D( x0, y0, x1, y1, + -600, beta, + Ptr3do ) ; + +/* if( comportement != Comportement ) + { +// ShadeBox( x0,y0, x1,y1, 5 ) ; + } + else + { +// Rect( x0+1,y0+1, x1-1,y1-1, 12 ) ; + Rect( x0+2,y0+2, x1-2,y1-2, 12 ) ; + } +*/ + + if( copyblock ) + { + CopyBlockPhys( x0,y0,x1,y1 ) ; + CopyBlockPhys( CTRL_X0+10, CTRL_Y0+139, CTRL_X1-10, CTRL_Y0+139+40 ) ; + } + + RestoreClip() ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void DrawInfoMenu( WORD x0, WORD y0 ) +{ + WORD x,x1 ; + WORD l ; + WORD lifepoint ; + + UnSetClip() ; + + DrawCadre( x0,y0, x0+450, y0+80 ) ; + /*Shade*/Box( x0+1,y0+1, x0+450-1, y0+80-1, 0/*3*/ ) ; + + // Life Points (max 50) + +// AffGraph( 4, x0+9, y0+13, PtrSpriteExtra ) ; + AffGraph( 0, x0+9, y0+13, HQR_Get(HQRPtrSpriteExtra, 4) ) ; + + lifepoint = ListObjet[NUM_PERSO].LifePoint ; + x = RegleTrois32( x0+25, x0+325, 50, lifepoint ) ; + + Box( x0+25, y0+10, x, y0+10+15, 91 ) ; + Box( x, y0+10, x0+325, y0+10+15, 0 ) ; + + DrawCadre( x0+25, y0+10, x0+325, y0+10+15 ) ; + + // Magic level (max 4) MagicPoint (max 80) + + if( !ListFlagGame[FLAG_CONSIGNE] + AND ListFlagGame[FLAG_TUNIQUE] ) + { + +// AffGraph( 5, x0+9, y0+36, PtrSpriteExtra ) ; + AffGraph( 0, x0+9, y0+36, HQR_Get(HQRPtrSpriteExtra, 5) ) ; + + if( MagicLevel ) + { + x = RegleTrois32( x0+25, x0+325, 80, MagicPoint ) ; + Box( x0+25, y0+35, x, y0+35+15, 75 ) ; + + for( l=0; lPtrFile3D ; + + Ptr3do = PtrBody[ptrobj->Body] ; + + TabAnim[0] = AnimRienNormal ; + TabAnim[1] = AnimRienSportif ; + TabAnim[2] = AnimRienAgressif ; + TabAnim[3] = AnimRienDiscret ; + + InitRealAngle( ptrobj->Beta, ptrobj->Beta-256, 50, &RealRot ) ; + + CopyScreen( Log, Screen ) ; + + memoisland = Island ; + Island = 255 ; + + memoflagspeak = FlagSpeak ; + FlagSpeak = FALSE ; + InitDial( 0 ) ; + + DrawMenuComportement( ptrobj->Beta ) ; + + oldcomp = Comportement ; + SetAnimObjet( FrameAnim[Comportement], + HQR_Get( HQR_Anims, TabAnim[Comportement] ), + Ptr3do ) ; + + while( (Fire & F_CTRL) OR ((Key>=K_F1) AND (Key<=K_F4)) ) + { +#ifdef DEBUG_TOOLS + CheckSavePcx() ; +#endif + MyJoy = Joy ; + +/* if( Comportement == C_AGRESSIF ) + { + if( MyJoy & J_UP ) CombatAuto = TRUE ; + if( MyJoy & J_DOWN ) CombatAuto = FALSE ; + } +*/ + if( MyJoy & J_RIGHT ) Comportement++ ; + if( MyJoy & J_LEFT ) Comportement-- ; + Comportement &= 3 ; + + if( Comportement != oldcomp ) + { + DrawComportement( oldcomp, ptrobj->Beta, TRUE ) ; + + oldcomp = Comportement ; + InitRealAngle( ptrobj->Beta, + ptrobj->Beta-256, + 50, &RealRot ) ; + + SetAnimObjet( FrameAnim[Comportement], + HQR_Get( HQR_Anims, TabAnim[Comportement] ), + Ptr3do ) ; + + while( Joy ) + DrawComportement( Comportement, -1, TRUE ) ; + } + DrawComportement( Comportement, -1, TRUE ) ; + } + SetComportement( Comportement ) ; + + Init3DGame() ; + + Island = memoisland ; + + FlagSpeak = memoflagspeak ; + InitDial( START_FILE_ISLAND+Island ) ; + + RestoreTimer() ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û ÛÛÜ Û Û Û Ûßßßß ÛÛÜ Û ßßÛßß ÛßßßÛ ÛßßßÛ Û Üß + ÛÛ ÛÛßÛÛ ÛÛ Üß ÛÛßß ÛÛßÛÛ ÛÛ ÛÛ Û ÛÛßÛß ÛÛß + ßß ßß ß ßßß ßßßßß ßß ß ßß ßßßßß ßß ß ßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void Draw3dObject( WORD x, WORD y, WORD *ptrobj, WORD beta, WORD zoom ) +{ + SetProjection( x,y,128,200,200 ) ; + + SetFollowCamera( 0,0,0, 60,0,0, zoom ) ; + + if( !ptrobj ) + { + Message( "ptrobj = 0", TRUE ) ; + } + else + { + AffObjetIso( 0,0,0, 0,beta,0, ptrobj ) ; + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DrawOneInventory( WORD flagnum ) +{ + WORD x, y, x0, y0, x1, y1 ; + WORD *ptrobj ; + + x = INV_START_X + 10 + SIZE_INV_OBJ_X/2 + + (SIZE_INV_OBJ_X+10) * (flagnum/4) ; + y = INV_START_Y + 10 + SIZE_INV_OBJ_Y/2 + + (SIZE_INV_OBJ_Y+10) * (flagnum&3) ; + + x0 = x - SIZE_INV_OBJ_X/2 ; + y0 = y - SIZE_INV_OBJ_Y/2 ; + x1 = x + SIZE_INV_OBJ_X/2 ; + y1 = y + SIZE_INV_OBJ_Y/2 ; + + if( flagnum == InvSelect ) + { + Box( x0, y0, x1, y1, InvCoul ) ; + } + else + { + Box( x0, y0, x1, y1, 0 ) ; +// CopyBlock( x0, y0, x1, y1, Screen, x0, y0, Log ) ; +// ShadeBox( x0, y0, x1, y1, 4 ) ; + } + + if( (ListFlagGame[flagnum]) + AND ((ListFlagGame[FLAG_CONSIGNE]==0) OR (flagnum==FLAG_CLOVER)) ) + { + ptrobj = HQR_Get( InventoryObj, flagnum ) ; + if( HQR_Flag ) + { + PatchObjet( ptrobj ) ; + } + + Draw3dObject( x, y, ptrobj, + ListBetaGame[flagnum]+=8, 15000 ) ; + + if( flagnum == 15 ) // carburant + { + CoulFont( 15 ) ; + Font( x0+3,y0+32, Itoa( Fuel ) ) ; + } + } + + DrawCadre( x0, y0, x1, y1 ) ; + + CopyBlockPhys( x0,y0, x1,y1 ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + + +void DrawListInventory() +{ + WORD x, y ; + WORD n = 0 ; + WORD x0, y0, x1, y1 ; + + x0 = INV_START_X ; + y0 = INV_START_Y ; + + x1 = x0 + (SIZE_INV_OBJ_X+10)*7 + 10 ; + y1 = y0 + (SIZE_INV_OBJ_Y+10)*4 + 10 ; + + ShadeBox( x0,y0, x1,y1, 4 ) ; + DrawCadre( x0,y0, x1,y1 ) ; + +/* DrawCadre( INV_START_X+ 10 - 2 + (SIZE_INV_OBJ_X+10) * 0, + INV_START_Y+ 10 - 2 + (SIZE_INV_OBJ_Y+10) * 1, + + INV_START_X+ 1 + (SIZE_INV_OBJ_X+10) * 1, + INV_START_Y+ 1 + (SIZE_INV_OBJ_Y+10) * 3 ) ; +*/ + Rect( INV_START_X+ 10 - 2 + (SIZE_INV_OBJ_X+10) * 1, + INV_START_Y+ 10 - 2 + (SIZE_INV_OBJ_Y+10) * 0, + INV_START_X+ 1 + (SIZE_INV_OBJ_X+10) * 2, + INV_START_Y+ 1 + (SIZE_INV_OBJ_Y+10) * 4, + 75 ) ; + + CopyBlockPhys( x0,y0, x1,y1 ) ; + + for( n=0; n 0 ) ListFlagGame[FLAG_CLOVER] = TRUE ; + else ListFlagGame[FLAG_CLOVER] = FALSE ; + + InvCoul = COUL_SELECT_MENU ; + DrawListInventory() ; // draw all + + memoflagspeak = FlagSpeak ; + FlagSpeak = FALSE ; + InitDial( 2 ) ; // game divers txt + + dialstat = 3 ; + TestCoulDial( 4 ) ; + InitDialWindow() ; + + while( Key != K_ESC ) + { +#ifdef DEBUG_TOOLS + CheckSavePcx() ; +#endif + oldselect = InvSelect ; + + if( !flag ) + { + MyJoy = Joy ; + MyFire = Fire ; + MyKey = Key ; + if( MyJoy OR Fire ) flag = 1 ; + } + else + { + MyFire = MyJoy = MyKey = 0 ; + if( !Joy AND !Fire ) flag = 0 ; + } + + if( (MyKey == K_ESC) OR (MyFire&F_SHIFT) ) + { + break ; + } + + if( MyJoy & J_DOWN ) + { + InvSelect++ ; + if( InvSelect >= MAX_INVENTORY ) + InvSelect = 0 ; + DrawOneInventory( oldselect ) ; + dialstat = 3 ; + } + + if( MyJoy & J_UP ) + { + InvSelect-- ; + if( InvSelect < 0 ) + InvSelect = MAX_INVENTORY - 1 ; + DrawOneInventory( oldselect ) ; + dialstat = 3 ; + } + + if( MyJoy & J_LEFT ) + { + InvSelect -= 4 ; + if( InvSelect < 0 ) + InvSelect = MAX_INVENTORY + InvSelect ; + DrawOneInventory( oldselect ) ; + dialstat = 3 ; + } + + if( MyJoy & J_RIGHT ) + { + InvSelect += 4 ; + if( InvSelect >= MAX_INVENTORY ) + InvSelect = InvSelect - MAX_INVENTORY ; + DrawOneInventory( oldselect ) ; + dialstat = 3 ; + } + + + if( dialstat == 3 ) + { + SecondInitDialWindow() ; + + if( (ListFlagGame[InvSelect]==1) + AND ((ListFlagGame[FLAG_CONSIGNE]==0) OR (InvSelect==FLAG_CLOVER)) ) + { + OpenDialNoWindow( InvSelect+100 ) ; + dialstat = 0 ; + } + else + { + OpenDialNoWindow( 128 ) ; + dialstat = 0 ; + } + } + + if( dialstat != 2 ) + { + dialstat = NextDialCar() ; + } + if( dialstat != 1 ) // en cours lecture + { + Vsync() ; + } + + if( MyFire & F_SPACE ) + { + if( dialstat == 2 ) + { + SecondInitDialWindow() ; + dialstat = 0 ; + } + else + { + if( (ListFlagGame[InvSelect]==1) + AND ((ListFlagGame[FLAG_CONSIGNE]==0) OR (InvSelect==FLAG_CLOVER)) ) + { + SecondInitDialWindow() ; + OpenDialNoWindow( InvSelect+100 ) ; + } + } + } + + DrawOneInventory( InvSelect ) ; + + if( MyFire & F_RETURN ) + { + if( (ListFlagGame[InvSelect]==1) + AND ((ListFlagGame[FLAG_CONSIGNE]==0) OR (InvSelect==FLAG_CLOVER)) ) + { + InventoryAction = InvSelect ; + + InvCoul = 91 ; // rouge + DrawOneInventory( InvSelect ) ; + + break ; + } + } + } + CloseDial() ; + + AlphaLight = memoalphalight ; + BetaLight = memobetalight ; + Init3DGame() ; + + FlagSpeak = memoflagspeak ; + InitDial( START_FILE_ISLAND+Island ) ; + + while( Key OR Fire ) ; +} +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Ûßßßß ÛßßßÛ Û Û ÛÛÜ Û ÛßßßÜ ÛßßßÛ ÛßßÛ Û Ûßßßß Ûßßßß ßßÛßß + ÛÛßß ÛÛ Û ÛÛ Û ÛÛßÛÛ ÛÛ Û ÛÛ Û ÛÛßßÛ ÜÜ Û ÛÛßß ÛÛ ÛÛ + ßß ßßßßß ßßßßß ßß ß ßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DoFoundObj( WORD numobj ) +{ + char string[256] ; + WORD *ptr3do ; + T_OBJET *ptrobj ; + WORD xm, ym, zm, xw, yw, zw ; + WORD x, y, x0, y0, x1, y1 ; + ULONG timerend ; + WORD dialstat ; + WORD flag ; + UBYTE *ptranim ; + WORD numanim ; + WORD frameanim ; + + LONG memoflagspeak ; + LONG speakfromcd ; + LONG memotimersystem ; + + ptrobj = &ListObjet[NUM_PERSO] ; + + // reaff scene recentree sans twinkel + + StartXCube = ((ListObjet[NUM_PERSO].PosObjX+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + StartYCube = ((ListObjet[NUM_PERSO].PosObjY+SIZE_BRICK_Y)/SIZE_BRICK_Y) ; + StartZCube = ((ListObjet[NUM_PERSO].PosObjZ+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + + ptrobj->Flags |= INVISIBLE ; + AffScene( TRUE ) ; + ptrobj->Flags &= ~INVISIBLE ; + + CopyScreen( Log, Screen ) ; + + // reaff twinksen anim trouve + + xw = StartXCube*SIZE_BRICK_XZ ; + yw = StartYCube*SIZE_BRICK_Y ; + zw = StartZCube*SIZE_BRICK_XZ ; + + AffObjetIso( ptrobj->PosObjX-xw, ptrobj->PosObjY-yw, ptrobj->PosObjZ-zw, + 0, 128/*ptrobj->Beta*/, 0, + PtrBody[ptrobj->Body] ) ; + + SetClip( ScreenXmin, ScreenYmin, ScreenXmax, ScreenYmax ) ; + + xm = ((ptrobj->PosObjX+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + ym = ((ptrobj->PosObjY)/SIZE_BRICK_Y) ; + if( (ptrobj->Col&127) != 0 ) ym++ ; + zm = ((ptrobj->PosObjZ+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + + DrawOverBrick( xm, ym, zm ) ; + + Flip() ; + + ProjettePoint( ptrobj->PosObjX-xw, + ptrobj->PosObjY-yw, + ptrobj->PosObjZ-zw ) ; + + Yp -= 150 ; + + x0 = Xp - SIZE_FOUND_OBJ/2 ; + y0 = Yp - SIZE_FOUND_OBJ/2 ; + x1 = Xp + SIZE_FOUND_OBJ/2 ; + y1 = Yp + SIZE_FOUND_OBJ/2 ; + + HQ_MixSample( 41, 0x1000, 1, 128, 128 ) ; + + // aff text et objet + +#ifdef CDROM + + if( IsVoiceFileOnHD( 2 ) ) + { + // voix sur hd touche … rien + + InitDial( 2 ) ; // game divers txt + speakfromcd = FALSE ; + + } + else // coupe music cd si on + { + StopMusicCD() ; + memoflagspeak = FlagSpeak ; + FlagSpeak = FALSE ; + + InitDial( 2 ) ; + + FlagSpeak = memoflagspeak ; + speakfromcd = TRUE ; + } + +#else + + InitDial( 2 ) ; // game divers txt + +#endif + + UnSetClip() ; + OpenDial( numobj ) ; +// timerend = TimerRef + 50 * 30 ; + dialstat = 1 ; + flag = FALSE ; + TestCoulDial( 4 ) ; // coul twinsen +#ifdef CDROM + + if( speakfromcd ) + { + SpeakFromCD( 2, numobj ) ; + } + else + { + Speak( numobj ) ; + } +#endif + + numanim = SearchAnim( GEN_ANIM_TROUVE, NUM_PERSO ) ; + ptranim = HQR_Get( HQR_Anims, numanim ) ; +#ifdef DEBUG_TOOLS + if( numanim == -1 ) + { + Message( "num anim 'trouve' = -1 in DoFoundObj", TRUE ) ; + goto argexit ; + } + if( !ptranim ) + { + Message( "ptranim = 0 in DoFoundObj", TRUE ) ; + goto argexit ; + } +#endif + + frameanim = 0 ; + + PtrBufferAnim += StockInterAnim( PtrBufferAnim, PtrBody[ptrobj->Body] ) ; + if( PtrBufferAnim > BufferAnim + 5000 - 512 ) PtrBufferAnim = BufferAnim ; + + ptr3do = HQR_Get( InventoryObj, numobj ) ; + if( HQR_Flag ) + { + PatchObjet( ptr3do ) ; + } + + NbOptPhysBox = 0 ; // clear list cls boxes + + while( flag == FALSE ) + { + UnSetClip() ; + + NbPhysBox = 0 ; + ClsBoxes() ; + + ShadeBox( x0, y0, x1, y1, 4 ) ; + SetClip( x0, y0, x1, y1 ) ; + + Draw3dObject( Xp, Yp, ptr3do, + ListBetaGame[numobj]+=8, 10000 ) ; + + DrawCadre( x0, y0, x1, y1 ) ; + AddPhysBox( x0,y0, x1,y1 ) ; + + UnSetClip() ; + Init3DGame() ; + + // reaff twinkel anim trouve + + if( SetInterAnimObjet( frameanim, ptranim, PtrBody[ptrobj->Body] ) ) + { + frameanim++ ; + if( frameanim == GetNbFramesAnim( ptranim ) ) + { + frameanim = GetBouclageAnim( ptranim ) ; + } + } + + AffObjetIso( ptrobj->PosObjX-xw, ptrobj->PosObjY-yw, ptrobj->PosObjZ-zw, + 0, 128/*ptrobj->Beta*/, 0, + PtrBody[ptrobj->Body] ) ; + + SetClip( ScreenXmin, ScreenYmin, ScreenXmax, ScreenYmax ) ; + DrawOverBrick( xm, ym, zm ) ; + AddPhysBox( ScreenXmin, ScreenYmin, ScreenXmax, ScreenYmax ) ; + + // message + + if( dialstat == 1 ) + { + UnSetClip() ; + dialstat = NextDialCar() ; + } + if( dialstat != 1 ) // pas en cours lecture + { + Vsync() ; + } + + FlipBoxes() ; + + if( Fire ) + { + if( dialstat == 0 ) + { + flag = TRUE ; + } + if( dialstat == 2 ) + { + dialstat = 1 ; // continue + } + } + } + +#ifdef DEBUG_TOOLS +argexit: +#endif + +#ifdef CDROM + + if( speakfromcd ) + { + while( TestSpeakFromCD() AND (Key != K_ESC) ) ; + } + else + { + while( TestSpeak() AND (Key != K_ESC) ) ; + } + StopSpeak() ; +#endif + Init3DGame() ; + + InitDial( START_FILE_ISLAND+Island ) ; + + while( Key == K_ESC ) ; + +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void ExtInitMcga() +{ + int i ; + char num[10] ; + + if (Wave_Driver_Enable) + while( !WavePause() ) ; + + InitMcgaMode() ; + if( FlagPalettePcx ) Palette( PalettePcx ) ; + else Palette( PtrPal ) ; + WaveContinue() ; + FlagMCGA = TRUE ; +} + +void ExtInitSvga() +{ + if (Wave_Driver_Enable) + while( !WavePause() ) ; + + SimpleInitSvga() ; + if( FlagPalettePcx ) Palette( PalettePcx ) ; + else Palette( PtrPal ) ; + FlagMCGA = FALSE ; + WaveContinue() ; +} + +void TestRestoreModeSVGA( LONG flag ) +{ + if( FlagMCGA ) + { + ExtInitSvga() ; + if( flag ) AffScene(TRUE) ; + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void CopyBlockPhysMCGA( LONG x0, LONG y0, LONG x1, LONG y1 ) +{ + LONG x, y ; + +/* x = (x0+x1)/2 - 160 ; + y = (y0+y1)/2 - 100 ; +*/ + x = x0 - 160 ; + y = y0 - 140 ; + + if( x > 640-320 ) x = 640-320 ; + if( x < 0 ) x = 0 ; + if( y > 480-200 ) y = 480-200 ; + if( y < 0 ) y = 0 ; + + CopyBlockMCGA( x,y, x+319, y+199, Log, 0,0,0xA0000 ) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛÛßßß ÛßßßÛ Û Û Ûßßßß Û ÛßßßÛ ÛßßßÛ ÛßßßÜ + ßßßßÛ ÛÛßßÛ ÛÛ Üß ÛÛßß ÛÛ ÛÛ Û ÛÛßßÛ ÛÛ Û + ßßßßß ßß ß ßßß ßßßßß ßßßßß ßßßßß ßßßßß ßß ß ßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +WORD PlayerGameList( UBYTE **ptrlistname, UBYTE *listname ) +{ + struct find_t fileinfo ; + ULONG rc ; + UBYTE wbyte ; + UBYTE pathname[_MAX_PATH] ; + WORD nb = 0 ; + ULONG handle ; + + strcpy( pathname, PATH_RESSOURCE"*.LBA" ) ; + + rc = _dos_findfirst( pathname, _A_NORMAL, &fileinfo ) ; + while( !rc ) + { + strcpy( pathname, PATH_RESSOURCE ) ; + strcat( pathname, fileinfo.name ) ; + handle = OpenRead( pathname ) ; + if( handle ) + { + Read( handle, &wbyte, 1 ) ; // num version + + *ptrlistname++ = listname ; + do + { + Read( handle, &wbyte, 1 ) ; + *listname++ = wbyte ; + + } while( wbyte != 0 ) ; + + Close( handle ) ; + + nb++ ; + if( nb == MAX_PLAYER ) return nb ; + } + rc = _dos_findnext( &fileinfo ) ; + } + return nb ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +WORD FindPlayerFile() +{ + struct find_t fileinfo ; + ULONG rc ; + UBYTE pathname[_MAX_PATH] ; + UBYTE playername[MAX_SIZE_PLAYER_NAME+1] ; + UBYTE *ptr ; + ULONG handle ; + UBYTE wbyte ; + + strcpy( pathname, PATH_RESSOURCE"*.LBA" ) ; + + rc = _dos_findfirst( pathname, _A_NORMAL, &fileinfo ) ; + while( !rc ) + { + strcpy( pathname, PATH_RESSOURCE ) ; + strcat( pathname, fileinfo.name ) ; + + handle = OpenRead( pathname ) ; + + Read( handle, &wbyte, 1 ) ; // num version + + ptr = playername ; + do + { + Read( handle, &wbyte, 1 ) ; + *ptr++ = wbyte ; + + } while( wbyte != 0 ) ; + + Close( handle ) ; + + if( !stricmp( PlayerName, playername ) ) + { + strcpy( GamePathname, PATH_RESSOURCE ) ; + strcat( GamePathname, fileinfo.name ) ; + return TRUE ; + } + + rc = _dos_findnext( &fileinfo ) ; + } + return FALSE ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void SaveGame() +{ + WORD handle ; + WORD wword ; + UBYTE wbyte ; + + handle = OpenWrite( GamePathname ) ; + if( !handle ) + { + Message( "Error Writing Saved Game", TRUE ) ; + return ; + } + + NumVersion = 3 ; + + Write( handle, &NumVersion, 1 ) ; + + Write( handle, PlayerName, strlen(PlayerName)+1 ) ; + +// list flag game + wbyte = MAX_FLAGS_GAME ; + Write( handle, &wbyte, 1 ) ; // nb octets + Write( handle, ListFlagGame, MAX_FLAGS_GAME ) ; + +// infos jeu + Write( handle, &NumCube, 1 ) ; + Write( handle, &Chapitre, 1 ) ; + Write( handle, &Comportement, 1 ) ; + Write( handle, &ListObjet[NUM_PERSO].LifePoint, 1 ) ; + + Write( handle, &NbGoldPieces, 2 ) ; + + Write( handle, &MagicLevel, 1 ) ; + Write( handle, &MagicPoint, 1 ) ; + Write( handle, &NbCloverBox, 1 ) ; + + Write( handle, &SceneStartX, 2 ) ; + Write( handle, &SceneStartY, 2 ) ; + Write( handle, &SceneStartZ, 2 ) ; + Write( handle, &ListObjet[NUM_PERSO].Beta, 2 ) ; + + Write( handle, &ListObjet[NUM_PERSO].GenBody, 1 ) ; + +// tabholopos + + wbyte = MAX_HOLO_POS ; + Write( handle, &wbyte, 1 ) ; + Write( handle, TabHoloPos, wbyte ) ; + +// others + Write( handle, &Fuel, 1 ) ; + +// used inventory + wbyte = MAX_INVENTORY ; + Write( handle, &wbyte, 1 ) ; // nb octets + Write( handle, ListFlagInventory, MAX_INVENTORY ) ; + +// others + Write( handle, &NbFourLeafClover, 1 ) ; + Write( handle, &Weapon, 2 ) ; + + Close( handle ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void LoadGame() +{ + WORD handle ; + WORD wword ; + UBYTE wbyte ; + UBYTE *ptr ; + + handle = OpenRead( GamePathname ) ; + + Read( handle, &wbyte, 1 ) ; // num version + + ptr = PlayerName ; + do + { + Read( handle, &wbyte, 1 ) ; + *ptr++ = wbyte ; + + } while( wbyte != 0 ) ; + +// list flag game + Read( handle, &wbyte, 1 ) ; // nb octets + Read( handle, ListFlagGame, wbyte ) ; + + NewCube = 0 ; + Read( handle, &NewCube, 1 ) ; + + Read( handle, &Chapitre, 1 ) ; + + Read( handle, &Comportement, 1 ) ; + SaveComportement = Comportement ; + Read( handle, &ListObjet[NUM_PERSO].LifePoint, 1 ) ; + + Read( handle, &NbGoldPieces, 2 ) ; + + Read( handle, &MagicLevel, 1 ) ; + Read( handle, &MagicPoint, 1 ) ; + Read( handle, &NbCloverBox, 1 ) ; + + Read( handle, &SceneStartX, 2 ) ; + Read( handle, &SceneStartY, 2 ) ; + Read( handle, &SceneStartZ, 2 ) ; + Read( handle, &ListObjet[NUM_PERSO].Beta, 2 ) ; + SaveBeta = ListObjet[NUM_PERSO].Beta ; + + Read( handle, &ListObjet[NUM_PERSO].GenBody, 1 ) ; + +// tabholopos + Read( handle, &wbyte, 1 ) ; + Read( handle, TabHoloPos, wbyte ) ; + +// others + Read( handle, &Fuel, 1 ) ; + +// used inventory + Read( handle, &wbyte, 1 ) ; // nb octets + Read( handle, ListFlagInventory, wbyte ) ; + +// others + Read( handle, &NbFourLeafClover, 1 ) ; + Read( handle, &Weapon, 2 ) ; + + + Close( handle ) ; + + NumCube = -1 ; + FlagChgCube = 3 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û ÛÛÜ Û ÛßßßÛ Û Û ßßÛßß ÛÛÜ Û ÛßßßÛ ÛÜ ÜÛ Ûßßßß + ÛÛ ÛÛßÛÛ ÛÛßßß ÛÛ Û ÛÛ ÛÛßÛÛ ÛÛßßÛ ÛÛß Û ÛÛßß + ßß ßß ß ßß ßßßßß ßß ßßßßß ßß ß ßß ß ßß ß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DrawOneString( WORD x, WORD y, UBYTE *playername, WORD draw ) +{ + WORD x2, x0,y0,x1,y1 ; +// UBYTE string[256] ; + + x0 = x - LargeurMenu/2 ; + x1 = x + LargeurMenu/2 ; + + y0 = y - HAUTEUR_STANDARD/2 ; + y1 = y + HAUTEUR_STANDARD/2 ; + + // fond + + if( draw == 0 ) + { + CopyBlock( x0, y0, x1, y1, Screen, x0, y0, Log ) ; + ShadeBox( x0, y0, x1, y1, 4 ) ; + } + if( draw == 1 ) + { + DrawFire( x0, y0, x1, y1, COUL_INPUT_NAME&0xF0 ) ; + } + if( draw == 2 ) + { + Box( x0, y0, x1, y1, 91 ) ; + } + + // cadre + DrawCadre( x0, y0, x1, y1 ) ; + + // text + CoulFont( COUL_TEXT_MENU ) ; + +// if( playername[0] != 0 ) + Font( x - SizeFont( playername )/2, y-18, playername ) ; + + // flip + + CopyBlockPhys( x0,y0, x1,y1 ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DrawSingleString( WORD x, WORD y, UBYTE *string ) +{ + WORD x2, x0,y0,x1,y1 ; + WORD sf ; + + sf = SizeFont( string ) ; + + x0 = x - sf/2 ; + x1 = x + sf/2 ; + + y0 = y - HAUTEUR_STANDARD/2 ; + y1 = y + HAUTEUR_STANDARD/2 ; + + // cadre +// DrawCadre( x0, y0, x1, y1 ) ; + + // text + CoulFont( 0 ) ; + Font( x0 + 4, y-18 + 4, string ) ; + CoulFont( COUL_TEXT_MENU ) ; + Font( x0, y-18, string ) ; + + // flip + CopyBlockPhys( x0,y0, x1,y1 ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +UBYTE TabLetter[NB_CAR_V][NB_CAR_H] = +{ + { ' ','A','B','C','D','E','F','G','H','I','J','K','L','M' } , + { '.','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' } , + { '-','a','b','c','d','e','f','g','h','i','j','k','l','m' } , + { '?','n','o','p','q','r','s','t','u','v','w','x','y','z' } , + { '!','0','1','2','3','4','5','6','7','8','9',' ', 8 , 13 } } ; + +// { ' ','‚','Š','‡','…','“','ˆ','ƒ','Œ','8','9',' ',' ',' ' } , + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +/* +WORD SearchLetter( UBYTE car ) +{ + WORD x, y ; + + for( y=0; y 0 ) PlayerName[len-1] = 0 ; + else car = 0 ; + } + + if( car == A_RETURN ) + { + if( len != 0 ) break ; + else car = 0 ; + } + + if( (car != A_SPACE) AND (car != 0) ) + { + car &= 255 ; + +// if( SearchLetter( car ) ) + if( (car>32) AND (car<255) ) + { + if( len < MAX_SIZE_PLAYER_NAME ) + { + PlayerName[len] = car ; + PlayerName[len+1] = 0 ; + } + } + } + + //////////////// + } + + if( car == A_RETURN ) + { + if( FindPlayerFile() == TRUE ) + { + nummess = 43 ; + goto try_again ; + } + else retval = TRUE ; + } + +#ifdef TRACE + AsciiMode = memoasciimode ; +#else + AsciiMode = FALSE ; +#endif + + CopyScreen( Screen, Log ) ; + Flip() ; + + return retval ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#define NB_GAME_CHOICE 6 + +WORD ChoosePlayerName( WORD mess ) +{ + WORD flag = 1 ; + UBYTE *listplayername ; + UBYTE **ptrlist ; + WORD n, nb ; + WORD start = 0 ; + WORD select = 0 ; + WORD ys = 50 ; + WORD retval = 0 ; + UBYTE string[256] ; + + CopyScreen( Screen, Log ) ; + Flip() ; + + listplayername = Malloc( MAX_PLAYER * (MAX_SIZE_PLAYER_NAME+1) ) ; + ptrlist = (UBYTE**)Malloc( MAX_PLAYER * sizeof(UBYTE*) ) ; + + if( !listplayername OR !ptrlist ) + { + TheEnd( NOT_ENOUGH_MEM, "Choose Player Name" ) ; + } + + nb = PlayerGameList( ptrlist, listplayername ) ; + + if( !nb ) return FALSE ; + + InitDial( 0 ) ; + + DrawSingleString( 320, 40, (UBYTE*)GetMultiText( mess,string ) ) ; + + while( Key != K_ESC ) + { + if( flag == 1 ) + { + for( n=0; n<6; n++ ) + { + if( n+start >= nb ) break ; + if( (n+start) == select ) + { + ys = 50+50+60*n ; + } + DrawOneString( 320, 50+50+60*n, ptrlist[n+start], (n+start) == select ) ; + } + while( Joy OR Fire ) + DrawOneString( 320, ys, ptrlist[select], 1 ) ; + flag = 0 ; + } + + DrawOneString( 320, ys, ptrlist[select], 1 ) ; + + if( Joy & J_DOWN ) + { + if( select < (nb-1) ) + { + DrawOneString( 320, ys, ptrlist[select], 0 ) ; + select++ ; + flag = 1 ; + } + + if( select >= (start + 6) ) + { + if( start < (nb-1) ) + { + start++ ; + } + } + } + + if( Joy & J_UP ) + { + if( select > 0 ) + { + DrawOneString( 320, ys, ptrlist[select], 0 ) ; + select-- ; + flag = 1 ; + } + if( select < start ) + { + start-- ; + } + } + + if( Fire ) + { + retval = 1 ; + break ; + } + } + + strcpy( PlayerName, ptrlist[select] ) ; + FindPlayerFile() ; + + Free( ptrlist ) ; + Free( listplayername ) ; + + CopyScreen( Screen, Log ) ; + Flip() ; + + return retval ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛÜ ÜÛ Ûßßßß ÛÛÜ Û Û Û + ÛÛß Û ÛÛßß ÛÛßÛÛ ÛÛ Û + ßß ß ßßßßß ßß ß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DrawOneChoice( WORD x, WORD y, WORD type, WORD num, WORD select ) +{ + WORD x2, x0,y0,x1,y1 ; + UBYTE string[256] ; + ULONG volleft, volright ; + + x0 = x - LargeurMenu/2 ; + x1 = x + LargeurMenu/2 ; + + y0 = y - HAUTEUR_STANDARD/2 ; + y1 = y + HAUTEUR_STANDARD/2 ; + + // fond + + if( select ) + { + switch( type ) + { + case 1: // music volume + x2 = RegleTrois32( x0, x1, 255, MusicVolume ) ; + DrawFire( x0, y0, x2, y1, 91&0xF0 ) ; + Box( x2, y0, x1, y1, COUL_SELECT_MENU ) ; + break ; + + case 2: // sample volume + x2 = RegleTrois32( x0, x1, 255, SampleVolume ) ; + DrawFire( x0, y0, x2, y1, 91&0xF0 ) ; + Box( x2, y0, x1, y1, COUL_SELECT_MENU ) ; + break ; + + case 3: // CD volume + x2 = RegleTrois32( x0, x1, 255, CDVolume ) ; + DrawFire( x0, y0, x2, y1, 91&0xF0 ) ; + Box( x2, y0, x1, y1, COUL_SELECT_MENU ) ; + break ; + + case 4: // Line volume + x2 = RegleTrois32( x0, x1, 255, LineVolume ) ; + DrawFire( x0, y0, x2, y1, 91&0xF0 ) ; + Box( x2, y0, x1, y1, COUL_SELECT_MENU ) ; + break ; + + case 5: // Master volume + x2 = RegleTrois32( x0, x1, 255, MasterVolume ) ; + DrawFire( x0, y0, x2, y1, 91&0xF0 ) ; + Box( x2, y0, x1, y1, COUL_SELECT_MENU ) ; + break ; + default: +// Box( x0, y0, x1, y1, COUL_SELECT_MENU ) ; + DrawFire( x0, y0, x1, y1, COUL_SELECT_MENU&0xF0 ) ; + } + + if( (type >= 1) AND (type<=5) ) + { + // bruitons un peu la situation (violement) + + DoLoopMidi() ; + + if( (TimerRef-TimerSample) > 30 ) + { + TimerSample = TimerRef ; + Balance( rand()&127, 128, &volleft, &volright ); + HQ_MixSample( 34+((rand()&7)>0)*92, 0x1000, 1, volleft, volright ) ; +// HQ_MixSample( Rnd( 50 ), 0x1000, 1, volleft, volright ) ; + } + } + + } + else + { + CopyBlock( x0, y0, x1, y1, Screen, x0, y0, Log ) ; + ShadeBox( x0, y0, x1, y1, 4 ) ; + } + + // cadre + DrawCadre( x0, y0, x1, y1 ) ; + + // text + + CoulFont( COUL_TEXT_MENU ) ; + GetMultiText( num, string ) ; + + Font( x - SizeFont( string )/2, y-18, string ) ; + + // flip + + CopyBlockPhys( x0,y0, x1,y1 ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DrawGameMenu( UWORD *ptrmenu, WORD justone ) +{ + WORD n, y ; + WORD nb ; + WORD selected, type, num ; + + selected = *ptrmenu++ ; + + nb = *ptrmenu++ ; + + y = *ptrmenu++ ; + + ptrmenu++ ; // dial num + + if( y == 0 ) // depuis le haut + { + y = HAUTEUR_STANDARD/2 + 10 ; + } + else // centre sur y + { + y -= ( HAUTEUR_STANDARD*nb + (nb-1)*MENU_SPACE ) / 2 ; + } + + for( n=0; n 50 * 60) + OR ((Key == K_C) AND (Fire & F_SHIFT)) ) +#else + if( (TimerRef - chrono > 50 * (60 * 3 + 53) ) + OR ((Key == K_C) AND (Fire & F_SHIFT)) ) +#endif + { + chrono = TimerRef ; + return 9999 ; + } + } + + MyJoy = Joy ; + + if( MyJoy & J_DOWN ) + { + selected++ ; + if( selected == nb ) selected = 0 ; + flag = 1 ; + } + + if( MyJoy & J_UP ) + { + selected-- ; + if( selected < 0 ) selected = nb - 1 ; + flag = 1 ; + } + + switch( ptrmenu[4 + 0 + selected*2] ) // type + { + case 0: // text normal + break ; + + case 1: // volume music + + if ( flag ) flagVol = 3 ; + + if( (MyJoy & J_LEFT) ) + { + MusicVolume -= 4 ; + flagVol = 3 ; + } + if( (MyJoy & J_RIGHT) ) + { + MusicVolume += 4 ; + flagVol = 3 ; + } + break ; + + case 2: // volume sample + + if ( flag ) flagVol = 3 ; + + if( (MyJoy & J_LEFT) ) + { + SampleVolume -= 4 ; + flagVol = 3 ; + } + if( (MyJoy & J_RIGHT) ) + { + SampleVolume += 4 ; + flagVol = 3 ; + } + break ; + + case 3: // volume cd + + if ( flag ) flagVol = 4 ; + + if( (MyJoy & J_LEFT) ) + { + CDVolume -= 4 ; + flagVol = 4 ; + } + if( (MyJoy & J_RIGHT) ) + { + CDVolume += 4 ; + flagVol = 4 ; + } + break ; + + case 4: // volume Line + + if ( flag ) flagVol = 5 ; + + if( (MyJoy & J_LEFT) ) + { + LineVolume -= 4 ; + flagVol = 5 ; + } + if( (MyJoy & J_RIGHT) ) + { + LineVolume += 4 ; + flagVol = 5 ; + } + break ; + + case 5: // volume master + + if ( flag ) flagVol = 2 ; + + if( (MyJoy & J_LEFT) ) + { + MasterVolume -= 4 ; + flagVol = 2 ; + } + if( (MyJoy & J_RIGHT) ) + { + MasterVolume += 4 ; + flagVol = 2 ; + } + break ; + } + + if( flag == 1 ) + { + ptrmenu[0] = selected ; + DrawGameMenu( ptrmenu, FALSE ) ; + while( Joy OR Fire OR Key ) + DrawGameMenu( ptrmenu, TRUE ) ; + flag = 0 ; + } + else + { +// Vsync() ; + if( flagVol ) + { + if( MusicVolume > 255 ) MusicVolume = 255 ; + if( SampleVolume > 255 )SampleVolume = 255 ; + if( LineVolume > 255 ) LineVolume = 255 ; + if( CDVolume > 255 ) CDVolume = 255 ; + if( MasterVolume > 255 )MasterVolume = 255 ; + + if( MusicVolume < 0 ) MusicVolume = 0 ; + if( SampleVolume < 0 ) SampleVolume = 0 ; + if( LineVolume < 0 ) LineVolume = 0 ; + if( CDVolume < 0 ) CDVolume = 0 ; + if( MasterVolume < 0 ) MasterVolume = 0 ; + + switch ( flagVol ) + { + case 3: + SetVolumes(MusicVolume, SampleVolume, 0, 0, MasterVolume ) ; + break; + case 4: + SetVolumes(0, SampleVolume, 0, CDVolume, MasterVolume ) ; + break; + case 5: + SetVolumes(0, SampleVolume, LineVolume, 0, MasterVolume ) ; + break; + default: + SetVolumes(MusicVolume, SampleVolume, LineVolume, CDVolume, MasterVolume ) ; + } + } + DrawGameMenu( ptrmenu, TRUE ) ; + flagVol = 0 ; + flag = 0 ; + } + + if( Fire & F_RETURN + OR Fire & F_SPACE ) + { + return ptrmenu[4 + 1 + selected*2] ; // num mess + } + +// if( Key == K_ESC ) break ; + } + return -1 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +LONG OptionsMenu() +{ + WORD select ; + WORD flag = 0 ; + + CopyScreen( Log, Screen ) ; + + HQ_StopSample() ; +#ifdef CDROM + PlayCdTrack( 9 ) ; +#else + PlayMidiFile( 9 ) ; +#endif + + while( !flag ) + { + select = DoGameMenu( GameOptionMenu ) ; + + switch( select ) // num mess + { +/* case -1: // esc + flag = 1 ; + break ; +*/ + case 15: // retour au jeu + case 26: // menu prec. + flag = 1 ; + break ; + + case 47: + CopyScreen( Screen, Log ) ; + Flip() ; + AdvancedOptions() ; + break ; + + case 30: + CopyScreen( Screen, Log ) ; + Flip() ; + VolumeOptions() ; + break ; + + case 46: + CopyScreen( Screen, Log ) ; + Flip() ; + SavedGameManagement() ; + break ; + } + } + CopyScreen( Screen, Log ) ; + Flip() ; + + return FALSE ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void VolumeOptions() +{ + WORD select ; + WORD flag = 0 ; + + CopyScreen( Log, Screen ) ; + +#ifdef CDROM + PlayAllMusic( 9 ) ; // he oui on lance les 2 +#else + PlayMidiFile( 9 ) ; +#endif + + TimerSample = TimerRef ; + + while( !flag ) + { + select = DoGameMenu( GameVolumeMenu ) ; + + switch( select ) // num mess + { +/* case -1: // esc + flag = 1 ; + break ; +*/ + case 26: // quitter +#ifdef CDROM + FadeMusicMidi( 1 ) ; +#endif + SetVolumes(MusicVolume, SampleVolume, LineVolume, CDVolume, MasterVolume ) ; + flag = 1 ; + break ; + + case 16: + SetVolumes(MusicVolume, SampleVolume, LineVolume, CDVolume, MasterVolume ) ; + WriteVolumeSettings() ; + GameVolumeMenu[0] = 0 ; // selected + break ; + } + } + CopyScreen( Screen, Log ) ; + Flip() ; +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void SavedGameManagement() +{ + WORD select ; + WORD flag = 0 ; + UBYTE memoplayername[MAX_SIZE_PLAYER_NAME] ; + UBYTE memogamepath[_MAX_PATH] ; + + CopyScreen( Log, Screen ) ; + + strcpy( memoplayername, PlayerName ) ; + strcpy( memogamepath, GamePathname ) ; + + while( !flag ) + { + select = DoGameMenu( SavedGameMenu ) ; + + switch( select ) // num mess + { + case 26: // quitter + flag = 1 ; + break ; + + case 41: // copier + if( ChoosePlayerName( 41 ) ) + { + UBYTE *ptr,*ptrs ; + LONG size ; + UBYTE num ; + UBYTE n,c ; + LONG handle ; + + ptrs = ptr = LoadMalloc( GamePathname ) ; + size = FileSize( GamePathname ) ; + num = *ptr++ ; // num version + n = strlen( ptr ) + 1 ; // size player name + + if( InputPlayerName( 44 ) ) + { + do + { + strcpy( GamePathname, PATH_RESSOURCE"S" ) ; + strcat( GamePathname, Itoa( Rnd(10000) ) ) ; + strcat( GamePathname, ".LBA" ) ; + } + while( FileSize( GamePathname ) != 0 ) ; + + handle = OpenWrite( GamePathname ) ; + if( handle ) + { + Write( handle, &num, 1 ) ; + Write( handle, PlayerName, strlen(PlayerName)+1 ) ; + Write( handle, ptrs+n+1, size-n-1 ) ; + Close( handle ) ; + } + } + Free( ptrs ) ; + } + CopyScreen( Screen, Log ) ; + break ; + + case 45: // detruire + if( ChoosePlayerName( 45 ) ) + { + CopyScreen( Screen, Log ) ; + + DrawOneString( 320, 80, PlayerName, 2 ) ; + + SavedConfirmMenu[0] = 0 ; + select = DoGameMenu( SavedConfirmMenu ) ; + + switch( select ) // num mess + { + case 48: // detruire + Delete( GamePathname ) ; + break ; + } + } + SavedGameMenu[0] = 0 ; + CopyScreen( Screen, Log ) ; + Flip() ; +// flag = 1 ; + break ; + } + } + CopyScreen( Screen, Log ) ; + Flip() ; + + strcpy( GamePathname, memogamepath ) ; + strcpy( PlayerName, memoplayername ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void AdvancedOptions() +{ + WORD select ; + WORD flag = 0 ; + + CopyScreen( Log, Screen ) ; + + while( !flag ) + { + select = DoGameMenu( GameAdvancedMenu ) ; + + switch( select ) // num mess + { + case 26: + flag = 1 ; + break ; + + case 4: // agressif auto + GameAdvancedMenu[7] = 2 ; + CombatAuto = FALSE ; + break ; + + case 2: // agressif manuel + GameAdvancedMenu[7] = 4 ; + CombatAuto = TRUE ; + break ; + case 31: // poly high + GameAdvancedMenu[9] = 131 ; + SetFillDetails( 1 ) ; + break ; + case 131: // poly medium + GameAdvancedMenu[9] = 231 ; + SetFillDetails( 0 ) ; + break ; + case 231: // poly low + GameAdvancedMenu[9] = 31 ; + SetFillDetails( 2 ) ; + break ; + + case 32: // ombres full + GameAdvancedMenu[11] = 132 ; + Shadow = 1 ; + break ; + case 132: // ombres obj + GameAdvancedMenu[11] = 232 ; + Shadow = 0 ; + break ; + case 232: // pas ombres + GameAdvancedMenu[11] = 32 ; + Shadow = 2 ; + break ; + + case 33: // zoom hard + GameAdvancedMenu[13] = 233 ; + SceZoom = 0 ; + break ; + + case 233: // pas zoom + GameAdvancedMenu[13] = 33 ; + SceZoom = 1 ; + break ; + +/* case 233: // zoom soft + GameAdvancedMenu[13] = 33 ; + SceZoom = 2 ; + break ; +*/ + } + } + CopyScreen( Screen, Log ) ; + Flip() ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +LONG MainGameMenu() +{ + WORD select ; + WORD flag = 0 ; + + HQ_StopSample() ; + + +/* for( flag=0; flag<50*320; flag++ ) + { + BufSpeak[flag] = 0 ; + } + flag = 0; +*/ + + CopyScreen( Log, Screen ) ; + + while( !flag ) + { + InitDial( 0 ) ;// SYS + +#ifdef CDROM + PlayCdTrack( 9 ) ; +#else + PlayMidiFile( 9 ) ; +#endif + HQ_StopSample() ; + + GetMultiText( 49, PleaseWait ) ; + + select = DoGameMenu( GameMainMenu ) ; + switch( select ) // num mess + { + case 9999: // menu demo + + MenuDemo() ; + Load_HQR( PATH_RESSOURCE"ress.hqr", Screen, RESS_MENU_PCR ) ; + CopyScreen( Screen, Log ) ; + SetBlackPal() ; + Flip() ; + FadeToPal( PtrPal ) ; + break ; + +// case -1: // esc + case 22: // quitter + flag = 1 ; + break ; + + case 20: // newgame + + if( !InputPlayerName( 42 ) ) break ; + + do + { + strcpy( GamePathname, PATH_RESSOURCE"S" ) ; + strcat( GamePathname, Itoa( Rnd(10000) ) ) ; + strcat( GamePathname, ".LBA" ) ; + } + while( FileSize( GamePathname ) != 0 ) ; + + InitGame( 1, 0 ) ; + Introduction() ; + if( MainLoop() ) + { +#ifdef DEMO + PlayMidiFile( 6 ) ; + Credits() ; + TheEnd( PROGRAM_OK, "* End of Demo version." ) ; +#else + Credits() ; + PlayAnimFla( "The_End" ) ; + Cls() ; + Flip() ; + Palette( PtrPal ) ; +#endif + } + + CopyScreen( Log, Screen ) ; + while( Key OR Fire ) ; // provisoire + break ; + + case 21: // load + + if( !ChoosePlayerName( 21 ) ) break ; + + InitGame( -1, 0 ) ; + Introduction() ; + if( MainLoop() ) + { +#ifdef DEMO + PlayMidiFile( 6 ) ; + Credits() ; + TheEnd( PROGRAM_OK, "* End of Demo version." ) ; +#else + Credits() ; + PlayAnimFla( "The_End" ) ; + Cls() ; + Flip() ; + Palette( PtrPal ) ; +#endif + } + CopyScreen( Log, Screen ) ; + while( Key OR Fire ) ; // provisoire + break ; + + case 23: + CopyScreen( Screen, Log ) ; + Flip() ; + GameOptionMenu[5] = 26 ; // retour prec + OptionsMenu() ; + break ; + } + } + return FALSE ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +LONG QuitMenu() +{ + WORD select ; + LONG memoflagspeak ; + + CopyScreen( Log, Screen ) ; + HQ_StopSample() ; + + while( TRUE ) + { + memoflagspeak = FlagSpeak ; + FlagSpeak = FALSE ; + InitDial( 0 ) ;// SYS + FlagSpeak = memoflagspeak ; + + select = DoGameMenu( GameQuitMenu ) ; + + InitDial( START_FILE_ISLAND+Island ) ;// SYS + + switch( select ) // num mess + { + case 28: // continue + return FALSE ; + + case 27: // abandonner + return TRUE ; + } + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Ûßßßß ÛßßßÛ ÛÜ ÜÛ Ûßßßß Ûßßßß Û Û ÛßßßÛ Û Ûßßßß Ûßßßß + ÛÛ ßÛ ÛÛßßÛ ÛÛß Û ÛÛßß ÛÛ ÛÛßßÛ ÛÛ Û ÛÛ ÛÛ ÛÛßß + ßßßßß ßß ß ßß ß ßßßßß ßßßßß ßßßßß ßß ß ßßßßß ßß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* +UWORD GameChoiceMenu[] = { + 0, // selected + 7, // nb entries + 0, // y from top. + 0, // .dia num + + 0, 0, + 0, 1, + 0, 2, + 0, 3, + 0, 4, + 0, 5, + 0, 6 } ; +*/ + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void GameAskChoice( WORD nummess ) +{ + WORD n ; + + CopyScreen( Log, Screen ) ; + + GameChoiceMenu[0] = 0 ; + GameChoiceMenu[1] = GameNbChoices ; + GameChoiceMenu[2] = 0 ; + GameChoiceMenu[3] = START_FILE_ISLAND+Island ; + for(n=0; nLifePoint <= 0 ) + { + Value = -1 ; + } + else + { + Value = ptrobj->ObjCol ; + } + break ; + + case LF_CHAPTER: + Value = Chapitre ; + break ; + + case LF_LIFE_POINT: + Value = ptrobj->LifePoint ; + break ; + + case LF_HIT_BY: + Value = ptrobj->HitBy ; + break ; + + case LF_ACTION: + Value = ActionNormal ; + break ; + + case LF_LIFE_POINT_OBJ: + Value = ListObjet[*PtrPrg++].LifePoint ; + break ; + + case LF_COL_OBJ: +// Value = ListObjet[*PtrPrg++].ObjCol ; + num = *PtrPrg++ ; + if( ListObjet[num].LifePoint <= 0 ) + { + Value = -1 ; + } + else + { + Value = ListObjet[num].ObjCol ; + } + break ; + + case LF_DISTANCE: + num = (WORD)*PtrPrg++ ; + TypeAnswer = RET_WORD ; + + if( ListObjet[num].WorkFlags & OBJ_DEAD ) + { + Value = 32000 ; + break ; + } + + if( abs(ListObjet[num].PosObjY-ptrobj->PosObjY) < 1500 ) + { + distance = Distance2D( ptrobj->PosObjX, + ptrobj->PosObjZ, + ListObjet[num].PosObjX, + ListObjet[num].PosObjZ ) ; + if( distance > 32000 ) + Value = 32000 ; + else + Value = distance ; + } + else + { + Value = 32000 ; + } + break ; + + case LF_DISTANCE_3D: + num = (WORD)*PtrPrg++ ; + TypeAnswer = RET_WORD ; + + if( ListObjet[num].WorkFlags & OBJ_DEAD ) + { + Value = 32000 ; + break ; + } + + distance = Distance3D( ptrobj->PosObjX, + ptrobj->PosObjY, + ptrobj->PosObjZ, + ListObjet[num].PosObjX, + ListObjet[num].PosObjY, + ListObjet[num].PosObjZ ) ; + + if( distance > 32000 ) + Value = 32000 ; + else + Value = distance ; + break ; + + case LF_CONE_VIEW: + num = (WORD)*PtrPrg++ ; + TypeAnswer = RET_WORD ; + + if( ListObjet[num].WorkFlags & OBJ_DEAD ) + { + Value = 32000 ; + break ; + } + + if( abs(ListObjet[num].PosObjY-ptrobj->PosObjY) < 1500 ) + { + angle = GetAngle( ptrobj->PosObjX, + ptrobj->PosObjZ, + ListObjet[num].PosObjX, + ListObjet[num].PosObjZ ) ; + + if( Distance > 32000 ) + Distance = 32000 ; + } + else + { + Distance = 32000 ; + } + + + if( num == NUM_PERSO ) + { + if( Comportement == C_DISCRET ) + { + if( (((ptrobj->Beta + 1024 + 128) - (angle + 1024))&1023) <= 256 ) + { + Value = Distance ; + } + else + { + Value = 32000 ; + } + } + else Value = Distance ; + } + else + { + if( (((ptrobj->Beta + 1024 + 128) - (angle + 1024))&1023) <= 256 ) + { + Value = Distance ; + } + else + { + Value = 32000 ; + } + } + break ; + + case LF_ZONE: + Value = ptrobj->ZoneSce ; + break ; + + case LF_NB_GOLD_PIECES: + Value = NbGoldPieces ; + TypeAnswer = RET_WORD ; + break ; + + case LF_NB_LITTLE_KEYS: + Value = NbLittleKeys ; + break ; + + case LF_COMPORTEMENT_HERO: + Value = Comportement ; + break ; + + case LF_MAGIC_LEVEL: + Value = MagicLevel ; + break ; + + case LF_MAGIC_POINT: + Value = MagicPoint ; + break ; + + case LF_CHOICE: + Value = GameChoice ; + TypeAnswer = RET_WORD ; + break ; + + case LF_FUEL: + Value = Fuel ; + break ; + + case LF_L_TRACK: + Value = ptrobj->LabelTrack ; + break ; + + case LF_ZONE_OBJ: + Value = ListObjet[ *PtrPrg++ ].ZoneSce ; + break ; + + case LF_FLAG_CUBE: + Value = ListFlagCube[ *PtrPrg++ ] ; + break ; + + case LF_FLAG_GAME: + num = *PtrPrg++ ; + + if( (ListFlagGame[FLAG_CONSIGNE] == 0) + OR (num >= MAX_INVENTORY) ) + { // si pas consigne ou pas inventaire + Value = ListFlagGame[ num ] ; + } + else // si flag consigne + { + if( num == FLAG_CONSIGNE ) + { + Value = ListFlagGame[ num ] ; + } + else // ne possede aucun objet + { + Value = 0 ; + } + } + break ; + + case LF_USE_INVENTORY: + num = *PtrPrg++ ; // flag game + + if( num >= MAX_INVENTORY ) // a bon ? + { + Value = FALSE ; + } + + if( ListFlagGame[FLAG_CONSIGNE] ) + { + Value = 0 ; + } + else // si pas flag consigne + { + if( InventoryAction == num ) + { // action ‚mise depuis l'inventaire … cette boucle + Value = TRUE ; + } + else + { + if( (ListFlagInventory[ num ] == 1) + AND (ListFlagGame[num] == 1) ) + { + Value = TRUE ; + } + else + { + Value = FALSE ; + } + } + if( Value == TRUE ) + { + // init incdisp symbol utilisation + InitIncrustDisp( INCRUST_OBJ, + num, + 0, 0, + 0, 0, 3 ) ; + } + } + break ; + + case LF_L_TRACK_OBJ: + Value = ListObjet[ *PtrPrg++ ].LabelTrack ; + break ; + + case LF_BODY: + Value = ptrobj->GenBody ; + break ; + + case LF_BODY_OBJ: + Value = ListObjet[*PtrPrg++].GenBody ; + break ; + + case LF_ANIM: + Value = ptrobj->GenAnim ; + break ; + + case LF_ANIM_OBJ: + Value = ListObjet[*PtrPrg++].GenAnim ; + break ; + + case LF_CARRY_BY: + Value = ptrobj->CarryBy ; + break ; + + case LF_CDROM: +#ifdef CDROM +//Message( "CDROM TRUE" ) ; + Value = 1 ; +#else +//Message( "CDROM FALSE" ) ; + Value = 0 ; +#endif + break ; + + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +WORD DoTest() +{ + UBYTE test ; + WORD valueword ; + BYTE valuebyte ; + UBYTE *ptrstring ; + + test = *PtrPrg++ ; + + switch( TypeAnswer ) + { + case RET_BYTE: + + valuebyte = *PtrPrg++ ; + switch( test ) + { + case LT_EQUAL: + return (Value == valuebyte) ; + + case LT_SUP: + return (Value > valuebyte) ; + + case LT_LESS: + return (Value < valuebyte) ; + + case LT_SUP_EQUAL: + return (Value >= valuebyte) ; + + case LT_LESS_EQUAL: + return (Value <= valuebyte) ; + + case LT_DIFFERENT: + return (Value != valuebyte) ; + } + + case RET_WORD: + + valueword = *(WORD*)PtrPrg ; + PtrPrg += 2 ; + switch( test ) + { + case LT_EQUAL: + return (Value == valueword) ; + + case LT_SUP: + return (Value > valueword) ; + + case LT_LESS: + return (Value < valueword) ; + + case LT_SUP_EQUAL: + return (Value >= valueword) ; + + case LT_LESS_EQUAL: + return (Value <= valueword) ; + + case LT_DIFFERENT: + return (Value != valueword) ; + } + + case RET_STRING: + + valueword = stricmp( String, PtrPrg ) ; + PtrPrg += strlen( PtrPrg ) + 1 ; + + switch( test ) + { + case LT_EQUAL: + return (valueword == 0 ) ; + + case LT_SUP: + case LT_LESS: + case LT_SUP_EQUAL: + case LT_LESS_EQUAL: + return FALSE ; + + case LT_DIFFERENT: + return (valueword != 0 ) ; + } + } + return FALSE ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + + +void DoLife( WORD numobj ) +{ + WORD flag = 0 ; + UBYTE macro ; + T_OBJET *ptrobj ; + + LONG obj ; + LONG num ; + UBYTE index ; + UBYTE *ptrmacro ; + LONG memoflagdisplaytext ; + LONG var ; + UBYTE string[256] ; + LONG dx, n ; + + ptrobj = &ListObjet[numobj] ; + + PtrPrg = ptrobj->PtrLife + ptrobj->OffsetLife ; + + while( flag != -1 ) + { + ptrmacro = PtrPrg ; + switch( *PtrPrg++ ) + { + case LM_END: + case LM_END_LIFE: + ptrobj->OffsetLife = -1 ; + flag = -1 ; + break ; + + case LM_RETURN: + case LM_END_COMPORTEMENT: + flag = -1 ; + break ; + + case LM_LABEL: + case LM_COMPORTEMENT: +#ifdef LBA_EDITOR + if ( numobj == ObjSelected )/* TOOLS */ + { + ComportementDebug = *PtrPrg ; + } +#endif + PtrPrg++ ; + break ; + + case LM_FALLABLE: + num = *PtrPrg++ * OBJ_FALLABLE ; + ptrobj->Flags &= ~OBJ_FALLABLE ; + ptrobj->Flags |= num ; + break ; + + case LM_COMPORTEMENT_HERO: + InitAnim( GEN_ANIM_RIEN, ANIM_REPEAT, NO_ANIM, NUM_PERSO ) ; + SetComportement( *PtrPrg++ ) ; + break ; + + case LM_SET_MAGIC_LEVEL: +// si sce permet objets magique ordre quelconque transforme SET en INC + MagicLevel = *PtrPrg++ ; + // remplie magie a fond + MagicPoint = MagicLevel * 20 ; + break ; + + case LM_SUB_MAGIC_POINT: + MagicPoint -= *PtrPrg++ ; + if( MagicPoint < 0 ) MagicPoint = 0 ; + break ; + + case LM_CAM_FOLLOW: + num = *PtrPrg++ ; + if( num != NumObjFollow ) + { + NumObjFollow = num ; + StartXCube = ((ListObjet[NumObjFollow].PosObjX+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + StartYCube = ((ListObjet[NumObjFollow].PosObjY+SIZE_BRICK_Y)/SIZE_BRICK_Y) ; + StartZCube = ((ListObjet[NumObjFollow].PosObjZ+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + FirstTime = TRUE ; + } + break ; + + case LM_INIT_PINGOUIN: + num = *PtrPrg++ ; + NumPingouin = num ; + ListObjet[num].WorkFlags |= OBJ_DEAD ; + ListObjet[num].Body = -1 ; + ListObjet[num].ZoneSce = -1 ; + break ; + + case LM_KILL_OBJ: + num = *PtrPrg++ ; + CheckCarrier( num ) ; + ListObjet[num].WorkFlags |= OBJ_DEAD ; + ListObjet[num].Body = -1 ; + ListObjet[num].ZoneSce = -1 ; + ListObjet[num].LifePoint = 0 ; + break ; + + case LM_SUICIDE: + CheckCarrier( numobj ) ; + ptrobj->WorkFlags |= OBJ_DEAD ; + ptrobj->Body = -1 ; + ptrobj->ZoneSce = -1 ; + ptrobj->LifePoint = 0 ; + break ; + + case LM_SET_DIR: + ptrobj->Move = *PtrPrg++ ; + if( ptrobj->Move == MOVE_FOLLOW ) + { + ptrobj->Info3 = *PtrPrg++ ; + } + break ; + + case LM_SET_DIR_OBJ: + obj = *PtrPrg++ ; + num = ListObjet[obj].Move = *PtrPrg++ ; + if( num == MOVE_FOLLOW ) + { + ListObjet[obj].Info3 = *PtrPrg++ ; + } + break ; + + case LM_SET_LIFE: + case LM_SET_COMPORTEMENT: + ptrobj->OffsetLife = *(WORD*)PtrPrg ; + PtrPrg += 2 ; + break ; + + case LM_SET_LIFE_OBJ: + case LM_SET_COMPORTEMENT_OBJ: + num = *PtrPrg++ ; + ListObjet[num].OffsetLife = *(WORD*)PtrPrg ; + PtrPrg += 2 ; + break ; + + case LM_SET_LIFE_POINT_OBJ: + num = *PtrPrg++ ; + ListObjet[num].LifePoint = *PtrPrg++ ; + break ; + + case LM_SUB_LIFE_POINT_OBJ: + num = *PtrPrg++ ; + ListObjet[num].LifePoint -= *PtrPrg++ ; + if( ListObjet[num].LifePoint < 0 ) + ListObjet[num].LifePoint = 0 ; + break ; + + case LM_HIT_OBJ: + num = *PtrPrg++ ; + HitObj( numobj, num, *PtrPrg++, ListObjet[num].Beta ) ; + break ; + + case LM_SET_TRACK: + ptrobj->OffsetTrack = *(WORD*)PtrPrg ; + PtrPrg += 2 ; + break ; + + case LM_SET_TRACK_OBJ: + num = *PtrPrg++ ; + ListObjet[num].OffsetTrack = *(WORD*)PtrPrg ; + PtrPrg += 2 ; + break ; + + case LM_STOP_L_TRACK: + ptrobj->MemoLabelTrack = ptrobj->OffsetLabelTrack ; + ptrobj->OffsetTrack = -1 ; + break ; + + case LM_RESTORE_L_TRACK: + ptrobj->OffsetTrack = ptrobj->MemoLabelTrack ; + break ; + + case LM_IF: + DoFuncLife( ptrobj ) ; + if( !DoTest() ) + { + PtrPrg = ptrobj->PtrLife + *(WORD*)PtrPrg ; + } + else + { + PtrPrg += 2 ; + } + break ; + + case LM_OR_IF: + DoFuncLife( ptrobj ) ; + if( DoTest() ) + { + PtrPrg = ptrobj->PtrLife + *(WORD*)PtrPrg ; + } + else + { + PtrPrg += 2 ; + } + break ; + + case LM_SWIF: + DoFuncLife( ptrobj ) ; + if( !DoTest() ) + { + PtrPrg = ptrobj->PtrLife + *(WORD*)PtrPrg ; + } + else + { + *ptrmacro = LM_SNIF ; + PtrPrg += 2 ; + } + break ; + + case LM_SNIF: /* swif invers‚ tjrs jump jusqu'a cond inverse */ + DoFuncLife( ptrobj ) ; + if( !DoTest() ) + { + *ptrmacro = LM_SWIF ; + } + PtrPrg = ptrobj->PtrLife + *(WORD*)PtrPrg ; + break ; + + case LM_ONEIF: + DoFuncLife( ptrobj ) ; + if( !DoTest() ) + { + PtrPrg = ptrobj->PtrLife + *(WORD*)PtrPrg ; + } + else + { + PtrPrg += 2 ; + *ptrmacro = LM_NEVERIF ; + } + break ; + + case LM_NEVERIF: + DoFuncLife( ptrobj ) ; + DoTest() ; + PtrPrg = ptrobj->PtrLife + *(WORD*)PtrPrg ; + break ; + + case LM_OFFSET: /* jmp … offset */ + PtrPrg = ptrobj->PtrLife + *(WORD*)PtrPrg ; + break ; + + case LM_ELSE: + PtrPrg = ptrobj->PtrLife + *(WORD*)PtrPrg ; + break ; + + case LM_BODY: + InitBody( *PtrPrg++, numobj ) ; + break ; + + case LM_BODY_OBJ: + num = *PtrPrg++ ; + InitBody( *PtrPrg++, num ) ; + break ; + + case LM_ANIM_OBJ: + num = *PtrPrg++ ; + InitAnim( *PtrPrg++, ANIM_REPEAT,0, num ) ; + break ; + + case LM_ANIM: + InitAnim( *PtrPrg++, ANIM_REPEAT,0,numobj ) ; + break ; + + case LM_ANIM_SET: + ptrobj->GenAnim = NO_ANIM ; + ptrobj->Anim = -1 ; + InitAnim( *PtrPrg++, ANIM_REPEAT,0,numobj ) ; + break ; + + case LM_MESSAGE_OBJ: + SaveTimer() ; + TestRestoreModeSVGA( TRUE ) ; + num = *PtrPrg++ ; + if( Bulle ) DrawBulle( num ) ; + TestCoulDial( ListObjet[num].CoulObj ) ; +#ifdef CDROM + NumObjSpeak = num ; +#endif + Dial( *(WORD*)PtrPrg ) ; + PtrPrg += 2 ; + RestoreTimer() ; + + AffScene(TRUE) ; + WaitReleaseSpace() ; + break ; + + case LM_MESSAGE: + SaveTimer() ; + TestRestoreModeSVGA( TRUE ) ; + if( Bulle ) DrawBulle( numobj ) ; + TestCoulDial( ptrobj->CoulObj ) ; +#ifdef CDROM + NumObjSpeak = numobj ; +#endif + Dial( *(WORD*)PtrPrg ) ; + PtrPrg += 2 ; + RestoreTimer() ; + AffScene(TRUE) ; + WaitReleaseSpace() ; + break ; + + case LM_SAY_MESSAGE_OBJ: + obj = *PtrPrg++ ; + num = *(WORD*)PtrPrg ; + InitIncrustDisp( INCRUST_TEXT, + num, + 0, 0, + obj, 1, 2 ) ; + PtrPrg += 2 ; +#ifdef CDROM + SaveTimer() ; + Speak( num ) ; + RestoreTimer() ; +#endif + break ; + + case LM_SAY_MESSAGE: + num = *(WORD*)PtrPrg ; + InitIncrustDisp( INCRUST_TEXT, + num, + 0, 0, + numobj, 1, 2 ) ; + PtrPrg += 2 ; +#ifdef CDROM + SaveTimer() ; + Speak( num ) ; + RestoreTimer() ; +#endif + break ; + + case LM_SET_FLAG_CUBE: + num = *PtrPrg++ ; + ListFlagCube[num] = *PtrPrg++ ; + break ; + + case LM_SET_FLAG_GAME: + num = *PtrPrg++ ; + ListFlagGame[num] = *PtrPrg++ ; + +//Text( 0,100, "%Fset ListFlagGame %d = %d",num,ListFlagGame[num] ) ; + + break ; + + case LM_SET_USED_INVENTORY: + num = *PtrPrg++ ; + if( num < 24 ) + ListFlagInventory[num] = TRUE ; + break ; + + case LM_GIVE_GOLD_PIECES: + num = NbGoldPieces ; + NbGoldPieces -= *(WORD*)PtrPrg ; + if( NbGoldPieces < 0 ) + { + NbGoldPieces = 0 ; + } + PtrPrg += 2 ; + + // sample cling cling +// HQ_MixSample( 83, 0x1000, 2, 128, 128 ) ; + + // aff piece + InitIncrustDisp( INCRUST_SPRITE, + 3, + 10, 15, + 0, 0, 3 ) ; + + // aff cmpt si pas + { + // attention MAGOUILLE + // ne marche que parcequ'il y n'y a + // qu'UN seul incrust_cmpt dans le jeu + + T_INCRUST_DISP *ptrdisp ; + ptrdisp = ListIncrustDisp ; + var = 0 ; + for( n=0; nNum == -1 ) + continue ; + + if( ptrdisp->Type==INCRUST_CMPT ) + { + ptrdisp->Num = BoundRegleTrois( ptrdisp->Info, ptrdisp->Num, 50*2, ptrdisp->TimerEnd-TimerRef-50 ) ; + ptrdisp->Info = NbGoldPieces ; + ptrdisp->TimerEnd = TimerRef + 50 * 3 ; + var = 1 ; + break ; + } + } + + if( !var ) // yen avait pas + { + InitIncrustDisp( INCRUST_CMPT, + num, + 30, 20, + NbGoldPieces, 0, 3 ) ; + } + } + break ; + + case LM_USE_ONE_LITTLE_KEY: + NbLittleKeys-- ; + if( NbLittleKeys < 0 ) NbLittleKeys = 0 ; + // affiche little key + InitIncrustDisp( INCRUST_SPRITE, + 6, + 0, 0, + NUM_PERSO, 1, 1 ) ; + break ; + + case LM_INC_CHAPTER: + Chapitre++ ; + break ; + + case LM_FOUND_OBJECT: + SaveTimer() ; + TestRestoreModeSVGA( TRUE ) ; + DoFoundObj( *PtrPrg++ ) ; + RestoreTimer() ; + AffScene( TRUE ) ; + break ; + + case LM_SET_DOOR_LEFT: + ptrobj->Beta = 768 ; + ptrobj->PosObjX = ptrobj->AnimStepX - *(WORD*)PtrPrg ; + ptrobj->WorkFlags &= ~AUTO_STOP_DOOR ; + ptrobj->SRot = 0 ; + PtrPrg += 2 ; + break ; + + case LM_SET_DOOR_RIGHT: + ptrobj->Beta = 256 ; + ptrobj->PosObjX = ptrobj->AnimStepX + *(WORD*)PtrPrg ; + ptrobj->WorkFlags &= ~AUTO_STOP_DOOR ; + ptrobj->SRot = 0 ; + PtrPrg += 2 ; + break ; + + case LM_SET_DOOR_UP: + ptrobj->Beta = 512 ; + ptrobj->PosObjZ = ptrobj->AnimStepZ - *(WORD*)PtrPrg ; + ptrobj->WorkFlags &= ~AUTO_STOP_DOOR ; + ptrobj->SRot = 0 ; + PtrPrg += 2 ; + break ; + + case LM_SET_DOOR_DOWN: + ptrobj->Beta = 0 ; + ptrobj->PosObjZ = ptrobj->AnimStepZ + *(WORD*)PtrPrg ; + ptrobj->WorkFlags &= ~AUTO_STOP_DOOR ; + ptrobj->SRot = 0 ; + PtrPrg += 2 ; + break ; + + case LM_GIVE_BONUS: + if( ptrobj->OptionFlags & EXTRA_MASK ) + { + GiveExtraBonus( ptrobj ) ; + + } + if( *PtrPrg++ ) + { + // ne donne plus rien ???? + ptrobj->OptionFlags |= EXTRA_GIVE_NOTHING ; + } + break ; + + case LM_CHANGE_CUBE: + NewCube = *PtrPrg++ ; + FlagChgCube = 2 ; + break ; + + case LM_PLAY_MIDI: + PlayMusic( *PtrPrg++ ) ; + break ; + + case LM_ADD_FUEL: + Fuel += *PtrPrg++ ; + if( Fuel > 100 ) Fuel = 100 ; + break ; + + case LM_SUB_FUEL: + Fuel -= *PtrPrg++ ; + if( Fuel < 0 ) Fuel = 0 ; + break ; + + case LM_SET_HOLO_POS: + SetHoloPos( *PtrPrg++ ) ; + if( ListFlagGame[FLAG_HOLOMAP] ) + { + InitIncrustDisp( INCRUST_OBJ, + 0, // holomap + 0, 0, + 0, 0, 3 ) ; + } + break ; + + case LM_CLR_HOLO_POS: + ClrHoloPos( *PtrPrg++ ) ; + break ; + + case LM_SET_GRM: // ne marche que si pas autre grm + IncrustGrm( (IndexGrm = *PtrPrg++) ) ; + break ; + + case LM_INC_CLOVER_BOX: + if( NbCloverBox < MAX_CLOVER_BOX ) + { + NbCloverBox++ ; + } + break ; + + case LM_OBJ_COL: + if( *PtrPrg++ ) ptrobj->Flags |= CHECK_OBJ_COL ; + else ptrobj->Flags &= ~CHECK_OBJ_COL ; + break ; + + case LM_INVISIBLE: + if( *PtrPrg++ ) ptrobj->Flags |= INVISIBLE ; + else ptrobj->Flags &= ~INVISIBLE ; + break ; + + case LM_BRICK_COL: + num = *PtrPrg++ ; + ptrobj->Flags &= ~(CHECK_BRICK_COL+COL_BASSE) ; + if( num == 1 ) + { + ptrobj->Flags &= ~(CHECK_BRICK_COL+COL_BASSE) ; + ptrobj->Flags |= CHECK_BRICK_COL ; + } + if( num == 2 ) + { + ptrobj->Flags |= CHECK_BRICK_COL+COL_BASSE ; + } + break ; + + case LM_ZOOM: + if( *PtrPrg++ ) + { + if( (!FlagMCGA) AND (SceZoom!=0) ) + { + FadeToBlack( PtrPal ) ; + ExtInitMcga() ; + SetBlackPal() ; + FlagFade = TRUE ; + } + } + else + { + if( FlagMCGA ) + { + FadeToBlack( PtrPal ) ; + ExtInitSvga() ; + SetBlackPal() ; + FlagFade = TRUE ; + FirstTime = TRUE ; + } + } + break ; + + case LM_POS_POINT: + Value = *PtrPrg++ ; // index point + X0 = ListBrickTrack[Value].X ; + Y0 = ListBrickTrack[Value].Y ; + Z0 = ListBrickTrack[Value].Z ; + + ptrobj->PosObjX = X0 ; + ptrobj->PosObjY = Y0 ; + ptrobj->PosObjZ = Z0 ; + break ; + + case LM_PLAY_FLA: + SaveTimer() ; + if( FlagPalettePcx ) FadeToBlack( PalettePcx ) ; + else FadeToBlack( PtrPal ) ; + HQ_StopSample() ; + PlayAnimFla( PtrPrg ) ; + PtrPrg += strlen( PtrPrg ) + 1 ; + RestoreTimer() ; + FlagFade = TRUE ; + FirstTime = TRUE ; + break ; + + case LM_ADD_CHOICE: + GameListChoice[GameNbChoices] = *(WORD*)PtrPrg ; + PtrPrg += 2 ; + GameNbChoices++ ; + break ; + + case LM_ASK_CHOICE: +#ifndef DEMO + SaveTimer() ; + TestRestoreModeSVGA( TRUE ) ; + if( Bulle ) DrawBulle( numobj ) ; + TestCoulDial( ptrobj->CoulObj ) ; + GameAskChoice( *(WORD*)PtrPrg ) ; + GameNbChoices = 0 ; + PtrPrg += 2 ; +// FlagFade = TRUE ; + RestoreTimer() ; + AffScene(TRUE) ; + WaitReleaseSpace() ; +#endif + break ; + + case LM_ASK_CHOICE_OBJ: +#ifndef DEMO + SaveTimer() ; + num = *PtrPrg++ ; + TestRestoreModeSVGA( TRUE ) ; + if( Bulle ) DrawBulle( num ) ; + TestCoulDial( ListObjet[num].CoulObj ) ; + GameAskChoice( *(WORD*)PtrPrg ) ; + GameNbChoices = 0 ; + PtrPrg += 2 ; +// FlagFade = TRUE ; + RestoreTimer() ; + AffScene(TRUE) ; + WaitReleaseSpace() ; +#endif + break ; + + case LM_BIG_MESSAGE: + SaveTimer() ; + TestRestoreModeSVGA( TRUE ) ; + BigWinDial() ; + if( Bulle ) DrawBulle( numobj ) ; + TestCoulDial( ptrobj->CoulObj ) ; +#ifdef CDROM + NumObjSpeak = numobj ; +#endif + Dial( *(WORD*)PtrPrg ) ; + PtrPrg += 2 ; + NormalWinDial() ; + AffScene(TRUE) ; + RestoreTimer() ; + WaitReleaseSpace() ; + break ; + + case LM_FULL_POINT: + ListObjet[NUM_PERSO].LifePoint = 50 ; + MagicPoint = MagicLevel * 20 ; + break ; + + case LM_BETA: + ptrobj->Beta = *(WORD*)PtrPrg ; + ClearRealAngle( ptrobj ) ; + PtrPrg += 2 ; + break ; + + case LM_GRM_OFF: + if( IndexGrm != -1 ) + { + IndexGrm = ZoneGrm = -1 ; + CopyMapToCube() ; + AffScene( TRUE ) ; + } + break ; + + case LM_FADE_PAL_RED: + SaveTimer() ; + FadeToRed( PtrPal ) ; + FlagPalettePcx = FALSE ; + RestoreTimer() ; + break ; + + case LM_FADE_ALARM_RED: + SaveTimer() ; + Load_HQR( PATH_RESSOURCE"ress.hqr", PalettePcx, RESS_PAL_ALARM ) ; + FadeToRed( PalettePcx ) ; + FlagPalettePcx = TRUE ; + RestoreTimer() ; + break ; + + case LM_FADE_ALARM_PAL: + SaveTimer() ; + Load_HQR( PATH_RESSOURCE"ress.hqr", PalettePcx, RESS_PAL_ALARM ) ; + FadePalToPal( PalettePcx, PtrPal ) ; + FlagPalettePcx = FALSE ; + RestoreTimer() ; + break ; + + case LM_FADE_RED_PAL: + SaveTimer() ; + FadeRedToPal( PtrPal ) ; + FlagPalettePcx = FALSE ; + RestoreTimer() ; + break ; + + case LM_FADE_RED_ALARM: + SaveTimer() ; + Load_HQR( PATH_RESSOURCE"ress.hqr", PalettePcx, RESS_PAL_ALARM ) ; + FadeRedToPal( PalettePcx ) ; + FlagPalettePcx = TRUE ; + RestoreTimer() ; + break ; + + case LM_FADE_PAL_ALARM: + SaveTimer() ; + Load_HQR( PATH_RESSOURCE"ress.hqr", PalettePcx, RESS_PAL_ALARM ) ; + FadePalToPal( PtrPal, PalettePcx ) ; + FlagPalettePcx = TRUE ; + RestoreTimer() ; + break ; + + case LM_EXPLODE_OBJ: + num = *PtrPrg++ ; + ExtraExplo( + ListObjet[num].PosObjX + Rnd( 512 ) - 256 , + ListObjet[num].PosObjY + Rnd( 256 ) - 128 , + ListObjet[num].PosObjZ + Rnd( 512 ) - 256 ) ; + break; + + case LM_BULLE_ON: + Bulle = TRUE ; + break ; + + case LM_BULLE_OFF: + Bulle = FALSE ; + break ; + + case LM_SET_DARK_PAL: + SaveTimer() ; + Load_HQR( PATH_RESSOURCE"ress.hqr", PalettePcx, RESS_PAL_MUSEE ) ; + if( !FlagFade ) Palette( PalettePcx ) ; + FlagPalettePcx = TRUE ; + RestoreTimer() ; + break ; + + case LM_SET_NORMAL_PAL: + FlagPalettePcx = FALSE ; + if( !FlagFade ) Palette( PtrPal ) ; + break ; + + case LM_MESSAGE_SENDELL: +#ifndef DEMO + SaveTimer() ; + TestRestoreModeSVGA( TRUE ) ; + + FadeToBlack( PtrPal ) ; + Load_HQR( PATH_RESSOURCE"ress.hqr", Screen, RESS_SENDELL_PCR ) ; + CopyScreen( Screen, Log ) ; + Load_HQR( PATH_RESSOURCE"ress.hqr", PalettePcx, RESS_SENDELL_PAL ) ; + Flip() ; + FadeToPal( PalettePcx ) ; + + BigWinDial() ; + TestCoulDial( 15 ) ; +#ifdef CDROM + memoflagdisplaytext = FlagDisplayText ; + FlagDisplayText = TRUE ; +#endif + FlagMessageShade = FALSE ; + Dial( 6 ) ; + FlagMessageShade = TRUE ; + + NormalWinDial() ; + FadeToBlack( PalettePcx ) ; + Cls() ; + Flip(); + Palette( PtrPal ) ; +#ifdef CDROM + FlagDisplayText = memoflagdisplaytext ; +#endif + while( (Fire & F_SPACE) + OR (Key == K_ESC) ) ; + RestoreTimer() ; +#endif + break ; + + case LM_HOLOMAP_TRAJ: + NumHolomapTraj = *PtrPrg++ ; // signal pour chg cube + break ; + + case LM_GAME_OVER: + ListObjet[NUM_PERSO].LifePoint = 0 ; + ListObjet[NUM_PERSO].WorkFlags |= ANIM_END ; + NbFourLeafClover = 0 ; + flag = -1 ; + break ; + + case LM_THE_END: +#ifndef DEMO + // Save Partie retour scene de fin (inrejouable ?) + NbFourLeafClover = 0 ; + ListObjet[NUM_PERSO].LifePoint = 50 ; + MagicPoint = 80 ; + Comportement = SaveComportement ; + ListObjet[NUM_PERSO].Beta = SaveBeta ; + NumCube = 113 ; + SceneStartX = -1 ; + SaveGame() ; + FlagTheEnd = 1 ; // credits + flag = -1 ; +#endif + break ; + + case LM_BRUTAL_EXIT: + FlagTheEnd = 0 ; + flag = -1 ; + break ; + + case LM_MIDI_OFF: + StopMusicMidi() ; + break ; + + case LM_PLAY_CD_TRACK: +#ifdef CDROM + PlayCdTrack( *PtrPrg++ ) ; +#else + PtrPrg++ ; +#endif + break ; + + case LM_PROJ_ISO: + SetIsoProjection( 320-8-1, 240, SIZE_BRICK_XZ ) ; + SetPosCamera( 0,0,0 ) ; + SetAngleCamera( 0,0,0 ) ; + SetLightVector( AlphaLight, BetaLight, 0 ) ; + break ; + + case LM_PROJ_3D: + Cls() ; + CopyScreen( Log, Screen ) ; + Flip() ; + FlagAffGrille = FALSE ; + SetProjection( 320, 240, 128,1024,1024 ) ; + SetFollowCamera( 0,1500,0, 25,-128,0, 13000 ) ; + SetLightVector( 896, 950, 0 ) ; + InitDial( 1 ) ; + break ; + + case LM_TEXT: + if( TextLig < 440 ) + { + num = *(WORD*)PtrPrg ; + if( !Version_US ) + { + if( num == 0 ) num = 16 ; + } + GetMultiText( num, string ) ; + PtrPrg += 2 ; + dx = SizeFont( string ) ; + CoulFont( 15 ) ; + Font( 0, TextLig, string ) ; + if( dx > 639 ) dx = 639 ; + CopyBlockPhys( 0, TextLig, dx, TextLig+40 ) ; + TextLig += 40 ; + } + break ; + + case LM_CLEAR_TEXT: + TextLig = 0 ; + Box( 0,0, 639, 40*6, 0 ) ; + CopyBlockPhys( 0,0, 639, 40*6 ) ; + break ; + } + } +} diff --git a/SOURCES/GERELIFE.DEF b/SOURCES/GERELIFE.DEF new file mode 100644 index 0000000..2a35c77 --- /dev/null +++ b/SOURCES/GERELIFE.DEF @@ -0,0 +1,3 @@ +extern void DoFuncLife(T_OBJET *); +extern short DoTest(void); +extern void DoLife(short ); diff --git a/SOURCES/GERETRAK.C b/SOURCES/GERETRAK.C new file mode 100644 index 0000000..c97b03b --- /dev/null +++ b/SOURCES/GERETRAK.C @@ -0,0 +1,604 @@ +#include "c_extern.h" + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Ûßßßß Ûßßßß ÛßßßÛ Ûßßßß ßßÛßß ÛßßßÛ ÛßßßÛ Ûßßßß Û Üß + ÛÛ ßÛ ÛÛßß ÛÛßÛß ÛÛßß ÛÛ ÛÛßÛß ÛÛßßÛ ÛÛ ÛÛßÜ + ßßßßß ßßßßß ßß ß ßßßßß ßßßßß ßß ßß ß ßß ß ßßßßß ßß ß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +WORD BigSampleRepeat = 1 ; + + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void DoTrack( WORD numobj ) +{ + T_OBJET *ptrobj ; + WORD flag ; + UBYTE macro ; + UBYTE string[256] ; + WORD angle ; + LONG dist, y ; + UBYTE *ptrtrack; + UBYTE memooffsettrack; + WORD overflow = 0 ; + UBYTE *ptr ; + UBYTE n, c ; + + ptrobj = &ListObjet[numobj] ; + + flag = TRUE ; + while( flag ) + { + memooffsettrack = ptrobj->OffsetTrack ; + + ptrtrack = ptrobj->PtrTrack ; + ptrtrack += ptrobj->OffsetTrack ; /* offset macro en cours */ + + macro = *ptrtrack++ ; + ptrobj->OffsetTrack++ ; + + switch( macro ) + { +/*-------------------------------------------------------------------------*/ + case TM_SAMPLE: + HQ_3D_MixSample( *(WORD*)ptrtrack, 0x1000, 1, + ptrobj->PosObjX, ptrobj->PosObjY, ptrobj->PosObjZ ) ; + ptrobj->OffsetTrack += 2 ; + break ; + + case TM_SAMPLE_RND: + HQ_3D_MixSample( *(WORD*)ptrtrack, 0x800+Rnd(0x800), 1, + ptrobj->PosObjX, ptrobj->PosObjY, ptrobj->PosObjZ ) ; + ptrobj->OffsetTrack += 2 ; + break ; + + case TM_SAMPLE_ALWAYS: + HQ_3D_MixSample( *(WORD*)ptrtrack, 0x1000, 0, + ptrobj->PosObjX, ptrobj->PosObjY, ptrobj->PosObjZ ) ; + ptrobj->OffsetTrack += 2 ; + break ; + + case TM_SAMPLE_STOP: + HQ_StopOneSample( *(WORD*)ptrtrack ) ; + ptrobj->OffsetTrack += 2 ; + break ; + + case TM_REPEAT_SAMPLE: + BigSampleRepeat = *(WORD*)ptrtrack ; + ptrobj->OffsetTrack += 2 ; + break ; + + case TM_SIMPLE_SAMPLE: + HQ_MixSample( *(WORD*)ptrtrack, 0x1000, BigSampleRepeat, 128, 128 ) ; + BigSampleRepeat = 1 ; + ptrobj->OffsetTrack += 2 ; + break ; + +/*-------------------------------------------------------------------------*/ + case TM_PLAY_FLA: + ptr = string ; + n = 0 ; + do { c = *ptrtrack++ ; + *ptr++ = c ; + n++ ; + } while( c != 0 ) ; + + ptrobj->OffsetTrack += n ; + + SaveTimer() ; + FadeToBlack( PtrPal ) ; + PlayAnimFla( string ) ; + FlagFade = TRUE ; + RestoreTimer() ; + AffScene( TRUE ) ; + + break ; + +/*-------------------------------------------------------------------------*/ + case TM_BODY: + InitBody( *ptrtrack++, numobj ) ; + ptrobj->OffsetTrack ++ ; + break ; + + case TM_NO_BODY: + InitBody( NO_BODY, numobj ) ; + break ; + +/*-------------------------------------------------------------------------*/ + case TM_ANIM: + if( !InitAnim( *ptrtrack++, ANIM_REPEAT, 0, numobj ) ) + { + + ptrobj->OffsetTrack = memooffsettrack ; + flag = FALSE ; + } + else + { + ptrobj->OffsetTrack++ ; + } + break ; + +/*-------------------------------------------------------------------------*/ + case TM_WAIT_ANIM: + if( !(ptrobj->WorkFlags & ANIM_END) ) + { + ptrobj->OffsetTrack-- ; + flag = FALSE ; + } + else + { + flag = FALSE ; +/* attention si autre utilisation ANIM_END */ +/* ptrobj->Flags &= ~ANIM_END ; */ + + /* sup. ce clear si pb obj avec track pendant + follow ... */ + ClearRealAngle( ptrobj ) ; + } + break ; + +/*-------------------------------------------------------------------------*/ + case TM_WAIT_NB_ANIM:/* LORAN */ + ptrobj->OffsetTrack += 2 ; + if( !(ptrobj->WorkFlags & ANIM_END) ) + { + flag = FALSE ; + } + else + { + ptrtrack[1]++ ; // nb anim += + + if ( *(ptrtrack+1) == *ptrtrack ) + { + *(ptrtrack+1) = 0 ;/* Cpt */ + } + else flag = FALSE ; + + } + if ( flag == FALSE ) ptrobj->OffsetTrack -= 3 ; + break ; + +/*-------------------------------------------------------------------------*/ + case TM_WAIT_NB_SECOND: + ptrobj->OffsetTrack += 5 ; + + if( *(ULONG*)(ptrtrack+1) == 0 ) + { + *(ULONG*)(ptrtrack+1) = TimerRef + ( *ptrtrack * 50 ) ; + } + + if ( TimerRef < *(ULONG*)(ptrtrack+1) ) + { + ptrobj->OffsetTrack -= 6 ; + flag = FALSE ; + } + else *(ULONG*)(ptrtrack+1) = 0 ; + break ; + +/*-------------------------------------------------------------------------*/ + case TM_GOTO_POINT: + ptrobj->OffsetTrack++ ; +// if( !(ptrobj->WorkFlags & ANIM_MASTER_ROT) ) + { + Value = *ptrtrack ; // index point + X0 = ListBrickTrack[Value].X ; + Y0 = ListBrickTrack[Value].Y ; + Z0 = ListBrickTrack[Value].Z ; + + angle = GetAngle( ptrobj->PosObjX, + ptrobj->PosObjZ, + X0, Z0 ) ; + + if( ptrobj->Flags & SPRITE_3D ) + { + ptrobj->Beta = angle ; + } + else + { + if( Distance < 4000 ) + { + + InitRealAngleConst( ptrobj->Beta, + angle, + ptrobj->SRot/**Distance/4000*/ , + &ptrobj->RealAngle ) ; + } + else + { + InitRealAngleConst( ptrobj->Beta, + angle, + ptrobj->SRot, + &ptrobj->RealAngle ) ; + } + } + if( Distance > 500 ) + { + ptrobj->OffsetTrack -= 2 ; + flag = FALSE ; + } + } +/* else + { + ptrobj->OffsetTrack -= 2 ; + flag = FALSE ; + } +*/ + break ; + +/*-------------------------------------------------------------------------*/ + case TM_GOTO_POINT_3D: + ptrobj->OffsetTrack++ ; + if( ptrobj->Flags & SPRITE_3D ) + { + Value = *ptrtrack ; // index point + X0 = ListBrickTrack[Value].X ; + Y0 = ListBrickTrack[Value].Y ; + Z0 = ListBrickTrack[Value].Z ; + + ptrobj->Beta = + GetAngle( ptrobj->PosObjX, + ptrobj->PosObjZ, + X0, Z0 ) ; + + ptrobj->FlagAnim = /* alpha */ + GetAngle( ptrobj->PosObjY,0, + Y0,Distance ) ; +/* OpenWindow( &DWin, 10,200, 20,5 ) ; + WinText( &DWin, "Dist: ", Distance ) ; + WinText( &DWin, "Flag Y: ", Y0 ) ; + WinText( &DWin, "Obj Y: ", ptrobj->PosObjY ) ; + FlipWindow( &DWin ) ; +*/ + if( Distance > 100 ) + { + ptrobj->OffsetTrack -= 2 ; + flag = FALSE ; + } + else + { + /* find_me */ + + ptrobj->PosObjX = X0 ; + ptrobj->PosObjY = Y0 ; + ptrobj->PosObjZ = Z0 ; + } + + } + break ; + +/*-------------------------------------------------------------------------*/ + case TM_GOTO_SYM_POINT: + ptrobj->OffsetTrack++ ; +// if( !(ptrobj->WorkFlags & ANIM_MASTER_ROT) ) + { + Value = *ptrtrack ; // index point + X0 = ListBrickTrack[Value].X ; + Y0 = ListBrickTrack[Value].Y ; + Z0 = ListBrickTrack[Value].Z ; + + angle = 512 + GetAngle( ptrobj->PosObjX, + ptrobj->PosObjZ, + X0, Z0 ) ; + + if( ptrobj->Flags & SPRITE_3D ) + { + ptrobj->Beta = angle ; + } + else + { + InitRealAngleConst( ptrobj->Beta, + /* sym */ angle, + ptrobj->SRot, + &ptrobj->RealAngle ) ; + } + + if( Distance > 500 ) + { + ptrobj->OffsetTrack -= 2 ; + flag = FALSE ; + } + } +/* else + { + ptrobj->OffsetTrack -= 2 ; + flag = FALSE ; + } +*/ + break ; + +/*-------------------------------------------------------------------------*/ + case TM_ANGLE: + ptrobj->OffsetTrack += 2 ; + + if( !(ptrobj->Flags & SPRITE_3D) ) + { +// if( !(ptrobj->WorkFlags & ANIM_MASTER_ROT) ) + { + Value = *(WORD*)ptrtrack ; + + if( !ptrobj->RealAngle.TimeValue ) + { + InitRealAngleConst( ptrobj->Beta, + Value, + ptrobj->SRot, + &ptrobj->RealAngle ) ; + } + + if( ptrobj->Beta != Value ) + { + ptrobj->OffsetTrack -= 3 ; + flag = FALSE ; + } + else + { + ClearRealAngle( ptrobj ) ; + } + } +/* else + { + ptrobj->OffsetTrack -= 3 ; + flag = FALSE ; + } +*/ + } + break ; + +/*-------------------------------------------------------------------------*/ + case TM_FACE_TWINKEL: + ptrobj->OffsetTrack+=2 ; + if( !(ptrobj->Flags & SPRITE_3D) ) + { +// if( !(ptrobj->WorkFlags & ANIM_MASTER_ROT) ) + { + Value = *(WORD*)ptrtrack ; + + if( Value == -1 ) + { + if( !ptrobj->RealAngle.TimeValue ) + { + Value = GetAngle(ptrobj->PosObjX, + ptrobj->PosObjZ, + ListObjet[NUM_PERSO].PosObjX, + ListObjet[NUM_PERSO].PosObjZ ); + + InitRealAngleConst( ptrobj->Beta, + Value, + ptrobj->SRot, + &ptrobj->RealAngle ) ; + *(WORD*)ptrtrack = Value ; + } + } + + if( ptrobj->Beta != Value ) + { + ptrobj->OffsetTrack-=3 ; + flag = FALSE ; + } + else + { + ClearRealAngle( ptrobj ) ; + *(WORD*)ptrtrack = -1 ; + } + } +/* else + { + ptrobj->OffsetTrack-=3 ; + flag = FALSE ; + } +*/ + } + break ; + +/*-------------------------------------------------------------------------*/ + case TM_ANGLE_RND: + ptrobj->OffsetTrack += 4 ; + + if( !(ptrobj->Flags & SPRITE_3D) ) + { +// if( !(ptrobj->WorkFlags & ANIM_MASTER_ROT) ) + { + Value = *(WORD*)(ptrtrack+2) ; + + if( Value == -1 ) + { + if( !ptrobj->RealAngle.TimeValue ) + { + if( rand()&1 ) + { + Value = *(WORD*)ptrtrack ; + Value = (ptrobj->Beta + 256 + Value/2 - Rnd( Value ))&1023 ; + } + else + { + Value = *(WORD*)ptrtrack ; + Value = (ptrobj->Beta - 256 - Value/2 + Rnd( Value ))&1023 ; + } + InitRealAngleConst( ptrobj->Beta, + Value, + ptrobj->SRot, + &ptrobj->RealAngle ) ; + *(WORD*)(ptrtrack+2) = Value ; + } + } + if( ptrobj->Beta != Value ) + { + ptrobj->OffsetTrack -= 5 ; + flag = FALSE ; + } + else + { + ClearRealAngle( ptrobj ) ; + *(WORD*)(ptrtrack+2) = -1 ; + } + } +/* else + { + ptrobj->OffsetTrack -= 5 ; + flag = FALSE ; + } +*/ + } + break ; + +/*-------------------------------------------------------------------------*/ +/* sp‚cifique porte: SPRITE_3D + SPRITE_CLIP */ + + case TM_OPEN_LEFT: + case TM_OPEN_RIGHT: + case TM_OPEN_UP: + case TM_OPEN_DOWN: + ptrobj->OffsetTrack += 2 ; + if( (ptrobj->Flags & (SPRITE_3D+SPRITE_CLIP)) == SPRITE_3D+SPRITE_CLIP ) + { + switch( macro ) + { + case TM_OPEN_LEFT: + ptrobj->Beta = 768 ; + break ; + case TM_OPEN_RIGHT: + ptrobj->Beta = 256 ; + break ; + case TM_OPEN_UP: + ptrobj->Beta = 512 ; + break ; + case TM_OPEN_DOWN: + ptrobj->Beta = 0 ; + break ; + } + ptrobj->DoorWidth = *(WORD*)ptrtrack ; + ptrobj->WorkFlags |= AUTO_STOP_DOOR ; + //speed porte + ptrobj->SRot = 1000 ; /* reglage global 8( */ + InitRealValue( 0, 1000, 50, &ptrobj->RealAngle ) ; + } + break ; + +/*-------------------------------------------------------------------------*/ +/* sp‚cifique porte: SPRITE_3D + SPRITE_CLIP */ + case TM_CLOSE: + if( (ptrobj->Flags & (SPRITE_3D+SPRITE_CLIP)) == SPRITE_3D+SPRITE_CLIP ) + { + ptrobj->WorkFlags |= AUTO_STOP_DOOR ; + ptrobj->DoorWidth = 0 ; + //speed porte + ptrobj->SRot = -1000 ; /* reglage global 8( */ + InitRealValue( 0, -1000, 50, &ptrobj->RealAngle ) ; + } + break ; + +/*-------------------------------------------------------------------------*/ +/* sp‚cifique porte: SPRITE_3D + SPRITE_CLIP */ + case TM_WAIT_DOOR: + if( (ptrobj->Flags & (SPRITE_3D+SPRITE_CLIP)) == SPRITE_3D+SPRITE_CLIP ) + { + if( ptrobj->SRot != 0 ) + { + ptrobj->OffsetTrack-- ; + flag = FALSE ; + } + } + break ; + +/*-------------------------------------------------------------------------*/ + case TM_BETA: + ptrobj->OffsetTrack += 2 ; +// if( !(ptrobj->WorkFlags & ANIM_MASTER_ROT) ) + { + ptrobj->Beta = *(WORD*)ptrtrack ; + if( !(ptrobj->Flags & SPRITE_3D) ) + { + ClearRealAngle( ptrobj ) ; + } + } + break ; + +/*-------------------------------------------------------------------------*/ + case TM_POS_POINT: + + ptrobj->OffsetTrack ++ ; + Value = *ptrtrack ; // index point + X0 = ListBrickTrack[Value].X ; + Y0 = ListBrickTrack[Value].Y ; + Z0 = ListBrickTrack[Value].Z ; + + if( ptrobj->Flags & SPRITE_3D ) + { + ptrobj->SRot = 0 ; //arrete deplacement !!! + } + ptrobj->PosObjX = X0 ; + ptrobj->PosObjY = Y0 ; + ptrobj->PosObjZ = Z0 ; + break ; + +/*-------------------------------------------------------------------------*/ + case TM_LABEL: + ptrobj->LabelTrack = *ptrtrack ; /* label */ + ptrobj->OffsetTrack++ ; + ptrobj->OffsetLabelTrack = ptrobj->OffsetTrack - 2 ; + break ; + +/*-------------------------------------------------------------------------*/ + case TM_GOTO: + ptrobj->OffsetTrack = *(WORD*)ptrtrack ; + break ; + +/*-------------------------------------------------------------------------*/ + case TM_LOOP: + /* mettre recherche label */ + ptrobj->OffsetTrack = 0 ; + break ; + +/*-------------------------------------------------------------------------*/ + case TM_SPEED: + ptrobj->OffsetTrack += 2 ; + ptrobj->SRot = *(WORD*)ptrtrack ; + if( ptrobj->Flags & SPRITE_3D ) + { /* voir pour les 2 types ? */ + InitRealValue( 0, ptrobj->SRot, + 50, &ptrobj->RealAngle ) ; + } + break ; + +/*-------------------------------------------------------------------------*/ + case TM_BACKGROUND: + ptrobj->OffsetTrack ++ ; + if( *ptrtrack ) /* ON */ + { + if( !(ptrobj->Flags & OBJ_BACKGROUND) ) + { + ptrobj->Flags |= OBJ_BACKGROUND ; + if( ptrobj->WorkFlags & WAS_DRAWN ) + { + FirstTime = TRUE ; /* :-( */ + } + } + } + else /* OFF */ + { + if( ptrobj->Flags & OBJ_BACKGROUND ) + { + ptrobj->Flags &= ~OBJ_BACKGROUND ; + if( ptrobj->WorkFlags & WAS_DRAWN ) + { + FirstTime = TRUE ; /* :-( */ + } + } + } + break ; + +/*-------------------------------------------------------------------------*/ + case TM_END: +// ptrobj->Move = NO_MOVE ; + ptrobj->OffsetTrack = -1 ; + flag = FALSE ; + break ; + + case TM_STOP: + ptrobj->OffsetTrack = -1 ; + flag = FALSE ; + break ; + } + } +} + diff --git a/SOURCES/GERETRAK.DEF b/SOURCES/GERETRAK.DEF new file mode 100644 index 0000000..4b79851 --- /dev/null +++ b/SOURCES/GERETRAK.DEF @@ -0,0 +1 @@ +extern void DoTrack(short ); diff --git a/SOURCES/GLOBAL.C b/SOURCES/GLOBAL.C new file mode 100644 index 0000000..0495b58 --- /dev/null +++ b/SOURCES/GLOBAL.C @@ -0,0 +1,260 @@ +#include "defines.h" + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßßÛ Ûßßßß ÛßßßÛ ÛÛßßß ÛßßßÛ + ÛÛßßß ÛÛßß ÛÛßÛß ßßßßÛ ÛÛ Û + ßß ßßßßß ßß ß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +/*--------- divers ---------------------------*/ + +UBYTE *BufSpeak ; + +UBYTE *LbaFont ; +UBYTE *Screen ; +UBYTE PalettePcx[768+500] ; +WORD MyJoy = 0 ; +WORD MyFire = 0 ; +WORD MyKey = 0 ; +UBYTE *PtrPal ; +WORD LastFire = 0 ; + +LONG FlagVsync = 0 ; +WORD FlagMCGA = FALSE ; +LONG FlagCredits = FALSE ; + +UBYTE String[256] ; +WORD Value ; + +LONG SampleVolume, MusicVolume, CDVolume, LineVolume, MasterVolume ; + +WORD SamplesEnable = FALSE ; + +WORD FlagPalettePcx = FALSE ; +WORD FlagFade = FALSE ; +WORD Bulle = TRUE ; +WORD FlagBlackPal = FALSE ; + +#ifdef CDROM +WORD FlaFromCD = TRUE ; +#else +#ifdef MAGOUILLE_FLA_HD +WORD FlaFromCD = TRUE ; // magouille fla sur HD +#else +WORD FlaFromCD = FALSE ; +#endif +#endif + +UBYTE PathFla[_MAX_PATH] ; + +LONG Version_US = TRUE ; + +/*--------- ressources ---------------------------*/ + +T_HQR_HEADER *HQR_Samples ; +T_HQR_HEADER *HQR_Midi ; +T_HQR_HEADER *InventoryObj ; + +UBYTE *BufferShadow ; + +/*--------- disk ---------------------------*/ + +char PleaseWait[60] ; + +UBYTE ProgDrive[_MAX_DRIVE] ; +UBYTE ProgDir[_MAX_DIR] ; + +ULONG OrgDrive ; +UBYTE OrgDir[_MAX_DIR] ; + +/* +UBYTE Drive[_MAX_DRIVE] ; +UBYTE Dir[_MAX_DIR] ; +*/ +UBYTE Name[_MAX_FNAME] ; +UBYTE Ext[_MAX_EXT] ; + + +//UBYTE OrgPathname[_MAX_PATH] ; +//UBYTE ProgramPathname[_MAX_PATH] ; + +//UBYTE Pathname[_MAX_PATH] ; + +/*--------- script ---------------------------*/ + +//UBYTE FicName[_MAX_PATH] ; +//UBYTE *PtrFiche ; +//UBYTE *PtrCommand ; +//UBYTE *PtrFicName ; + +/*--------- life tools ---------------------------*/ + +//UBYTE DefPathname[_MAX_PATH] ; +//UBYTE ScePathname[_MAX_PATH] ; +//UBYTE PcxPathname[_MAX_PATH] ; + +T_ZONE *ListZone ; +WORD NbZones = 0 ; + +T_TRACK *ListBrickTrack ; +WORD NbBrickTrack = 0 ; + +/* +T_FLAG ListFlagCube[MAX_FLAGS_CUBE] ; +T_FLAG ListFlagGame[MAX_FLAGS_GAME] ; +*/ + +UBYTE ListFlagCube[MAX_FLAGS_CUBE] ; +UBYTE ListFlagGame[MAX_FLAGS_GAME] ; + +UBYTE ListFlagInventory[MAX_INVENTORY] ; + +/*--------- holomap ----------------------------*/ + +//T_HOLO_OBJ ListHoloObj[MAX_HOLO_OBJ] ; +//WORD NbHoloObj = 0 ; + +T_HOLO_POS *ListHoloPos ; // [MAX_HOLO_POS] ; +UBYTE TabHoloPos[MAX_HOLO_POS] ; +//UBYTE *TabHoloPos ; + +/*--------- menus -----------------------------*/ + +WORD GameChoice ; +WORD GameNbChoices ; +WORD GameListChoice[10] ; // max 7 (normally) + +/*--------- perso ----------------------------*/ + +WORD FlagTheEnd = FALSE ; + +WORD ActionNormal = FALSE ; +WORD InventoryAction = -1 ; +WORD Weapon = 0 ; // magicball + +WORD Comportement = C_NORMAL ; +//WORD AnimRien = -1; +WORD AnimRienNormal, AnimRienSportif, AnimRienAgressif, AnimRienDiscret, AnimRienProtopack ; + +UBYTE *PtrFile3dNormal ; +UBYTE *PtrFile3dSportif ; +UBYTE *PtrFile3dAgressif ; +UBYTE *PtrFile3dDiscret ; +UBYTE *PtrFile3dProtopack ; + +WORD SceZoom = 1 ; // hard + +WORD Shadow = 2 ; // full +WORD ShadowX, ShadowY, ShadowZ ; +UBYTE ShadowCol ; + +WORD NumHolomapTraj = -1 ; +WORD NumCube = 0 ; // num cube en cours +WORD NewCube = -1 ; // change cube demand‚ +WORD FlagChgCube = 0 ; +WORD NewPosX, NewPosY, NewPosZ ; +WORD SceneStartX, SceneStartY, SceneStartZ ; +WORD CubeStartX, CubeStartY, CubeStartZ ; +WORD GameOverCube = 0 ; + +WORD MagicBall = -1 ; +WORD MagicBallType = 1 ; +WORD MagicBallCount = 3 ; +WORD CombatAuto = TRUE ; + +WORD MagicLevel = 0 ; +WORD MagicPoint = 0 ; +WORD NbGoldPieces = 0 ; +WORD NbLittleKeys = 0 ; +WORD Chapitre = 0 ; +WORD NbFourLeafClover = 2 ; +WORD NbCloverBox = 2 ; + +WORD Island = 0 ; +WORD Fuel = 0 ; +WORD NumPingouin = -1 ; + +WORD FlagClimbing = FALSE ; +WORD StartYFalling = 0 ; +T_REAL_VALUE RealFalling ; +WORD StepFalling = 1 ; + +WORD FlagWater = FALSE ; + +// perso sauvegarde entr‚e cube + +//UBYTE SaveGenBody ; + +//WORD SaveCube ; +//WORD SaveChapitre ; + +WORD SaveComportement = C_NORMAL ; +WORD SaveBeta = 0 ; + +//WORD SaveLifePoint ; +//WORD SaveNbGoldPieces ; +//WORD SaveMagicLevel ; +//WORD SaveMagicPoint ; + +//WORD SaveNbCloverBox ; +//WORD SaveNbFourLeafClover ; + +//UBYTE SaveListFlagGame[MAX_FLAGS_GAME] ; + +/*--------- Extra objs ----------------------------*/ + +T_EXTRA ListExtra[MAX_EXTRAS] ; + +//UBYTE *PtrSpriteExtra ; +T_HQR_HEADER *HQRPtrSpriteExtra ; +WORD *PtrZvExtra ; + +/*---------------- incrust display ----------------*/ + +T_INCRUST_DISP ListIncrustDisp[MAX_INCRUST_DISP] ; + +/*--------- moteur 3D ----------------------------*/ + +UBYTE *BufferAnim ; +UBYTE *PtrBufferAnim ; + +LONG NbBodys = 0 ; +UBYTE *PtrBody[MAX_BODYS] ; +// T_HQR_HEADER *HQR_Bodys ; + +//LONG NbAnims = 0 ; +//UBYTE *PtrAnim[MAX_ANIMS] ; +T_HQR_HEADER *HQR_Anims ; + +LONG NbObjets = 0 ; +T_OBJET ListObjet[MAX_OBJETS] ; + +T_SORT ListTri[MAX_OBJETS+MAX_EXTRAS] ; + +WORD NumObjFollow = NUM_PERSO ; + +/*--------- ambiance ----------------------------*/ + +WORD SampleAmbiance[4] ; +WORD SampleRepeat[4] ; +WORD SampleRnd[4] ; +WORD SamplePlayed = 0 ; +ULONG TimerNextAmbiance = 0 ; +WORD SecondEcart = 30 ; +WORD SecondMin = 10 ; +WORD CubeJingle = 255 ; +UBYTE *PtrXmi = 0 ; +WORD NumXmi = -2 ; + +/*--------- brick iso ----------------------------*/ + +WORD FirstTime = TRUE ; +WORD CameraZone = FALSE ; +WORD FlagAffGrille = TRUE ; + + + + + + diff --git a/SOURCES/GRAPH_A.ASM b/SOURCES/GRAPH_A.ASM new file mode 100644 index 0000000..6e5afa0 --- /dev/null +++ b/SOURCES/GRAPH_A.ASM @@ -0,0 +1,317 @@ +;---------------------------------------------------------------------------- +; Graph_A.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386P + .model SMALL, SYSCALL + +;---------------------------------------------------------------------------- + .data +;---------------------------------------------------------------------------- + include \projet\lib386\lib_svga\svga.ash + +comment @ + DWORD TabOffset[] + Brick: + - BYTE Delta X + - BYTE Delta Y + Line(Delta Y): + - BYTE NbBlock + Block: + - 00xxxxxxb xxxxxx zeros to jump + - 01xxxxxxb xxxxxx Copy Pix + - 10xxxxxxb xxxxxx Repeat Pix + - BYTE datas[] +@ + +BufferClip db 512 dup(?) +OffsetBegin dd 0 +NbPix dd 0 +;---------------------------------------------------------------------------- + .code + + public NoLanguage AffGraph + public NoLanguage GetDxDyGraph + +;---------------------------------------------------------------------------- +AffGraph proc uses esi edi ebx ebp,\ + numbrick:DWORD, xbrick:DWORD, ybrick:DWORD, \ + bankbrick:DWORD + + mov eax, numbrick + mov ebx, xbrick + mov ecx, ybrick + mov esi, bankbrick + + add esi, [esi+eax*4]; ESI = Begin Data + + +;----------------------------------------------- + lodsb ; Delta X + movzx edx, al ; + lodsb ; Nb Line ( Delta Y ) + movzx eax, al +;----------------------------------------------- Test Clipping + add edx, ebx + add eax, ecx + dec edx + dec eax + cmp ebx, ClipXmin + jl ClippingGraph + cmp ecx, ClipYmin + jl ClippingGraph + cmp edx, ClipXmax + jg ClippingGraph + cmp eax, ClipYmax + jg ClippingGraph + sub edx, ebx + sub eax, ecx + inc edx + inc eax +;----------------------------------------------- Calcul Offset Ecran + mov edi, Log + add edi, TabOffLine[ecx*4] + add edi, ebx + mov bh, al ; BH = NbLine + sub edx, Screen_X ; EDX = Offset Screen + neg edx ; EDX = Screen_X-edx + xor ecx, ecx ; Maz Compteur +;----------------------------------------------- Init NbBlock for this line +NextLine: lodsb ; Nb Block for this line + mov bl, al ; BL = NbBlock +;----------------------------------------------- Manage One Line +SameLine: lodsb ; OpCode + mov cl, al ; Sauve AL + and cl, 00111111b ; AH = Bit 0-5 + inc cl ; One More Please... + test al, 11000000b ; AL = Bit 6-7 + je JumpZero ; Incrust + test al, 01000000b ; AL = 01b + jne WriteDiffPix ; Pix Differents +;----------------------------------------------- Repeat Same Color + lodsb ; Color to Repeat + rep stosb ; Fill + dec bl ; Nb Block-- + jne SameLine ; Continue Same Line + add edi, edx ; EDI += Offset Screen + dec bh ; NbLine-- + jne NextLine ; Next Line + ret +;----------------------------------------------- Incrust +JumpZero: add edi, ecx ; Jump Zero (incrust) + dec bl ; Nb Block-- + jne SameLine ; Continue Same Line + add edi, edx ; EDI += Offset Screen + dec bh ; NbLine-- + jne NextLine ; Next Line + ret +;----------------------------------------------- Copy Diff Pix +WriteDiffPix: rep movsb ; Copy Pix + dec bl ; Nb Block-- + jne SameLine ; Continue Same Line +;----------------------------------------------- End of this Line ? + add edi, edx ; EDI += Offset Screen + dec bh ; NbLine-- + jne NextLine ; Next Line + ret +;-------------------------------------------------------------------- Clipping +; Graph : ( EBX, ECX ) ( EDX, EAX ) +ClippingGraph: + cmp ebx, ClipXmax + jg EndGraph + cmp ecx, ClipYmax + jg EndGraph + cmp edx, ClipXmin + jl EndGraph + cmp eax, ClipYmin + jl EndGraph + + cmp ecx, ClipYmin + jge PasHaut + +;---------------------- Clipping Haut, Saute ClipYmin-ECX Line(s) + + push eax + push ebx + + + mov ebx, ClipYmin + sub ebx, ecx + + mov bh, bl + +NextH: lodsb + mov bl, al +SameH: lodsb + test al, 11000000b + je JumpzH + mov ecx, 1 + test al, 01000000b + je AquiH + mov ecx, eax + and ecx, 00111111b + inc ecx +AquiH: add esi, ecx +JumpzH: dec bl + jne SameH + dec bh + jne NextH + + mov ecx, ClipYmin ; New Y Haut + + pop ebx + pop eax +;---------------------- Clipping Bas +PasHaut: cmp eax, ClipYmax + jle PasBas + mov eax, ClipYmax +;---------------------- Clipping Gauche +Pasbas: mov OffsetBegin, 0 + cmp ebx, ClipXmin + jge PasGauche + push eax + mov eax, ClipXmin + sub eax, ebx + mov OffsetBegin, eax + pop eax +;---------------------- Clipping Droit +PasGauche: push eax + mov eax, edx + sub eax, ebx + sub eax, OffsetBegin + inc eax + mov NbPix, eax + pop eax + + cmp edx, ClipXmax + jle PasDroit + + sub edx, ClipXmax + sub NbPix, edx + mov edx, ClipXmax +;---------------------- +PasDroit: + + mov edi, Log + add edi, TabOffLine[ecx*4] + add edi, ebx + + + sub eax, ecx + inc al + mov bh, al ; BH NbLine + xor ecx, ecx + mov ebp, edi +;---------------------------------------------- + ; ESI = DATAS LINE +NextL: lea edi, BufferClip ; EDI = BUFFERCLIP + lodsb + mov bl, al +SameL: lodsb + mov cl, al + and cl, 00111111b + inc cl + test al, 11000000b + je JumpL + test al, 01000000b + jne WriteDiffL +;---------------------- + lodsb + rep stosb + jmp nextBlock +;---------------------- +JumpL: xor al, al + rep stosb + jmp NextBlock +;---------------------- +WriteDiffL: rep movsb +;---------------------- +NextBlock: dec bl + jne SameL +;---------------------- + push esi ; SAVE ESI + lea esi, BufferClip ; ESI = BUFFERCLIP + mov edi, ebp ; EDI = SCREEN + mov ecx, OffsetBegin + add esi, ecx + add edi, ecx + mov ecx, NbPix +Again: lodsb + or al, al + je Incrust + mov [edi], al +Incrust: inc edi + loop Again + add ebp, 640 + pop esi + dec bh + jne NextL +;---------------------- +EndGraph: ret +AffGraph endp +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- +GetDxDyGraph proc uses esi edi ,\ + num:DWORD, ptdx:DWORD, ptdy:DWORD, bankgraph:DWORD + + mov esi, bankgraph + mov eax, num + add esi, [esi+eax*4] + mov edi, ptdx + lodsb + movzx eax, al + stosd + mov edi, ptdy + lodsb + movzx eax, al + stosd + ret +GetDxDyGraph endp + +;---------------------------------------------------------------------------- +;---------------------------------------------------------------------------- + + + + +;---------------------------------------------------------------------------- +; The + End + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOURCES/GRILLE.C b/SOURCES/GRILLE.C new file mode 100644 index 0000000..f08a68b --- /dev/null +++ b/SOURCES/GRILLE.C @@ -0,0 +1,735 @@ + +#include "c_extern.h" + +#include +#include +#include +#include + +#include "grille.h" + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Ûßßßß ÛßßßÛ Û Û Û Ûßßßß + ÛÛ ßÛ ÛÛßÛß ÛÛ ÛÛ ÛÛ ÛÛßß + ßßßßß ßß ß ßß ßßßßß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#define HEADER_BLOCK 3 + +#define DXBLOCK 0 +#define DYBLOCK 1 +#define DZBLOCK 2 + +/*-------------------------------------------------------------------------*/ +/* prototype */ + +UBYTE *GetAdrBlock( LONG numblock ) ; +UBYTE GetColBrick( WORD xm, WORD ym, WORD zm ) ; +ULONG CreateMaskGph( UBYTE *pt, UBYTE *dest ) ; +/*-------------------------------------------------------------------------*/ + +LONG StartXCube = 0 ; +LONG StartYCube = 0 ; +LONG StartZCube = 0 ; + +LONG WorldXCube = 0 ; +LONG WorldYCube = 0 ; +LONG WorldZCube = 0 ; + +WORD XpOrgw ; +WORD YpOrgw ; + +#define NB_COLON 28 +#define MAX_BRICK 150 + +WORD NbBrickColon[NB_COLON] ; + +typedef struct +{ + WORD Xm ; + WORD Ym ; + WORD Zm ; + WORD Ys ; + WORD Brick ; + +} T_COLONB ; + +T_COLONB ListBrickColon[NB_COLON][MAX_BRICK] ; + +UBYTE *BufCube = 0 ; +UBYTE *BufMap = 0 ; +UBYTE *TabBlock ; +UBYTE *BufferBrick ; + +UBYTE *BufferMaskBrick ; + +LONG XMap, YMap, ZMap ; +LONG NbBlock ; +LONG XScreen, YScreen ; + +LONG DxBlock, DyBlock, DzBlock; + +//LONG CoulFond=0 ; + +extern WORD Nxw, Nyw, Nzw ; +void ReajustPos( UBYTE col ) ; +/*--------------------------------------------------------------------------*/ +#ifdef BRICK_HQR +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û Û ÛßßßÛ ÛßßßÛ ÛßßÛ ÛßßßÛ Û Ûßßßß Û Üß + ÛÛßßÛ ÛÛ ÜÛ ÛÛßÛß ÛÛßßÛ ÛÛßÛß ÛÛ ÛÛ ÛÛßÜ + ßß ß ßßßß ßß ß ßßßßß ßßßßß ßß ß ßß ßßßßß ßß ß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +#define MAX_BRICK_GAME 10000L +#define OFFSET_BUFFER_FLAG 153800L + +char *NameHqrGri=PATH_RESSOURCE"LBA_GRI.HQR" ; +char *NameHqrBll=PATH_RESSOURCE"LBA_BLL.HQR" ; +char *NameHqrBrk=PATH_RESSOURCE"LBA_BRK.HQR" ; + +typedef struct { ULONG SizeFile ; + ULONG CompressedSizeFile ; + WORD CompressMethod ; /* 0 stored */ + /* 1 LZS */ + } T_HEADER ; + +/*--------------------------------------------------------------------------*/ +LONG LoadUsedBrick( ULONG size ) +{ + ULONG i, j, b ; + UBYTE *pt ; + UBYTE *ptb ; + UWORD *ptw ; + ULONG *ptoff ; + UBYTE *ptdata ; + UBYTE *ptsrc ; + UBYTE *ptused ; + ULONG offset ; + ULONG maxbrk ; + ULONG nbbrick ; + ULONG brick ; + ULONG offseek ; + ULONG *ptseek ; + ULONG handle ; + ULONG nbentity; + UWORD *tabflag; + UWORD *ptflag ; + UWORD min, max; + T_HEADER header ; + UBYTE *ptdecomp ; + + tabflag = (UWORD*)(Screen+OFFSET_BUFFER_FLAG) ; + + RazMem( tabflag, MAX_BRICK_GAME*2L ) ;/* Table de UWORD pour NewNumBrick */ + + min = 60000 ; + max = 0 ; + +/*-------------------------------------- Premiere Passe, Pr‚paration ptflag */ + + pt = ptused = BufMap+(size-32) ;/* Debut de Used Block */ + + for ( i = 1 ; i < 256 ; i++ ) + { + b = pt[i>>3] & (1<<(7-(i&7))) ;/* Recup Bit Block */ + if ( !b ) continue ; + + ptb = TabBlock + *(ULONG *)(TabBlock+((i-1)<<2)); + ptw = (UWORD *)(ptb + 5) ;/* Jump dx dy dz et collis */ + maxbrk = *ptb * *(ptb+1) * *(ptb+2) ;/* dx*dy*dz*/ + + for ( j = 0 ; j < maxbrk ; j++, ptw += 2 ) + { + brick = *ptw ; + + if ( brick ) + { + brick-- ; + + if ( brick < min ) min = brick ; + if ( brick > max ) max = brick ; + + tabflag[brick] = 1 ; + } + } + } + +/*-------------------------------------- Deuxieme Passe, On compte les Bricks*/ + ptflag = tabflag+min ; + + nbbrick = 0 ; + + for ( i = min ; i <= max ; i++, ptflag++ ) + { + if ( *ptflag ) nbbrick++ ; + } + +/*-------------------------------------- Troisieme Passe, Load Brick */ + + handle = OpenRead( NameHqrBrk ) ; + if ( !handle ) return(0L) ; + + Read( handle, &nbentity, 4L ) ; + Seek( handle, 0L, SEEK_START ) ; + + Read( handle, Screen, nbentity ); + nbentity >>= 2 ; + + ptflag = tabflag+min ; + + ptoff = (ULONG *)BufferBrick ; + + offset = (nbbrick+1)*4L ; + + *ptoff++ = offset ;/* First Offset */ + + ptdata = BufferBrick+offset ;/* Jump nbbrick+1 Offset */ + + nbbrick = 0 ; + + ptseek = (ULONG *)Screen ; + + for ( i = min ; i <= max ; i++, ptflag++ ) + { + if ( *ptflag ) + { + nbbrick++ ;/* One More*/ + *ptflag = nbbrick ;/* Brick+1 */ + offseek = *(ptseek+i) ; + Seek( handle, offseek, SEEK_START ) ; + Read( handle, &header, sizeof(header)) ; + switch( header.CompressMethod ) + { + case 0: + Read( handle, ptdata, header.SizeFile ) ; + break ; + case 1: + ptdecomp = ptdata+header.SizeFile-header.CompressedSizeFile+500 ; + Read( handle, ptdecomp, header.CompressedSizeFile ) ; + Expand( ptdecomp, ptdata, header.SizeFile ) ; + break ; + } + ptdata += header.SizeFile ; + offset += header.SizeFile ; + *ptoff++ = offset ; + } + } + +/*-------------------------------------- Quatrieme Passe, Rename Block */ + + pt = ptused ;/* Debut de Used Block */ + + for ( i = 1 ; i < 256 ; i++ ) + { + b = pt[i>>3] & (1<<(7-(i&7))) ;/* Recup Bit Block */ + if ( !b ) continue ; + + ptb = TabBlock + *(ULONG *)(TabBlock+((i-1)<<2)); + ptw = (UWORD *)(ptb + 5) ;/* Jump dx dy dz et collis */ + maxbrk = *ptb * *(ptb+1) * *(ptb+2) ;/* dx*dy*dz*/ + + for ( j = 0 ; j < maxbrk ; j++, ptw += 2 ) + { + if ( *ptw ) *ptw = tabflag[(*ptw)-1]; + } + } + + Close(handle) ; + + return(offset) ; +} +/*-------------------------------------------------------------------------*/ +LONG InitGrille( UWORD numcube ) +{ + ULONG i, b, j ; + UBYTE *pt ; + ULONG sizegri ; + ULONG sizebll ; + ULONG size ; + +// BufCube = Malloc(SIZE_CUBE_X*SIZE_CUBE_Y*SIZE_CUBE_Z*2L ) ; +// if ( BufCube == 0L ) return(0L) ; + + sizegri = Size_HQR( NameHqrGri, numcube ) ;/* GRI */ + HQM_Alloc( sizegri, &BufMap ) ; + CHECK_MEMORY +// BufMap = Malloc( sizegri+500 ) ; + if ( BufMap == 0L ) return(0L) ; + Load_HQR( NameHqrGri, BufMap, numcube ) ; +// Mshrink( BufMap, sizegri ) ; + + sizebll = Size_HQR( NameHqrBll, numcube ) ;/* BLL */ + HQM_Alloc( sizebll, &TabBlock ) ; + CHECK_MEMORY +// TabBlock = Malloc( sizebll+500 ) ; bordel ! + if ( TabBlock == 0L ) return(0L) ; + Load_HQR( NameHqrBll, TabBlock, numcube ) ; +// Mshrink( TabBlock, sizebll ) ; + +/*---------------------------------------------- NEW */ +/* Message("Loading Brick, Please Wait...", FALSE );*/ + + size = LoadUsedBrick( sizegri ) ; + if ( !size ) return(0L) ; + +/* Message(" End Loading Brick ", FALSE );*/ +/*----------------------------------------------*/ + + HQM_Alloc( size, &BufferMaskBrick ) ; + size = CreateMaskGph( BufferBrick, BufferMaskBrick ) ; + HQM_Shrink_Last( BufferMaskBrick, size ) ; + CHECK_MEMORY + +/* BufferMaskBrick = Malloc( size ) ; + size = CreateMaskGph( BufferBrick, BufferMaskBrick ) ; + Mshrink( BufferMaskBrick, size ) ;// Reduc no test +*/ + NbBlock = (*(ULONG*)TabBlock)/4 ; + + CopyMapToCube() ; + + return(1L) ; +} +/*--------------------------------------------------------------------------*/ +void FreeGrille() +{ +/* if( BufMap ) + { + Free( BufferMaskBrick ) ; + Free( TabBlock ) ; + Free( BufMap ) ; +// Free( BufCube ) ; + + BufMap = 0 ; + } +*/ +} +/*-------------------------------------------------------------------------*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Ûßßßß ÛÛÜ Û ÛßßßÜ Û Û ÛßßßÛ ÛßßßÛ + ÛÛßß ÛÛßÛÛ ÛÛ Û ÛÛßßÛ ÛÛ ÜÛ ÛÛßÛß + ßßßßß ßß ß ßßßß ßß ß ßßßß ßß ß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +#endif +/*--------------------------------------------------------------------------*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Ûßßßß Û Û ÛÛÜ Û Ûßßßß ßßÛßß Û ÛßßßÛ ÛÛÜ Û ÛÛßßß + ÛÛßß ÛÛ Û ÛÛßÛÛ ÛÛ ÛÛ ÛÛ ÛÛ Û ÛÛßÛÛ ßßßßÛ + ßß ßßßßß ßß ß ßßßßß ßß ßß ßßßßß ßß ß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +/*--------------------------------------------------------------------------*/ +UBYTE *GetAdrColonneMap( LONG x, LONG z ) +{ + ULONG offset ; + + offset = (x+(z*SIZE_CUBE_Z))*2 ; + offset = *(UWORD*)(BufMap+offset ) ; + + return(BufMap+offset) ; +} +/*--------------------------------------------------------------------------*/ +UBYTE *GetAdrColonneCube( LONG x, LONG z ) +{ + ULONG offset ; + + offset = (x*SIZE_CUBE_Y*2)+(z*SIZE_CUBE_Z*SIZE_CUBE_Y*2); + + return(BufCube+offset) ; +} + +/*--------------------------------------------------------------------------*/ + +void GetShadow( WORD xw, WORD yw, WORD zw ) +{ + WORD xm, ym, zm ; + UBYTE *ptc ; + WORD y ; + UBYTE *adr ; + LONG block ; + + xm = (xw+DEMI_BRICK_XZ)/SIZE_BRICK_XZ ; + ym = yw/SIZE_BRICK_Y ; + zm = (zw+DEMI_BRICK_XZ)/SIZE_BRICK_XZ ; + + ptc = BufCube + ym*2 + (xm*SIZE_CUBE_Y*2) + (zm*SIZE_CUBE_X*SIZE_CUBE_Y*2) ; + + for( y = ym; y>0; y-- ) + { + if( *(WORD*)ptc != 0 ) break ; + ptc -= 2 ; + } + + XMap = xm ; + YMap = y ; + ZMap = zm ; + + Nxw = xw ; + Nyw = (y+1) * SIZE_BRICK_Y ; + Nzw = zw ; + + ShadowCol = 0 ; + + if( *ptc != 0 ) + { + block = (*ptc++) - 1 ; + adr = GetAdrBlock( block ) ; + adr += HEADER_BLOCK ; + adr += (*ptc)<<2 ;/* 4 Bytes to Jump */ + ShadowCol = *adr ; + ReajustPos( ShadowCol ) ; +/* ShadowCol-- ; *//* pour num gph */ + } + + ShadowX = Nxw ; + ShadowY = Nyw ; + ShadowZ = Nzw ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛÜ ÜÛ Ûßßßß ÛÜ ÜÛ ÛßßßÛ Û ÛßßßÛ Ûßßßß + ÛÛß Û ÛÛßß ÛÛß Û ÛÛ Û ÛÛ ÛÛßÛß ÛÛßß + ßß ß ßßßßß ßß ß ßßßßß ßß ßß ß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +ULONG CreateMaskGph( UBYTE *ptsrc, UBYTE *ptdst ) +{ + UBYTE *ptd ; + ULONG nbg, off; + ULONG *ptoff ; + ULONG size, i ; + + ptoff = (ULONG*)ptdst ; + + off = *(ULONG *)ptsrc ;/* First Offset Src */ + + *ptoff++ = off ;/* First Offset */ + + ptd = ptdst+off ; + + nbg = (off-4)>>2 ;/* Nombre de Graph */ + + for ( i = 0 ; i < nbg ; i++ ) + { + size = CalcGraphMsk( i, ptsrc, ptd ) ; + + off += size ;/* Maj Offset */ + *ptoff++ = off ;/* Write Offset */ + ptd += size ;/* Maj Pt Dest */ + } + return(off) ; +} + +/*-------------------------------------------------------------------------*/ +void MixteMapToCube( UBYTE *map ) +{ + UBYTE *ptb ; + LONG blk, pos, nb ; + UBYTE *pts, *ptd ; + LONG x, y, z ; + ULONG offset, flg=1 ; + + for ( z = 0 ; z < SIZE_CUBE_Z ; z++ ) + { + for ( x = 0 ; x < SIZE_CUBE_X ; x++ ) + { + offset = (x+(z*SIZE_CUBE_Z))*2 ; + offset = *(UWORD*)(map+offset ) ; + + pts = map+offset ; + ptd = GetAdrColonneCube( x, z ) ; + MixteColonne( pts, ptd ) ; + } + } +} +/*--------------------------------------------------------------------------*/ +void CopyMapToCube() +{ + UBYTE *pts, *ptd, *ptb ; + LONG x, y, z, blk, pos, nb ; + LONG flg=1 ; + +/*-------------- Copy -------------------------*/ + for ( z = 0 ; z < SIZE_CUBE_Z ; z++ ) + { + for ( x = 0 ; x < SIZE_CUBE_X ; x++ ) + { + pts = GetAdrColonneMap( x, z ) ; + ptd = GetAdrColonneCube( x, z ) ; + DecompColonne( pts, ptd ) ; + } + } +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void InitBufferCube() +{ + BufCube = Malloc(SIZE_CUBE_X*SIZE_CUBE_Y*SIZE_CUBE_Z*2L ) ; + if ( BufCube == 0L ) + TheEnd( NOT_ENOUGH_MEM, "BufCube" ) ; + + // Init Buffer Brick + BufferBrick = Malloc(MAX_SIZE_BRICK_CUBE) ; + if ( BufferBrick == 0L ) + TheEnd( NOT_ENOUGH_MEM, "BufferBrick" ) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßßÜ Û ÛÛßßß ÛßßßÛ Û ÛßßßÛ Û Üß + ÛÛ Û ÛÛ ßßßßÛ ÛÛßßß ÛÛ ÛÛßßÛ ÛÛß + ßßßß ßß ßßßßß ßß ßßßßß ßß ß ßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DrawOverBrick( WORD xm, WORD ym, WORD zm ) +{ + T_COLONB *ptrlbc ; + WORD col, i ; + WORD startcol, endcol ; + + startcol = (ClipXmin+24)/24-1 ; + endcol = (ClipXmax+24)/24 ; + + for( col = startcol; col <= endcol; col++ ) + { + ptrlbc = &ListBrickColon[col][0] ; + + for( i=0; iYs+38 > ClipYmin + AND ptrlbc->Ys <= ClipYmax ) + { + if( ptrlbc->Ym >= ym ) + { + if( (ptrlbc->Xm+ptrlbc->Zm) > (xm+zm) ) + { + CopyMask( ptrlbc->Brick, col*24-24, ptrlbc->Ys, BufferMaskBrick, Screen ) ; + } + } + } + ptrlbc++ ; + } + } +} + +/*--------------------------------------------------------------------------*/ +/* +void DrawOverBrick2( WORD xm, WORD ym, WORD zm ) +{ + T_COLONB *ptrlbc ; + WORD col, i ; + WORD startcol, endcol ; + + startcol = (ClipXmin+24)/24-1 ; + endcol = (ClipXmax+24)/24 ; + + for( col = startcol; col <= endcol; col++ ) + { + ptrlbc = &ListBrickColon[col][0] ; + + for( i=0; iYs+38 > ClipYmin + AND ptrlbc->Ys <= ClipYmax ) + { + if( ptrlbc->Ym >= ym ) + { + if( (ptrlbc->Zm >= zm) + AND (ptrlbc->Xm >= xm) ) + { + CopyMask( ptrlbc->Brick, col*24-24, ptrlbc->Ys, BufferMaskBrick, Screen ) ; + } + + } + } + ptrlbc++ ; + } + } +} +*/ +/*--------------------------------------------------------------------------*/ +/* recouvrement reel pour obj qui ne depassent pas la ZV */ + +void DrawOverBrick3( WORD xm, WORD ym, WORD zm ) +{ + T_COLONB *ptrlbc ; + WORD col, i ; + WORD startcol, endcol ; + + startcol = (ClipXmin+24)/24-1 ; + endcol = (ClipXmax+24)/24 ; + + for( col = startcol; col <= endcol; col++ ) + { + ptrlbc = &ListBrickColon[col][0] ; + + for( i=0; iYs+38 > ClipYmin + AND ptrlbc->Ys <= ClipYmax ) + { + if( ptrlbc->Ym >= ym ) + { + + if( (ptrlbc->Zm == zm) + AND (ptrlbc->Xm == xm) ) + { + CopyMask( ptrlbc->Brick, col*24-24, ptrlbc->Ys, BufferMaskBrick, Screen ) ; + } + + if( (ptrlbc->Zm > zm) + OR (ptrlbc->Xm > xm) ) + { + CopyMask( ptrlbc->Brick, col*24-24, ptrlbc->Ys, BufferMaskBrick, Screen ) ; + } + + } + } + ptrlbc++ ; + } + } +} + + +/*--------------------------------------------------------------------------*/ +void AffBrickBlock( LONG block, LONG brick, LONG x, LONG y, LONG z ) +{ + UBYTE *adr ; + LONG numbrick; + LONG nb, col ; + WORD bc ; + + adr = GetAdrBlock( block ) ; + adr += HEADER_BLOCK ; + + adr += ( brick<<2 ) ;/* 4 Bytes to Jump */ + adr += 2 ; + + numbrick = *(UWORD*)adr ; /* & 32767 */ + + if ( numbrick ) + { + Map2Screen( x-StartXCube, y-StartYCube, z-StartZCube ) ; + + if( XScreen >= -24 + AND XScreen < 640 + AND YScreen >= -38 + AND YScreen < 480 ) + { + AffGraph( numbrick-1, XScreen, YScreen, BufferBrick ) ; + + col = (XScreen+24)/24 ; /* 48 / 2 colonne intercal‚e */ + + nb = NbBrickColon[col] ; + if( nb < MAX_BRICK ) + { + // ca moche mettre PTR + + ListBrickColon[ col ][ nb ].Xm = x ; + ListBrickColon[ col ][ nb ].Ym = y ; + ListBrickColon[ col ][ nb ].Zm = z ; + ListBrickColon[ col ][ nb ].Ys = YScreen ; + ListBrickColon[ col ][ nb ].Brick = numbrick-1 ; + NbBrickColon[ col ]++ ; + + } + else + Message( "Arg MAX_BRICK Z BUFFER atteint", TRUE ) ; + } + } +} + +/*--------------------------------------------------------------------------*/ +/*ptc = BufCube + y*2 + (x*SIZE_CUBE_Y*2) + (z*SIZE_CUBE_X*SIZE_CUBE_Y*2) ;*/ + +void AffGrille() +{ + LONG z, y, x ; + LONG block ; + UBYTE *ptc ; + + WorldXCube = StartXCube*SIZE_BRICK_XZ ; + WorldYCube = StartYCube*SIZE_BRICK_Y ; + WorldZCube = StartZCube*SIZE_BRICK_XZ ; + + ProjettePoint( -WorldXCube, -WorldYCube, -WorldZCube ) ; + XpOrgw = Xp ; + YpOrgw = Yp ; + + for( x=0; x 64 ) + test al, 11000000b ; Incrust ? + je JumpZero ; Yes, go... + test al, 01000000b ; Diff Brick ? + jne WriteDiffBrick ; Yes, go... +;----------------------------------------------- Write Same Brick + lodsw ; Get NumBlock & PosBlock + rep stosw ; Fill Brick + dec bl ; Entity-- + jne NewEntity ; Again + ret ; End +;----------------------------------------------- Incrust ( Full off Nothing ) +JumpZero: xor ax, ax ; NumBlock & PosBlock = 0 + rep stosw ; Fill + dec bl ; Entity-- + jne NewEntity ; Again + ret ; End +;----------------------------------------------- Write Diff Brick +WriteDiffBrick: rep movsw ; Copy NumBlock & PosBlock + dec bl ; Entity-- + jne NewEntity ; Again + ret ; end +DecompColonne endp +;---------------------------------------------------------------------------- +MixteColonne proc uses esi edi ebx,\ + pts:DWORD, ptd:DWORD + + mov esi, pts + mov edi, ptd + xor ecx, ecx +;----------------------------------------------- Get Nb Entity + mov bl, [esi] ; BL = NbEntity + inc esi +;----------------------------------------------- For Every Entity +NewEntity: lodsb ; OpCode + mov cl, al ; CL = AL + and cl, 00111111b ; CL = Repeat + inc cl ; One More ( 1 -> 64 ) + test al, 11000000b ; Incrust ? + je JumpZero ; Yes, go... + test al, 01000000b ; Diff Brick ? + jne WriteDiffBrick ; Yes, go... +;----------------------------------------------- Write Same Brick + lodsw ; Get NumBlock & PosBlock + rep stosw ; Fill Brick + dec bl ; Entity-- + jne NewEntity ; Again + ret ; End +;----------------------------------------------- Incrust ( Full off Nothing ) +JumpZero: lea edi, [edi+ecx*2]; must add ecx WORD! + dec bl ; Entity-- + jne NewEntity ; Again + ret ; End +;----------------------------------------------- Write Diff Brick +WriteDiffBrick: rep movsw ; Copy NumBlock & PosBlock + dec bl ; Entity-- + jne NewEntity ; Again + ret ; end +MixteColonne endp +;---------------------------------------------------------------------------- +; The + End + + + + + + + + + + + + + + + + + + + + diff --git a/SOURCES/HOLOMAP.C b/SOURCES/HOLOMAP.C new file mode 100644 index 0000000..236a53a --- /dev/null +++ b/SOURCES/HOLOMAP.C @@ -0,0 +1,1075 @@ +#include "c_extern.h" + +#define STEP_ANGLE 32 +#define SLIG (((1024/STEP_ANGLE)+1) * 4) +#define SIZE_TEXT_GLOBE (((1024/STEP_ANGLE)+1) * ((512/STEP_ANGLE)+1) * 4 * 2) +#define SIZE_COOR_GLOBE (((1024/STEP_ANGLE)+1) * ((512/STEP_ANGLE)+1) * 3 * 2) +#define SIZE_MAP_ALT ( (1024/STEP_ANGLE) * ((512/STEP_ANGLE)+1) ) + + +#define X_CENTRE_BIG_HOLO 320 +#define Y_CENTRE_BIG_HOLO 190 +#define LARGEUR_BIG_HOLO 300 +#define HAUTEUR_BIG_HOLO 280 +#define ZOOM_BIG_HOLO 9500 +#define X_CENTRE_TRAJ_HOLO 320+80 +#define Y_CENTRE_TRAJ_HOLO 240 + +extern WORD NbPolyPoints ; +extern T_REAL_VALUE RealRot ; +extern LONG LYmin, LYmax ; + +UBYTE *PtrHoloBody ; +UBYTE *PtrHoloFleche ; +UBYTE *PtrHoloBodyFleche ; +UBYTE *PtrCone ; +UBYTE *LastPtr ; + +WORD CamAlpha, CamBeta, CamGamma ; + + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û Û ÛßßßÛ Û ÛßßßÛ ÛÜ ÜÛ ÛßßßÛ ÛßßßÛ + ÛÛßßÛ ÛÛ Û ÛÛ ÛÛ Û ÛÛß Û ÛÛßßÛ ÛÛßßß + ßß ß ßßßßß ßßßßß ßßßßß ßß ß ßß ß ßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +// calcule coor mapping. 256*256 -> polys + + /* ptrglobe WORD Xp + WORD Yp + WORD Xt + WORD Yt */ +UBYTE *ListTraj ; +UWORD *PtrGlobe ; +UWORD *PtrCoorGlobe ; +UBYTE *PtrAlt ; +UBYTE *PtrMap ; +UWORD *PtrTri ; +UBYTE RotPal[(32+31)*3] ; +WORD RotPalPos = 0 ; + +void ComputeCoorMapping() +{ + WORD alpha, beta ; + UWORD *ptr ; + + ptr = PtrGlobe ; + + for( alpha = -256; alpha <= 256; alpha += STEP_ANGLE ) + { + for( beta = 0; beta < 1024; beta += STEP_ANGLE ) + { + ptr += 2 ; /* Xp Yp */ + + *ptr++ = (UWORD)RegleTrois32( 0,255*256+255, 1023, beta ) ; + if( alpha == 256 ) + *ptr++ = 256*255 + 255 ; + else + *ptr++ = (UWORD) ( ((alpha+256) * 256) / 2) ; + } + + ptr += 2 ; /* Xp Yp */ + *ptr++ = 255*256 + 255 ; + if( alpha == 256 ) + *ptr++ = 256*255 + 255 ; + else + *ptr++ = (UWORD) ( ((alpha+256) * 256) / 2) ; + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void ComputeCoorGlobe() +{ + WORD alpha, beta ; + UWORD *ptrc ; + UBYTE *mptrv, *ptrv ; + WORD x, y ; + WORD normal ; + +// precalcul coor globe avec coor polaires + + ptrc = PtrCoorGlobe ; + + ptrv = PtrAlt ; + + SetAngleCamera( 0,0,0 ) ; + + for( alpha = -256; alpha <= 256; alpha += STEP_ANGLE ) + { + mptrv = ptrv ; // memo 0 + + for( beta = 0; beta < 1024; beta += STEP_ANGLE ) + { + normal = 1000 + *ptrv++ * 2 ; + + Rotate( normal , 0, alpha ) ; + x = X0 ; + y = Y0 ; + Rotate( x, 0, beta ) ; + WorldRotatePoint( X0, y, Y0 ) ; + *ptrc++ = X0 ; + *ptrc++ = Y0 ; + *ptrc++ = Z0 ; + } + Rotate( 1000 + *mptrv * 2 , 0, alpha ) ; + x = X0 ; + y = Y0 ; + Rotate( x, 0, 0 ) ; //... + WorldRotatePoint( X0, y, Y0 ) ; + + *ptrc++ = X0 ; + *ptrc++ = Y0 ; + *ptrc++ = Z0 ; + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +// compute projection sphere + +int z_sort( WORD *a, WORD *b) +{ + return( *a - *b ) ; +} + +void ComputeGlobeProj() +{ + UWORD *ptr, *ptrt ; + WORD *ptrc ; + WORD alpha, beta ; + + ptr = PtrGlobe ; + ptrc = (UWORD*)PtrCoorGlobe ; + ptrt = PtrTri ; + + for( alpha = -256; alpha <= 256; alpha += STEP_ANGLE ) + { + for( beta = 0; beta < 1024; beta += STEP_ANGLE ) + { + X0 = *ptrc++ ; + Y0 = *ptrc++ ; + Z0 = *ptrc++ ; + WorldRotatePoint( X0, Y0, Z0 ) ; + + if( alpha != 256 ) + { + *ptrt++ = Z0 ; + *ptrt++ = ptr-PtrGlobe ; + } + + ProjettePoint( X0, Y0, Z0 ) ; + *ptr++ = Xp ; + *ptr++ = Yp ; + ptr += 2 ; // coor text + } + + X0 = *ptrc++ ; + Y0 = *ptrc++ ; + Z0 = *ptrc++ ; + WorldRotatePoint( X0, Y0, Z0 ) ; + ProjettePoint( X0, Y0, Z0 ) ; + *ptr++ = Xp ; + *ptr++ = Yp ; + ptr += 2 ; // coor text + } + + + qsort( PtrTri, 512, 4, z_sort ) ; + +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void DrawHoloMap( WORD calpha, WORD cbeta, WORD cgamma ) +{ + WORD alpha, beta, gamma ; + LONG offsetalpha ; + UWORD *ptr ; + LONG n ; + + ComputeGlobeProj() ; + + for( n=0; n<16*32; n++ ) + { + ptr = PtrGlobe + PtrTri[n*2+1] ; + + TabPoly[1] = ptr[0] ; + TabPoly[2] = ptr[1] ; + TabPoly[4] = ptr[0+SLIG] ; + TabPoly[5] = ptr[1+SLIG] ; + TabPoly[7] = ptr[4] ; + TabPoly[8] = ptr[5] ; + + if( TestVuePoly( TabPoly ) ) + { + TabText[1] = ptr[2] ; + TabText[2] = ptr[3] ; + TabText[4] = ptr[2+SLIG] ; + TabText[5] = ptr[3+SLIG] ; + TabText[7] = ptr[6] ; + TabText[8] = ptr[7] ; + + AsmTexturedTriangleNoClip() ; + FillTextPolyNoClip( LYmin, LYmax, PtrMap ) ; + } + + TabPoly[1] = ptr[0+SLIG] ; + TabPoly[2] = ptr[1+SLIG] ; + TabPoly[4] = ptr[4+SLIG] ; + TabPoly[5] = ptr[5+SLIG] ; + TabPoly[7] = ptr[4] ; + TabPoly[8] = ptr[5] ; + + if( TestVuePoly( TabPoly ) ) + { + TabText[1] = ptr[2+SLIG] ; + TabText[2] = ptr[3+SLIG] ; + TabText[4] = ptr[6+SLIG] ; + TabText[5] = ptr[7+SLIG] ; + TabText[7] = ptr[6] ; + TabText[8] = ptr[7] ; + + AsmTexturedTriangleNoClip() ; + FillTextPolyNoClip( LYmin, LYmax, PtrMap ) ; + } + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û Û ÛßßßÛ Û ÛßßßÛ ÛßßßÛ ÛßßÛ Û + ÛÛßßÛ ÛÛ Û ÛÛ ÛÛ Û ÛÛ Û ÛÛßßÛ ÜÜ Û + ßß ß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DrawListPos( WORD calpha, WORD cbeta, WORD cgamma, WORD pos ) +{ + T_HOLO_POS *ptrpos ; + WORD n, x,y,z ; + WORD x1,y1,z1 ; + WORD xm,ym,zm ; + WORD xm1,ym1,zm1 ; + WORD xp, yp ; + WORD normal ; + UBYTE *ptr3do ; + UBYTE t ; + LONG i, nbobjets ; + + ptrpos = ListHoloPos ; + nbobjets = 0 ; + + for( n=0; nAlpha, ptrpos->Beta, 0 ) ; + WorldRotatePoint( 0,0, 1000+ptrpos->Size ) ; + xm = X0 ; + ym = Y0 ; + zm = Z0 ; + WorldRotatePoint( 0,0, 1500 ) ; + xm1 = X0 ; + ym1 = Y0 ; + zm1 = Z0 ; + +// SetFollowCamera( 0,0,0, calpha,cbeta,cgamma, ZOOM_BIG_HOLO ) ; + SetInverseAngleCamera( calpha,cbeta,cgamma ) ; + CameraXr = 0 ; + CameraYr = 0 ; + CameraZr = ZOOM_BIG_HOLO ; + + + WorldRotatePoint( xm, ym, zm ) ; + x1 = X0 ; + y1 = Y0 ; + z1 = Z0 ; + WorldRotatePoint( xm1, ym1, zm1 ) ; + if( !pos ) + { + if( Z0 > z1 ) continue ; + } + else + { + if( Z0 < z1 ) continue ; + } + + // draw obj + + t = TabHoloPos[n] & 1 ; +//t = 1 ; + if( NumCube == n ) t |= 2 ; + + ListTri[nbobjets].Z = z1 ; + ListTri[nbobjets].NumObj = n ; + ListTri[nbobjets].Num = t ; + ListTri[nbobjets].Xw = xm ; + ListTri[nbobjets].Yw = ym ; + ListTri[nbobjets].Zw = zm ; + nbobjets++ ; + } + + SmallSort( ListTri, nbobjets, sizeof( T_SORT ) ) ; + + for( n=0; n=0; n-- ) + { + if( TabHoloPos[n] & (128+1) ) + { + return n ; + } + } + return -1 ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +void SetHoloPos( UBYTE num ) +{ +// if( !(TabHoloPos[num] & 64) ) // d‚j… visit‚ + { + TabHoloPos[num] = 1 + 128 ; + } +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void ClrHoloPos( UBYTE num ) +{ + TabHoloPos[num] &= ~(1+128) ; + TabHoloPos[num] |= 64 ; // cube done +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DrawTitle( WORD x, WORD y, WORD num ) +{ + WORD x2, x0,y0,x1,y1 ; + UBYTE string[256] ; + + x0 = x - 630/2 ; + x1 = x + 630/2 ; + + y0 = y - 40/2 ; + y1 = y + 40/2 ; + +// Box( x0, y0, x1, y1, COUL_SELECT_MENU ) ; +// DrawFire( x0, y0, x1, y1, COUL_SELECT_MENU&0xF0 ) ; +// CopyBlock( x0, y0, x1, y1, Screen, x0, y0, Log ) ; +// ShadeBox( x0, y0, x1, y1, 4 ) ; + + // cadre +// DrawCadre( x0, y0, x1, y1 ) ; + + // text +// GetMultiText( num, string ) ; + strcpy( string, "HoloMap" ) ; + + x -= SizeFont( string )/2 ; + y -= 18 ; + + CoulFont( 12*16+10 ) ; + Font( x-1, y-1, string ) ; + Font( x , y-1, string ) ; + Font( x+1, y-1, string ) ; + + Font( x-1, y+1, string ) ; + Font( x , y+1, string ) ; + Font( x+1, y+1, string ) ; + + Font( x-1, y , string ) ; + Font( x+1, y , string ) ; + + CoulFont( 15 ) ; + Font( x , y, string ) ; + + // flip + CopyBlockPhys( x0,y0, x1,y1 ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#define SIZE_CURSOR 20 + +void DrawCurseur() +{ + Rect( X_CENTRE_BIG_HOLO - SIZE_CURSOR, + Y_CENTRE_BIG_HOLO - SIZE_CURSOR, + X_CENTRE_BIG_HOLO + SIZE_CURSOR, + Y_CENTRE_BIG_HOLO + SIZE_CURSOR, + 15 ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void InitHoloDatas() +{ + LONG n ; + + // inits pointeurs + + PtrGlobe = (UWORD*)Screen ; + PtrCoorGlobe = (UWORD*)(Screen + SIZE_TEXT_GLOBE) ; + PtrAlt = Screen + + SIZE_TEXT_GLOBE + + SIZE_COOR_GLOBE ; + PtrMap = Screen + + SIZE_TEXT_GLOBE + + SIZE_COOR_GLOBE + + SIZE_MAP_ALT ; + PtrHoloBody = Screen + + SIZE_TEXT_GLOBE + + SIZE_COOR_GLOBE + + SIZE_MAP_ALT + + 65536 ; + + // chargements + + Load_HQR( PATH_RESSOURCE"ress.hqr", PtrAlt, RESS_HOLOMAP_HMT ) ; + Load_HQR( PATH_RESSOURCE"ress.hqr", PtrMap, RESS_HOLOMAP_HMG ) ; + + n = Load_HQR( PATH_RESSOURCE"ress.hqr", PtrHoloBody, RESS_HOLO_TWINKEL ) ; + PtrHoloFleche = PtrHoloBody + n ; + n = Load_HQR( PATH_RESSOURCE"ress.hqr", PtrHoloFleche, RESS_HOLO_FLECHE ) ; + PtrHoloBodyFleche = PtrHoloFleche + n ; + n = Load_HQR( PATH_RESSOURCE"ress.hqr", PtrHoloBodyFleche, RESS_HOLO_BODYFLECHE ) ; + PtrCone = PtrHoloBodyFleche + n ; + n = Load_HQR( PATH_RESSOURCE"ress.hqr", PtrCone, RESS_HOLO_CONE ) ; + + PatchObjet( PtrHoloBody ) ; + PatchObjet( PtrHoloFleche ) ; + PatchObjet( PtrHoloBodyFleche ) ; + PatchObjet( PtrCone ) ; + + PtrTri = (UWORD*)(PtrCone + n) ; + + ListHoloPos = (T_HOLO_POS*)( PtrTri + (17*33*4) ) ; + n = Load_HQR( PATH_RESSOURCE"ress.hqr", ListHoloPos, RESS_HOLOMAP_POS ) ; + //Load( "F:\\PROJET\\LBA\\DATAS\\HOLOMAP.POS", ListHoloPos ) ; + + ListTraj = (UBYTE*)(ListHoloPos) + n ; + n = Load_HQR( PATH_RESSOURCE"ress.hqr", ListTraj, RESS_HOLOMAP_TRAJ ) ; + //Load( "f:\\projet\\lba\\datas\\holotraj.pos", ListTraj ) ; + + LastPtr = (UBYTE*)(ListTraj) + n ; + + // recup couls flotte bank 12 et 13 32 couleurs + + Load_HQR( PATH_RESSOURCE"ress.hqr", PalettePcx, RESS_HOLOMAP_PAL ) ; + for( n=0; n<32; n++ ) + { + RotPal[n*3 + 0] = PalettePcx[(12*16+n)*3 + 0] ; + RotPal[n*3 + 1] = PalettePcx[(12*16+n)*3 + 1] ; + RotPal[n*3 + 2] = PalettePcx[(12*16+n)*3 + 2] ; + } + for( n=0; n<31; n++ ) + { + RotPal[(32+n)*3 + 0] = PalettePcx[(12*16+n)*3 + 0] ; + RotPal[(32+n)*3 + 1] = PalettePcx[(12*16+n)*3 + 1] ; + RotPal[(32+n)*3 + 2] = PalettePcx[(12*16+n)*3 + 2] ; + } + + // precalcul coordonn‚es diverses (stock dans screen) + + ComputeCoorMapping() ; + ComputeCoorGlobe() ; + RotPalPos = 0 ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û Û ÛßßßÛ Û ÛßßßÛ ÛÜ ÜÛ ÛßßßÛ ÛßßßÛ + ÛÛßßÛ ÛÛ Û ÛÛ ÛÛ Û ÛÛß Û ÛÛßßÛ ÛÛßßß + ßß ß ßßßßß ßßßßß ßßßßß ßß ß ßß ß ßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void HoloMap() +{ + WORD calpha=-256, cbeta=0, cgamma=0 ; + WORD zoom = 22000 ; + LONG y, x = 15 ; + UWORD *ptr, *ptrc ; + UBYTE *mptrv, *ptrv ; + WORD c, n ; + WORD flagredraw ; + WORD flagpal = TRUE ; + WORD dialstat = 3 ; + + WORD menumode = 0 ; + WORD flagrebond = FALSE ; + WORD redrawmenu = TRUE ; + + LONG automove = FALSE ; + LONG otimer ; + WORD oalpha, obeta ; + WORD dalpha, dbeta ; + LONG current = -1 ; + LONG dialmess = -1 ; + LONG alphalight, betalight ; + LONG memoflagspeak ; + + UBYTE savepalette[768] ; + + SaveTimer() ; + + for(n=0; n<768; n++) savepalette[n] = PalettePcx[n] ; + + alphalight = AlphaLight ; + betalight = BetaLight ; + + FadeToBlack( PtrPal ) ; + HQ_StopSample() ; + + UnSetClip() ; + Cls() ; + Flip() ; + CopyScreen( Log, Screen ) ; + + InitHoloDatas() ; + + DrawTitle( 320, 25, 0 ) ; + + SetProjection( X_CENTRE_BIG_HOLO, + Y_CENTRE_BIG_HOLO, + 128,1024,1024 ) ; + +// boucle aff + memoflagspeak = FlagSpeak ; + FlagSpeak = FALSE ; + InitDial( 2 ) ; + + TestCoulDial( 9 ) ; + + dialmess = ListHoloPos[NumCube].Mess ; + +// FlagMessageShade = FALSE ; + + flagredraw = TRUE ; + + otimer = TimerRef ; + dalpha = ListHoloPos[NumCube].Alpha & 1023 ; + dbeta = ListHoloPos[NumCube].Beta & 1023 ; + + calpha = oalpha = dalpha ; + cbeta = obeta = dbeta ; + automove = 0 ; + + current = NumCube ; + + while( (Key != K_ESC) AND (Key != K_H) AND !(Fire&F_RETURN) ) + { + if( flagrebond ) + { + if( !Joy AND !Fire ) flagrebond = FALSE ; + } + else + { + MyKey = Key ; + MyFire = Fire ; + MyJoy = Joy ; + + if( MyFire & F_CTRL ) + { + if( (dialstat != 1) AND (!automove) ) + { + if( MyJoy & J_UP ) calpha-=8 ; + if( MyJoy & J_DOWN ) calpha+=8 ; + if( MyJoy & J_LEFT ) cbeta-=8 ; + if( MyJoy & J_RIGHT ) cbeta+=8 ; + } + + calpha &= 1023 ; + cbeta &= 1023 ; + } + else + { + // search & goto next arrow + + if( MyJoy & J_RIGHT ) + { + current = SearchNextArrow( current ) ; + if( current == -1 ) + { + oalpha = calpha ; + obeta = cbeta ; + otimer = TimerRef ; + dalpha = ListHoloPos[NumCube].Alpha & 1023 ; + dbeta = ListHoloPos[NumCube].Beta & 1023 ; + + dialstat = 3 ; + dialmess = ListHoloPos[NumCube].Mess ; + } + else + { + oalpha = calpha ; + obeta = cbeta ; + otimer = TimerRef ; + dalpha = ListHoloPos[current].Alpha & 1023 ; + dbeta = ListHoloPos[current].Beta & 1023 ; + + dialstat = 3 ; + dialmess = ListHoloPos[current].Mess ; + } + automove = TRUE ; + flagrebond = TRUE ; + } + + if( MyJoy & J_LEFT ) + { + current = SearchPrevArrow( current ) ; + if( current == -1 ) + { + oalpha = calpha ; + obeta = cbeta ; + otimer = TimerRef ; + dalpha = ListHoloPos[NumCube].Alpha & 1023 ; + dbeta = ListHoloPos[NumCube].Beta & 1023 ; + + dialstat = 3 ; + dialmess = ListHoloPos[NumCube].Mess ; + } + else + { + oalpha = calpha ; + obeta = cbeta ; + otimer = TimerRef ; + dalpha = ListHoloPos[current].Alpha & 1023 ; + dbeta = ListHoloPos[current].Beta & 1023 ; + + dialstat = 3 ; + dialmess = ListHoloPos[current].Mess ; + } + automove = TRUE ; + flagrebond = TRUE ; + } + } + + +/* if( MyJoy & J_UP ) menumode++, flagrebond = TRUE, redrawmenu = TRUE ; + if( menumode > 3 ) menumode = 0 ; + if( MyJoy & J_DOWN ) menumode--, flagrebond = TRUE, redrawmenu = TRUE ; + if( menumode < 0 ) menumode = 3 ; +*/ + } // flagrebond + + if( automove ) + { + calpha = BoundRegleTrois( oalpha, dalpha, 75, TimerRef-otimer ) ; + cbeta = BoundRegleTrois( obeta, dbeta, 75, TimerRef-otimer ) ; + flagredraw = TRUE ; + } + +// calpha &= 1023 ; +// cbeta &= 1023 ; + +/* +CoulText( 15, 0 ) ; +Text( 0,0, "%Falpha:%d beta:%d ", calpha, cbeta ) ; +Text( 0,10, "%Foalpha:%d obeta:%d ", oalpha, obeta ) ; +Text( 0,20, "%Fdalpha:%d dbeta:%d ", dalpha, dbeta ) ; +Text( 0,30, "%Fcurrent:%d mess:%d ", current, ListHoloPos[current].Mess ) ; +*/ + + // cycle palette flotte + if( !flagpal ) + { + PalMulti( 12*16, 32, RotPal+(RotPalPos*3) ) ; + RotPalPos++ ; + if( RotPalPos == 32 ) RotPalPos = 0 ; + } + +// affiche big holo + + if( dialstat != 1 ) flagredraw = TRUE ; + + if( flagredraw == TRUE ) + { + flagredraw = FALSE ; + + + Box( X_CENTRE_BIG_HOLO-LARGEUR_BIG_HOLO/2, + Y_CENTRE_BIG_HOLO-HAUTEUR_BIG_HOLO/2, + X_CENTRE_BIG_HOLO+LARGEUR_BIG_HOLO/2, + Y_CENTRE_BIG_HOLO+HAUTEUR_BIG_HOLO/2, 0 ) ; + + SetInverseAngleCamera( calpha,cbeta,cgamma ) ; + SetLightVector( calpha, cbeta, 0 ) ; + + // aff obj derriere + + DrawListPos( calpha, cbeta, cgamma, 0 ) ; + + // draw sphŠre +// SetFollowCamera( 0,0,0, calpha,cbeta,cgamma, ZOOM_BIG_HOLO ) ; + SetInverseAngleCamera( calpha,cbeta,cgamma ) ; + CameraXr = 0 ; + CameraYr = 0 ; + CameraZr = ZOOM_BIG_HOLO ; + + DrawHoloMap( calpha, -cbeta, cgamma ) ; + + // aff obj devant + DrawListPos( calpha, cbeta, cgamma, 1 ) ; + + if( automove ) DrawCurseur() ; + + CopyBlockPhys( X_CENTRE_BIG_HOLO-LARGEUR_BIG_HOLO/2, + Y_CENTRE_BIG_HOLO-HAUTEUR_BIG_HOLO/2, + X_CENTRE_BIG_HOLO+LARGEUR_BIG_HOLO/2, + Y_CENTRE_BIG_HOLO+HAUTEUR_BIG_HOLO/2 ) ; + } + + if( automove ) + { + if( (dalpha == calpha) + AND (dbeta == cbeta) ) + { + automove = FALSE ; + } + } + + +// affiche message + + if( dialstat == 3 ) + { + OpenDial( dialmess ) ; + dialstat = 0 ; + } + + if( dialstat != 2 ) + { + dialstat = NextDialCar() ; + } + + if( MyFire & F_SPACE ) + { + if( dialstat == 2 ) + { + dialstat = 0 ; + } + else + { + OpenDial( dialmess ) ; + } + } + +// Text( 0,0, "Xmin: %d Ymin: %d Xmax: %d Ymax: %d Zoom: %d", ScreenXmin,ScreenYmin,ScreenXmax,ScreenYmax,zoom ) ; + +// fade in 1ere fois + if( flagpal ) + { + flagpal = FALSE ; + FadeToPal( PalettePcx ) ; + } + } + + FlagMessageShade = TRUE ; + FadeToBlack( PalettePcx ) ; + +/* Cls() ; + Flip() ; +*/ + AlphaLight = alphalight ; + BetaLight = betalight ; + Init3DGame() ; + + FlagSpeak = memoflagspeak ; + InitDial( START_FILE_ISLAND+Island ) ; + + for(n=0; n<768; n++) PalettePcx[n] = savepalette[n] ; + + RestoreTimer() ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û Û ÛßßßÛ Û ÛßßßÛ ßßÛßß ÛßßßÛ ÛßßßÛ Û + ÛÛßßÛ ÛÛ Û ÛÛ ÛÛ Û ÛÛ ÛÛßÛß ÛÛßßÛ ÜÜ Û + ßß ß ßßßßß ßßßßß ßßßßß ßß ßß ß ßß ß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + + // 0 cube source + // 1 cube dest + // 2 vehicule + // 3 alpha + // 4 beta + // 5 gamma + // 6 nbpoints + // { + // alpha + // beta + // } + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DrawHoloObj( UBYTE *ptr3do, WORD alpha, WORD beta, WORD size ) +{ + LONG xm, ym, zm ; + LONG x1, y1, z1 ; + + SetAngleCamera( alpha, beta, 0 ) ; + WorldRotatePoint( 0,0, 1000 + size ) ; + xm = X0 ; + ym = Y0 ; + zm = Z0 ; + + SetFollowCamera( 0,0,0, CamAlpha,CamBeta,CamGamma, 5300 ) ; + + WorldRotatePoint( xm, ym, zm ) ; + x1 = X0 ; + y1 = Y0 ; + z1 = Z0 ; + + UnSetClip() ; + AffObjetIso( xm,ym,zm, + alpha, beta, 0, + ptr3do ) ; + + CopyBlockPhys( ScreenXmin, ScreenYmin, ScreenXmax, ScreenYmax ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +WORD *GiveTrajPtr( LONG numtraj ) +{ + WORD *ptr ; + LONG n ; + WORD nbp ; + + ptr = (WORD*)ListTraj ; + + for( n=0; n!=numtraj; n++ ) + { + ptr += 6 ; + nbp = *ptr++ ; + ptr += nbp*2 ; + } + return ptr ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void HoloTraj( WORD numtraj ) +{ + WORD alpha=-256, beta=0, gamma=0 ; + WORD zoom = 22000 ; + LONG y, x = 15 ; + UWORD *ptr, *ptrc ; + UBYTE *mptrv, *ptrv ; + WORD c, n ; + WORD flagredraw ; + WORD flagpal = TRUE ; + WORD *ptrtraj, nbpoints, vehicule, cubestart, cubeend ; + + UBYTE *ptranim, *ptr3do ; + WORD frameanim, vbeta ; + + LONG alphalight, betalight ; + ULONG memotimer ; + +#ifndef DEMO + + // inits + + SaveTimer() ; + + alphalight = AlphaLight ; + betalight = BetaLight ; + + if( FlagPalettePcx ) FadeToBlack( PalettePcx ) ; + else FadeToBlack( PtrPal ) ; + + UnSetClip() ; + Cls() ; + Flip() ; + + InitHoloDatas() ; + + // recup infos traj + + ptrtraj = GiveTrajPtr( numtraj ) ; + + cubestart = ptrtraj[0] ; + cubeend = ptrtraj[1] ; + vehicule = ptrtraj[2] ; + + CamAlpha = ptrtraj[3] ; + CamBeta = ptrtraj[4] ; + CamGamma = ptrtraj[5] ; + + nbpoints = ptrtraj[6] ; + + // vehicule + + ptr3do = LastPtr ; + n = Load_HQR( PATH_RESSOURCE"ress.hqr", + ptr3do, + RESS_HOLO_VEHICULE+vehicule*2 ) ; + PatchObjet( ptr3do ) ; + ptranim = ptr3do + n ; + n = Load_HQR( PATH_RESSOURCE"ress.hqr", + ptranim, + RESS_HOLO_VEHICULE+vehicule*2+1 ) ; + frameanim = 0 ; +// vbeta = rand()&1023 ; + + // draw holo + + SetProjection( X_CENTRE_TRAJ_HOLO, + Y_CENTRE_TRAJ_HOLO, + 128,1024,1024 ) ; + + SetFollowCamera( 0,0,0, CamAlpha,CamBeta,CamGamma, 5300 ) ; + DrawHoloMap( CamAlpha, CamBeta, CamGamma ) ; + Flip() ; + + // premier point + + DrawHoloObj( PtrCone, + ListHoloPos[cubestart].Alpha, + ListHoloPos[cubestart].Beta, + 0 ) ; + + // boucle aff + + n = 0 ; + memotimer = TimerRef ; + while( Key != K_ESC ) + { + // cycle palette flotte + Vsync() ; + if( !flagpal ) + { + PalMulti( 12*16, 32, RotPal+(RotPalPos*3) ) ; + RotPalPos++ ; + if( RotPalPos == 32 ) RotPalPos = 0 ; + } + + // animation vehicule + vbeta = GetRealAngle( &RealRot ) ; + if( RealRot.TimeValue == 0 ) + { + InitRealAngle( vbeta, vbeta-256, 500, &RealRot ) ; + } + + if( SetInterAnimObjet( frameanim, ptranim, ptr3do ) ) + { + frameanim++ ; + if( frameanim == GetNbFramesAnim( ptranim ) ) + { + frameanim = GetBouclageAnim( ptranim ) ; + } + } + + SetProjection( 100, 100+300, 128,900,900 ) ; + SetFollowCamera( 0,0,0, 60,128,0, 30000 ) ; + SetLightVector( -60, 128, 0 ) ; + Box( 0,0+300,199,179+300, 0 ) ; + AffObjetIso( 0,0,0, 0,vbeta,0, ptr3do ) ; + CopyBlockPhys( 0,0+300,199,179+300 ) ; + + SetProjection( X_CENTRE_TRAJ_HOLO, + Y_CENTRE_TRAJ_HOLO, + 128,1024,1024 ) ; + SetFollowCamera( 0,0,0, CamAlpha,CamBeta,CamGamma, 5300 ) ; + SetLightVector( CamAlpha, CamBeta, 0 ) ; + + // points de trajectoire + + if( TimerRef >= memotimer+40 ) + { + memotimer = TimerRef ; + + if( n < nbpoints ) + { + alpha = ptrtraj[7+n*2] ; + beta = ptrtraj[8+n*2] ; + } + else + { + if( n > nbpoints ) break ; // c'est fini + + alpha = ListHoloPos[cubeend].Alpha ; + beta = ListHoloPos[cubeend].Beta ; + } + + DrawHoloObj( PtrCone,alpha,beta,0 ) ; + n++ ; + } + + // fade intro + if( flagpal ) + { + flagpal = FALSE ; + FadeToPal( PalettePcx ) ; + } + } + + FadeToBlack( PalettePcx ) ; + Cls() ; + Flip() ; + + AlphaLight = alphalight ; + BetaLight = betalight ; + Init3DGame() ; + + RestoreTimer() ; +#endif +} + diff --git a/SOURCES/HOLOMAP.DEF b/SOURCES/HOLOMAP.DEF new file mode 100644 index 0000000..0efa3c1 --- /dev/null +++ b/SOURCES/HOLOMAP.DEF @@ -0,0 +1,17 @@ +extern void ComputeCoorMapping(void); +extern void ComputeCoorGlobe(void); +extern int z_sort(short *,short *); +extern void ComputeGlobeProj(void); +extern void DrawHoloMap(short ,short ,short ); +extern void DrawListPos(short ,short ,short ,short ); +extern long SearchNextArrow(long ); +extern long SearchPrevArrow(long ); +extern void SetHoloPos(unsigned char ); +extern void ClrHoloPos(unsigned char ); +extern void DrawTitle(short ,short ,short ); +extern void DrawCurseur(void); +extern void InitHoloDatas(void); +extern void HoloMap(void); +extern void DrawHoloObj(unsigned char *,short ,short ,short ); +extern short *GiveTrajPtr(long ); +extern void HoloTraj(short ); diff --git a/SOURCES/INCRUST.C b/SOURCES/INCRUST.C new file mode 100644 index 0000000..766a943 --- /dev/null +++ b/SOURCES/INCRUST.C @@ -0,0 +1,108 @@ +#include "c_extern.h" + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û ÛÛÜ Û Ûßßßß ÛßßßÛ Û Û ÛÛßßß ßßÛßß ÛßßßÜ Û ÛÛßßß ÛßßßÛ + ÛÛ ÛÛßÛÛ ÛÛ ÛÛßÛß ÛÛ Û ßßßßÛ ÛÛ ÛÛ Û ÛÛ ßßßßÛ ÛÛßßß + ßß ßß ß ßßßßß ßß ß ßßßßß ßßßßß ßß ßßßßß ßßßß ßß ßßßßß ßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void InitIncrustDisp( WORD type, + WORD num, + WORD x, WORD y, + WORD info, + WORD move, + WORD timeout ) +{ + T_INCRUST_DISP *ptrdisp ; + WORD n ; + + ptrdisp = ListIncrustDisp ; + + for( n=0; nNum == -1 ) /* slot libre */ + { + ptrdisp->Num = num ; + + ptrdisp->X = x ; + ptrdisp->Y = y ; + + ptrdisp->Type = type ; + ptrdisp->Info = info ; + + ptrdisp->Move = move ; + + ptrdisp->TimerEnd = TimerRef + 50 * timeout ; + + return ; + } + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void ChangeIncrustPos( WORD xp0, WORD yp0, WORD xp1, WORD yp1 ) +{ + T_INCRUST_DISP *ptrdisp ; + WORD n ; + WORD dx, dy ; + + dx = xp1 - xp0 ; + dy = yp1 - yp0 ; + + ptrdisp = ListIncrustDisp ; + + for( n=0; nType == INCRUST_NUM ) + { + ptrdisp->X += dx ; + ptrdisp->Y += dy ; + } + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +WORD LastNumBulle = -1 ; +WORD SpriteBulle = 91 ; + +void DrawBulle( WORD numobj ) +{ + LONG dx, dy ; + + ProjettePoint( ListObjet[numobj].PosObjX - WorldXCube, + ListObjet[numobj].PosObjY + ListObjet[numobj].Ymax - WorldYCube, + ListObjet[numobj].PosObjZ - WorldZCube ) ; + + if( LastNumBulle != numobj ) + { + SpriteBulle ^= 1 ; + LastNumBulle = numobj ; + } + + GetDxDyGraph( 0, &dx, &dy, HQR_Get(HQRPtrSpriteExtra, SpriteBulle ) ) ; + + if( SpriteBulle == 90 ) ScreenXmin = Xp + 10 ; + else ScreenXmin = Xp - 10 - dx ; + + ScreenYmin = Yp - 20 ; + + + ScreenXmax = ScreenXmin + dx -1 ; + ScreenYmax = ScreenYmin + dy -1 ; + + SetClip( ScreenXmin, ScreenYmin, ScreenXmax, ScreenYmax ) ; + + AffGraph( 0, ScreenXmin, ScreenYmin, HQR_Get(HQRPtrSpriteExtra, SpriteBulle) ) ; + if( ClipXmin <= ClipXmax + AND ClipYmin <= ClipYmax ) + { + CopyBlockPhys( ClipXmin, ClipYmin, ClipXmax, ClipYmax ) ; + } + + UnSetClip() ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ diff --git a/SOURCES/INCRUST.DEF b/SOURCES/INCRUST.DEF new file mode 100644 index 0000000..b7c3ceb --- /dev/null +++ b/SOURCES/INCRUST.DEF @@ -0,0 +1,3 @@ +extern void InitIncrustDisp(short ,short ,short ,short ,short ,short ,short ); +extern void ChangeIncrustPos(short ,short ,short ,short ); +extern void DrawBulle(short ); diff --git a/SOURCES/M.BAT b/SOURCES/M.BAT new file mode 100644 index 0000000..3ed7d26 --- /dev/null +++ b/SOURCES/M.BAT @@ -0,0 +1,10 @@ +copy f:\projet\lba\tools\perso\common.h +copy f:\projet\lba\tools\perso\grille.h +copy f:\projet\lba\tools\perso\message.c +copy f:\compil\watcom10\lib386\qsort.obj +rem copy f:\compil\watcom10\lib386\hrder386.obj +del version.obj + +call watcom9 +wmake WATCOM9=yes +call watcom10 diff --git a/SOURCES/MAKEFILE b/SOURCES/MAKEFILE new file mode 100644 index 0000000..cbc8d54 --- /dev/null +++ b/SOURCES/MAKEFILE @@ -0,0 +1,66 @@ +# name the compiler +!ifdef %HOME +!ifeq WATCOM9 yes +CC = c:\compil\watcom\bin\wcc386p +CL = c:\compil\watcom\binb\Wcl386 +WL = c:\compil\watcom\binb\wlib +!else +CC = c:\compil\watcom10\binb\wcc386 +CL = c:\compil\watcom10\binb\Wcl386 +WL = c:\compil\watcom10\binb\wlib +!endif +!else +!ifeq WATCOM9 yes +CC = f:\compil\watcom\bin\wcc386p +CL = f:\compil\watcom\binb\Wcl386 +WL = f:\compil\watcom\binb\wlib +!else +CC = f:\compil\watcom10\binb\wcc386 +CL = f:\compil\watcom10\binb\Wcl386 +WL = f:\compil\watcom10\binb\wlib +!endif +!endif + +ASM = ml + +!ifeq WATCOM9 yes +CFLAGS = /oeaxt /zp2 /4s /zq /v /s /DWATCOM9 +# /d2 +# /DTRACE +!else +CFLAGS = /oeaxt /zp2 /5s /zq /s +!endif +AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=; +LFLAGS = /l=dos4g /x /zq /4s /k7000 +# /d2 +# /"OPTION SYMFILE=LBA.SYM OPTION MAP=LBA.MAP" + +.SILENT + +OBJETS1 = version.obj perso.obj object.obj global.obj +OBJETS2 = flipbox.obj diskfunc.obj fiche.obj extra.obj incrust.obj +OBJETS3 = grille.obj grille_a.obj func.obj cpymask.obj +OBJETS4 = Message.obj ambiance.obj Balance.obj gamemenu.obj fire.obj +OBJETS5 = geretrak.obj gerelife.obj +OBJETS6 = HoloMap.obj playfla.obj adfli_a.obj mcga.obj + +EXE = LBA0 + +$(EXE).exe: $(OBJETS1) $(OBJETS2) $(OBJETS3) $(OBJETS4) $(OBJETS5) $(OBJETS6) + if exist tempo.obs del tempo.obs + if exist tempo.obj del tempo.obj + copy /B *.obj tempo.obs + ren tempo.obs tempo.obj + $(CL) $(LFLAGS) /fe=$(EXE).exe tempo.obj + del tempo.obj + prntitre M "$(EXE) OK" +# wstrip $(EXE) + copy $(EXE).exe \projet\lba\game + +.c.obj : + PRNTITRE M "$*.C" + $(CC) $^& $(CFLAGS) + +.asm.obj : + PRNTITRE M "$*.ASM" + $(ASM) $(AFLAGS) $^&.ASM diff --git a/SOURCES/MALLOC.C b/SOURCES/MALLOC.C new file mode 100644 index 0000000..d5b0038 --- /dev/null +++ b/SOURCES/MALLOC.C @@ -0,0 +1,315 @@ +/* + MALLOC (c) Adeline 1993 + + Functions: + + - Malloc + - Free + - Mshrink +*/ + +#include +#include +#include +#include +#include +#include + +#include "h:\projet\lib386\lib_sys\adeline.h" +#include "h:\projet\lib386\lib_sys\lib_sys.h" + +struct meminfo { + unsigned LargestBlockAvail; + unsigned MaxUnlockedPage; + unsigned LargestLockablePage; + unsigned LinAddrSpace; + unsigned NumFreePagesAvail; + unsigned NumPhysicalPagesFree; + unsigned TotalPhysicalPages; + unsigned FreeLinAddrSpace; + unsigned SizeOfPageFile; + unsigned Reserved[3]; +} MemInfo; + +#define DPMI_INT 0x31 + + +// #define DEBUG_MALLOC 1 + +#ifdef DEBUG_MALLOC +LONG ModeTraceMalloc = FALSE ; +#endif + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* Special, Allocate Memory Under First Meg */ +void *DosMalloc( LONG size, ULONG *handle ) +{ + union REGS r ; + ULONG strat ; + ULONG addr ; + +//#ifdef jhjkhjkhjlk + r.x.eax = 0x5800 ; + int386( 0x21, &r, &r ) ; + strat = r.x.eax ;/* Save DOS alloc strategie */ + + r.x.eax = 0x5801 ; + r.x.ebx = 1 ;/* Low mem, best fit */ + int386( 0x21, &r, &r ) ;/* Set alloc strategie */ +//#endif + r.x.eax = 0x0100 ;/* Function allocate Dos Memory */ + if (size == -1) + r.x.ebx = -1 ;/*Number off Paragraphs Requested */ + else + r.x.ebx =(size+15)>>4;/*Number off Paragraphs Requested */ + int386( 0x31, &r, &r ) ;/* Invoke DPMI */ + + addr = 0 ; + if (size == -1) + { + if( r.x.cflag ) + addr = (r.x.ebx & 0xFFFF) << 4 ; + } + else + { + if( !r.x.cflag ) + { + if (handle) *handle = r.x.edx & 0xFFFF;/* DPMI selector*/ + addr = (r.x.eax & 0xFFFF) << 4;/* Ok, Take this! */ + } + } + +//#ifdef hjhkjhlhjk + r.x.eax = 0x5801 ; + r.x.ebx = strat ;/* Odl startegie */ + int386( 0x21, &r, &r ) ;/* Set alloc strategie */ +//#endif + return((void *)addr) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* Special, Free Allocated Memory Under First Meg */ +void DosFree( ULONG handle ) +{ + union REGS r ; + + r.x.eax = 0x0101 ;/* Function allocate Dos Memory */ + r.x.edx = handle ;/* DPMI Selector */ + int386( 0x31, &r, &r ) ;/* Invoke DPMI */ +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#ifdef DEBUG_MALLOC + +LONG mymalloc( LONG lenalloc, void **memptr ) +{ + union REGS regs ; + struct SREGS sregs ; + UBYTE *ptr ; + + lenalloc+=16; + regs.x.eax = 0x00000501 ; + regs.x.ebx = lenalloc>>16 ; + regs.x.ecx = lenalloc & 0xFFFF ; + sregs.es = 0 ; + sregs.ds = 0 ; + sregs.fs = 0 ; + sregs.gs = 0 ; + int386x( DPMI_INT, ®s, ®s, &sregs ) ; + + if( regs.x.cflag ) + { + *memptr = NULL ; + return regs.x.eax ; + } + + ptr=(UBYTE *)((regs.x.ebx<<16) | (regs.x.ecx & 0xFFFF)); + + *(WORD*)(ptr+0)=(WORD)regs.x.esi ; + *(WORD*)(ptr+2)=(WORD)regs.x.edi ; + + *memptr=(void*)(ptr+16) ; + return 0 ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +LONG myfree( void *ptr ) +{ + union REGS regs ; + struct SREGS sregs ; + UBYTE *ptrh ; + + ptrh = ptr ; + ptrh -= 16 ; + + regs.x.esi = *(WORD*)(ptrh+0) ; + regs.x.edi = *(WORD*)(ptrh+2) ; + regs.x.eax = 0x00000502 ; + sregs.es = 0 ; + sregs.ds = 0 ; + sregs.fs = 0 ; + sregs.gs = 0 ; + int386x( DPMI_INT, ®s, ®s, &sregs ) ; + + return regs.x.cflag ? regs.x.eax : 0 ; +} + +#endif + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +void *SmartMalloc( LONG lenalloc ) +{ + union REGS r ; + ULONG strat ; + ULONG addr ; + + r.x.eax = 0x5800 ; + int386( 0x21, &r, &r ) ; + strat = r.x.eax ;/* Save DOS alloc strategie */ + + r.x.eax = 0x5801 ; + r.x.ebx = 0x81 ;/* UMB first then Low mem, best fit*/ + int386( 0x21, &r, &r ) ;/* Set alloc strategie */ + + r.x.eax = 0x0100 ;/* Function allocate Dos Memory */ + r.x.ebx =(lenalloc+15)>>4;/*Number off Paragraphs Requested */ + int386( 0x31, &r, &r ) ;/* Invoke DPMI */ + + if( !r.x.cflag ) + addr = (r.x.eax & 0xFFFF) << 4;/* Ok, Take this! */ + else + addr = (ULONG)malloc( lenalloc ); + + r.x.eax = 0x5801 ; + r.x.ebx = strat ;/* Odl startegie */ + int386( 0x21, &r, &r ) ;/* Set alloc strategie */ + + return((void *)addr) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +void *Malloc( LONG lenalloc ) +{ + union REGS regs ; + struct SREGS sregs ; + void *ptr ; + FILE *fh ; + ULONG size, error ; + + if ( lenalloc != -1 ) + { +#ifdef DEBUG_MALLOC + if( ModeTraceMalloc ) + { + fh = fopen( "c:\\malloc.lst","a+t" ) ; + if( fh != NULL ) + { + regs.x.eax = 0x00000500 ; + sregs.es = FP_SEG( &MemInfo ) ; + sregs.ds = 0 ; + regs.x.edi = FP_OFF( &MemInfo ) ; + int386x( DPMI_INT, ®s, ®s, &sregs ) ; + size = MemInfo.LargestBlockAvail ; + + fprintf( fh, "Mem: %d\n", size ) ; + } + + error = mymalloc(lenalloc, &ptr) ; +// ptr = malloc( lenalloc ) ; + + if( fh != NULL ) + { + fprintf( fh, "Malloc: %d bytes at %X to %X\n", lenalloc, ptr, (LONG)ptr+lenalloc ) ; + if( error ) + fprintf( fh, "Error: %X\n", error ) ; + + regs.x.eax = 0x00000500 ; + sregs.es = FP_SEG( &MemInfo ) ; + sregs.ds = 0 ; + regs.x.edi = FP_OFF( &MemInfo ) ; + int386x( DPMI_INT, ®s, ®s, &sregs ) ; + size = MemInfo.LargestBlockAvail ; + + fprintf( fh, "Mem: %d\n", size ) ; + + fclose( fh ) ; + } + } + else +#endif + { + ptr = malloc( lenalloc ) ; + } + + return( ptr ) ; + + } + regs.x.eax = 0x00000500 ; + sregs.es = FP_SEG( &MemInfo ) ; + sregs.ds = 0 ; + regs.x.edi = FP_OFF( &MemInfo ) ; + + int386x( DPMI_INT, ®s, ®s, &sregs ) ; + + return( (void *)MemInfo.LargestBlockAvail ) ; +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +void Free( void *buffer ) +{ + union REGS regs ; + struct SREGS sregs ; + void *ptr ; + FILE *fh ; + ULONG size, error ; + +#ifdef DEBUG_MALLOC + if( ModeTraceMalloc ) + { + fh = fopen( "c:\\malloc.lst","a+t" ) ; + if( fh != NULL ) + { + regs.x.eax = 0x00000500 ; + sregs.es = FP_SEG( &MemInfo ) ; + sregs.ds = 0 ; + regs.x.edi = FP_OFF( &MemInfo ) ; + int386x( DPMI_INT, ®s, ®s, &sregs ) ; + size = MemInfo.LargestBlockAvail ; + + fprintf( fh, "Mem: %d\n", size ) ; + } + + error = myfree( buffer ) ; +// free( buffer ) ; + + if( fh != NULL ) + { + fprintf( fh, "Free: %X\n", buffer ) ; + if( error ) + fprintf( fh, "Error: %X\n", error ) ; + + regs.x.eax = 0x00000500 ; + sregs.es = FP_SEG( &MemInfo ) ; + sregs.ds = 0 ; + regs.x.edi = FP_OFF( &MemInfo ) ; + int386x( DPMI_INT, ®s, ®s, &sregs ) ; + size = MemInfo.LargestBlockAvail ; + + fprintf( fh, "Mem: %d\n", size ) ; + + fclose( fh ) ; + } + } + else +#endif + { + free( buffer ) ; + } +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +void *Mshrink( void *buffer, ULONG taille ) +{ + return _expand( buffer, (size_t)taille ) ; +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ diff --git a/SOURCES/MALLOC.DEF b/SOURCES/MALLOC.DEF new file mode 100644 index 0000000..a1e244a --- /dev/null +++ b/SOURCES/MALLOC.DEF @@ -0,0 +1,6 @@ +extern void *DosMalloc(long ,unsigned long *); +extern void DosFree(unsigned long ); +extern void *SmartMalloc(long ); +extern void *Malloc(long ); +extern void Free(void *); +extern void *Mshrink(void *,unsigned long ); diff --git a/SOURCES/MASK_A.ASM b/SOURCES/MASK_A.ASM new file mode 100644 index 0000000..a3d8502 --- /dev/null +++ b/SOURCES/MASK_A.ASM @@ -0,0 +1,600 @@ +;---------------------------------------------------------------------------- +; Mask_A.ASM 386 +; (c) Adeline 1993 +;---------------------------------------------------------------------------- + .386P + .model SMALL, SYSCALL +;---------------------------------------------------------------------------- + .data +;---------------------------------------------------------------------------- + include \projet\lib386\lib_svga\svga.ash +comment @ + DWORD TabOffset[] + Brick: + - BYTE Delta X + - BYTE Delta Y + Line(Delta Y): + - BYTE NbBlock + Block 0: Nb Zero to Jump + Block 1: Nb Zero to Write + Block 2: Nb Zero to Jump + etc... +@ + +BufferClip db 512 dup(?) +OffsetBegin dd 0 +NbPix dd 0 + +extrn NoLanguage Screen:DWORD + +;---------------------------------------------------------------------------- + .code + + public NoLanguage CopyMask + public NoLanguage AffMask + public NoLanguage GetDxDyMask + +;---------------------------------------------------------------------------- +CopyMask proc uses esi edi ebx ebp,\ + nummask:DWORD, xmask:DWORD, ymask:DWORD, \ + bankmask:DWORD, ptsrc:DWORD + + mov eax, nummask + mov ebx, xmask + mov ecx, ymask + mov esi, bankmask + + add esi, [esi+eax*4]; ESI = Begin Data + + + movzx eax, byte ptr[esi+2] ; Hot X + add ebx, eax + movzx eax, byte ptr[esi+3] ; Hot Y + add ecx, eax + + +;----------------------------------------------- + lodsb ; Delta X + movzx edx, al ; + lodsb ; Nb Line ( Delta Y ) + movzx eax, al + + + add esi, 2 ; Jump Hot X & Hot Y + + +;----------------------------------------------- Test Clipping + add edx, ebx + add eax, ecx + dec edx + dec eax + cmp ebx, ClipXmin + jl ClippingMask + cmp ecx, ClipYmin + jl ClippingMask + cmp edx, ClipXmax + jg ClippingMask + cmp eax, ClipYmax + jg ClippingMask + sub edx, ebx + sub eax, ecx + inc edx + inc eax +;----------------------------------------------- Calcul Offset Ecran + add ebx, TabOffLine[ecx*4] + + mov edi, Log + add edi, ebx + + mov ebp, ptsrc + add ebp, ebx + + mov bh, al ; BH = NbLine + sub edx, Screen_X ; EDX = Offset Screen + neg edx ; EDX = Screen_X-edx + xor ecx, ecx ; Maz Compteur + mov eax, ecx +;----------------------------------------------- Init NbBlock for this line +NextLine: lodsb ; Nb Block for this line + mov bl, al ; BL = NbBlock +;----------------------------------------------- Manage One Line +SameLine: lodsb ; Nb Zero to Jump + add edi, eax ; Incrust on Log + add ebp, eax ; And on PtSrc + + dec bl + je EndBlock + + lodsb ; Nb Zero to Write + mov cl, al + +; xor al, al +; rep stosb + + xchg esi, ebp + mov al, cl + shr cl, 2 + rep movsd ; Write Datas From PtSrc + mov cl, al + and cl, 11b + rep movsb + xchg esi, ebp + + + dec bl ; Nb Block-- + jne SameLine ; Continue Same Line +EndBlock: + add edi, edx ; EDI += Offset Screen + add ebp, edx + dec bh ; NbLine-- + jne NextLine ; Next Line +;----------------------------------------------- Incrust + ret +;-------------------------------------------------------------------- Clipping +; Graph : ( EBX, ECX ) ( EDX, EAX ) +ClippingMask: + cmp ebx, ClipXmax + jg EndMask + cmp ecx, ClipYmax + jg EndMask + cmp edx, ClipXmin + jl EndMask + cmp eax, ClipYmin + jl EndMask + + cmp ecx, ClipYmin + jge PasHaut + +;---------------------- Clipping Haut, Saute ClipYmin-ECX Line(s) + + sub ecx, ClipYMin + neg ecx + mov ebp, eax + xor eax, eax + +NextH: lodsb + add esi, eax + loop NextH + + mov ecx, ClipYMin + mov eax, ebp + +;---------------------- Clipping Bas +PasHaut: cmp eax, ClipYmax + jle PasBas + mov eax, ClipYmax +;---------------------- Clipping Gauche +Pasbas: mov OffsetBegin, 0 + cmp ebx, ClipXmin + jge PasGauche + + mov ebp, ClipXmin + sub ebp, ebx + mov OffsetBegin, ebp + +;---------------------- Clipping Droit +PasGauche: + mov ebp, edx + sub ebp, ebx + sub ebp, OffsetBegin + inc ebp + mov NbPix, ebp + + cmp edx, ClipXmax + jle PasDroit + + sub edx, ClipXmax + sub NbPix, edx + mov edx, ClipXmax +;---------------------- + + + + + + + + + +PasDroit: ; ESI debut data Y ok pas X + ; EBX not clipped X0 + ; ECX good Y0 + ; EAX clipped Y1 + ; NbPix real X nb pix + ; OffsetBegin start X ( !!!!! < 128 ) + + mov ebp, esi + + mov edi, TabOffLine[ecx*4] + add edi, ebx + mov esi, edi ; good Y offset screen + add edi, Log + add esi, Screen ; Screen + + mov edx, eax + sub edx, ecx + inc edx + + xor ecx, ecx + +l1: push esi + push edi + + mov bl, byte ptr[ebp] ; nb blocs + inc ebp + + mov bh, byte ptr[NbPix] ; nb point … copier + + mov ecx, [OffsetBegin] ; start x + mov ah, cl ; nb pix count + add edi, ecx ; new pos screen + add esi, ecx + +l0: mov al, byte ptr[ebp] ; nb pix to jump + inc ebp + dec bl + sub ah, al + jz okdraw ; tombe pile + jc rptj ; reste pix to jump + or bl, bl + jz aplus + + mov al, byte ptr[ebp] ; nb copy point + inc ebp + dec bl + sub ah, al + jz okjump + jc rgtc ; reste graph to copy + + or bl, bl ; jmp l0 + jnz l0 + jmp aplus + +rptj: neg ah ; ah nb pix to jump + mov cl, ah + sub bh, ah ; reste … ecrire + jle aplus + add edi, ecx + add esi, ecx + jmp okdraw + +rgtc: neg ah ; al nb pix to copy + mov cl, ah + sub bh, ah ; reste … ecrire + jc cpt ; copy pas tout + rep movsb ; copy + jz aplus ; tombe pile + jmp okjump + +cpt: add cl, bh + rep movsb + jmp aplus + + EVEN +okjump: mov cl, byte ptr[ebp] ; al nb pix to jump + inc ebp + dec bl + jz aplus + sub bh, cl ; reste … ecrire + jle aplus ; fini + add edi, ecx + add esi, ecx + +okdraw: mov cl, byte ptr[ebp] ; nb pix to copy + inc ebp + dec bl + sub bh, cl ; reste … ecrire + jc cpt ; copy pas tout + rep movsb ; copy + jz aplus ; tombe pile + or bl,bl ; nb bloc-- + jz aplus + jmp short okjump + +aplus: ; ligne finie + + movzx eax, bl + add ebp, eax + + pop edi + pop esi + add edi, 640 + add esi, 640 + + + dec dl ; nb lig-- + jnz l1 + + + + +comment # + add ebx, TabOffLine[ecx*4] + mov edi, Log + add edi, ebx + + sub eax, ecx + inc al + mov bh, al ; BH NbLine + xor ecx, ecx + mov ebp, edi +;---------------------------------------------- + ; ESI = DATAS LINE +NextL: lea edi, BufferClip ; EDI = BUFFERCLIP + lodsb ; NbBlock + mov bl, al +SameL: lodsb + mov cl, al + mov al, 1 + rep stosb + dec bl + je EndLine + lodsb + mov cl, al + xor al, al + rep stosb + dec bl + jne SameL +;---------------------- +EndLine: push esi ; SAVE ESI + lea esi, BufferClip ; ESI = BUFFERCLIP + mov edi, ebp ; EDI = SCREEN + mov ecx, OffsetBegin + add esi, ecx + add edi, ecx + mov ecx, NbPix +;---------------------- +Again: + lodsb + or al, al + jne Incrust + mov [edi], al +Incrust: inc edi + loop Again + + add ebp, 640 + pop esi + dec bh + jne NextL +;---------------------- + # + +EndMask: ret + +CopyMask endp + +;---------------------------------------------------------------------------- +AffMask proc uses esi edi ebx ebp,\ + nummask:DWORD, xmask:DWORD, ymask:DWORD, \ + bankmask:DWORD + + mov eax, nummask + mov ebx, xmask + mov ecx, ymask + mov esi, bankmask + + add esi, [esi+eax*4]; ESI = Begin Data + + +;----------------------------------------------- + lodsb ; Delta X + movzx edx, al ; + lodsb ; Nb Line ( Delta Y ) + movzx eax, al +;----------------------------------------------- Test Clipping + add edx, ebx + add eax, ecx + dec edx + dec eax + cmp ebx, ClipXmin + jl ClippingMask + cmp ecx, ClipYmin + jl ClippingMask + cmp edx, ClipXmax + jg ClippingMask + cmp eax, ClipYmax + jg ClippingMask + sub edx, ebx + sub eax, ecx + inc edx + inc eax +;----------------------------------------------- Calcul Offset Ecran + mov edi, Log + add edi, TabOffLine[ecx*4] + add edi, ebx + mov bh, al ; BH = NbLine + sub edx, Screen_X ; EDX = Offset Screen + neg edx ; EDX = Screen_X-edx + xor ecx, ecx ; Maz Compteur +;----------------------------------------------- Init NbBlock for this line +NextLine: lodsb ; Nb Block for this line + mov bl, al ; BL = NbBlock +;----------------------------------------------- Manage One Line +SameLine: lodsb ; Nb Zero to Jump + add edi, eax ; Incrust + dec bl + je EndBlock + lodsb ; Nb Zero to Write + mov cl, al + xor al, al + rep stosb ; Write Zero + dec bl ; Nb Block-- + jne SameLine ; Continue Same Line +EndBlock: + add edi, edx ; EDI += Offset Screen + dec bh ; NbLine-- + jne NextLine ; Next Line +;----------------------------------------------- Incrust + ret +;-------------------------------------------------------------------- Clipping +; Graph : ( EBX, ECX ) ( EDX, EAX ) +ClippingMask: + cmp ebx, ClipXmax + jg EndMask + cmp ecx, ClipYmax + jg EndMask + cmp edx, ClipXmin + jl EndMask + cmp eax, ClipYmin + jl EndMask + + cmp ecx, ClipYmin + jge PasHaut + +;---------------------- Clipping Haut, Saute ClipYmin-ECX Line(s) + + push eax + push ebx + + mov ebx, ClipYmin + sub ebx, ecx + +;---------------------- + xor eax, eax +NextH: lodsb ; NbBlock + add esi, eax ; Jump Data + dec bl + jne NextH + + mov ecx, ClipYmin ; New Y Haut + + pop ebx + pop eax +;---------------------- Clipping Bas +PasHaut: cmp eax, ClipYmax + jle PasBas + mov eax, ClipYmax +;---------------------- Clipping Gauche +Pasbas: mov OffsetBegin, 0 + cmp ebx, ClipXmin + jge PasGauche + push eax + mov eax, ClipXmin + sub eax, ebx + mov OffsetBegin, eax + pop eax +;---------------------- Clipping Droit +PasGauche: push eax + mov eax, edx + sub eax, ebx + sub eax, OffsetBegin + inc eax + mov NbPix, eax + pop eax + + cmp edx, ClipXmax + jle PasDroit + + sub edx, ClipXmax + sub NbPix, edx + mov edx, ClipXmax +;---------------------- +PasDroit: + + mov edi, Log + add edi, TabOffLine[ecx*4] + add edi, ebx + + + sub eax, ecx + inc al + mov bh, al ; BH NbLine + xor ecx, ecx + mov ebp, edi +;---------------------------------------------- + ; ESI = DATAS LINE +NextL: lea edi, BufferClip ; EDI = BUFFERCLIP + lodsb ; NbBlock + mov bl, al +SameL: lodsb + mov cl, al + mov al, 1 + rep stosb + dec bl + je EndLine + lodsb + mov cl, al + xor al, al + rep stosb + dec bl + jne SameL +;---------------------- +EndLine: push esi ; SAVE ESI + lea esi, BufferClip ; ESI = BUFFERCLIP + mov edi, ebp ; EDI = SCREEN + mov ecx, OffsetBegin + add esi, ecx + add edi, ecx + mov ecx, NbPix +Again: lodsb + or al, al + jne Incrust + mov [edi], al +Incrust: inc edi + loop Again + add ebp, 640 + pop esi + dec bh + jne NextL + +;---------------------- +EndMask: ret +AffMask endp +;---------------------------------------------------------------------------- +GetDxDyMask proc uses esi edi ebx,\ + num:DWORD, ptdx:DWORD, ptdy:DWORD, bankmask:DWORD + + mov esi, bankmask + mov eax, num + add esi, [esi+eax*4] + mov edi, ptdx + lodsb + movzx eax, al + stosd + mov edi, ptdy + lodsb + movzx eax, al + stosd + ret +GetDxDyMask endp +;---------------------------------------------------------------------------- +; The + End + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOURCES/MCGA.ASM b/SOURCES/MCGA.ASM new file mode 100644 index 0000000..144c691 --- /dev/null +++ b/SOURCES/MCGA.ASM @@ -0,0 +1,53 @@ +;---------------------------------------------------------------------------- +; +;' MCGA.ASM 386 +;' (c) Adeline 1994 +; +;---------------------------------------------------------------------------- + .386P + .model SMALL, SYSCALL + JUMPS +;---------------------------------------------------------------------------- + .data +;---------------------------------------------------------------------------- + include \projet\lib386\lib_svga\svga.ash +;---------------------------------------------------------------------------- + public NoLanguage Mcga_Cls + public NoLanguage Mcga_Flip + + .code + +;//-------------------------------------------------------------------------- +Mcga_Cls proc uses edi + + xor eax, eax + + mov edi, Log + mov ecx, 64000/4 + rep stosd + + ret +Mcga_Cls endp + +;//-------------------------------------------------------------------------- +Mcga_Flip proc uses esi edi + + mov esi, Log + mov edi, Phys + + mov ecx, 64000/4 + rep movsd + + ret +Mcga_Flip endp + +;---------------------------------------------------------------------------- +; The + End + + + + + + + diff --git a/SOURCES/MESSAGE.C b/SOURCES/MESSAGE.C new file mode 100644 index 0000000..0d0dabe --- /dev/null +++ b/SOURCES/MESSAGE.C @@ -0,0 +1,1562 @@ +/*-------------------------------------------------------------------------*/ +#ifdef TITRE +/*-------------------------------------------------------------------------*/ + + Û¿ Û¿ ÛÛÛÛÛÛ¿ ÛÛÛÛÛÛ¿ ÛÛÛÛÛÛ¿ ÛÛÛÛÛÛ¿ ÛÛÛÛÛÛ¿ ÛÛÛÛÛÛ¿ +// ÛÛ¿ ÛÛ³ ÛÛÚÄÄÄÙ ÛÛÚÄÄÄÙ ÛÛÚÄÄÄÙ ÛÛÚÄÛÛ³ ÛÛÚÄÄÄÙ ÛÛÚÄÄÄÙ + ÛÛÛÛÛÛ³ ÛÛÛÛÛ¿ ÛÛÛÛÛÛ¿ ÛÛÛÛÛÛ¿ ÛÛÛÛÛÛ³ ÛÛ³ÛÛÛ¿ ÛÛÛÛÛ¿ +// ÛÛÚÄÛÛ³ ÛÛÚÄÄÙ ÀÄÄÄÛÛ³ ÀÄÄÄÛÛ³ ÛÛÚÄÛÛ³ ÛÛ³ÀÛÛ³ ÛÛÚÄÄÙ + ÛÛ³ ÛÛ³ ÛÛÛÛÛÛ¿ ÛÛÛÛÛÛ³ ÛÛÛÛÛÛ³ ÛÛ³ ÛÛ³ ÛÛÛÛÛÛ³ ÛÛÛÛÛÛ¿ + ÀÄÙ ÀÄÙ ÀÄÄÄÄÄÙ ÀÄÄÄÄÄÙ ÀÄÄÄÄÄÙ ÀÄÙ ÀÄÙ ÀÄÄÄÄÄÙ ÀÄÄÄÄÄÙ +/*-------------------------------------------------------------------------*/ +#endif + +//#define CRYPTAGE 1 + + +//#define LORAN 1 +//#define LBA_EDITOR 1 +/*-------------------------------------------------------------------------*/ + +#ifdef LORAN +#include "f:\projet\lib386\lib_sys\adeline.h" +#include "f:\projet\lib386\lib_sys\lib_sys.h" +#include "f:\projet\lib386\lib_svga\lib_svga.h" +#include "f:\projet\lib386\lib_menu\lib_menu.h" +#include "f:\projet\lib386\lib_cd\lib_cd.h" +#include "f:\projet\lib386\lib_3d\lib_3d.h" + +#include +#include +#include +#include +#include +#include +#else +#include "c_extern.h" +#endif +#ifdef LORAN +//================================================================= L O R A N +#define PathConfigFile "c:\\adeline.def" +#define CDROM 1 + +LONG Island ; +extern UBYTE *BufSpeak ; +/*-------------------------------------------------------------------------*/ +void DrawCadre( LONG x0, LONG y0, LONG x1, LONG y1 ) +{ + Rect( x0, y0, x1, y1, 15 ) ; +} +/*-------------------------------------------------------------------------*/ +void *LoadTestMalloc( char *name ) +{ + return(LoadMalloc(name)) ; +} +/*-------------------------------------------------------------------------*/ +LONG GetMusicCD() +{ + return(GetMusicCDR()) ; +} +/*-------------------------------------------------------------------------*/ +void StopMusicCD() +{ + StopCDR() ; +} +/*-------------------------------------------------------------------------*/ +UBYTE *Screen ; +UBYTE *LbaFont; +UBYTE *PalOrg ; +WORD QuickMessage = FALSE ; +//=========================================================================== +#endif + +#ifdef ONE_GAME_DIRECTORY +#define PATH_TXT "" +#define PATH_NAR "" +#else +#define PATH_TXT "f:\\projet\\lba\\text\\" +#define PATH_NAR "f:\\projet\\lba\\samples\\dial\\" +#endif + +#ifdef CDROM +#define PATH_NAR_CD "\\LBA\\VOX\\" +#define PATH_NAR_HD "VOX\\" +#define MAX_FILE_VOICE 42 // SYS CRE GAM 0 1 2 3 4 5 6 7 8 9 10 * MaxLang +#define EXT_NAR ".VOX" +#define FROM_HD 0 +#define FROM_CD 1 +#endif + +#define NAME_HQR_TEXT "TEXT.HQR" +#define MAX_TEXT_LANG 14 // Attention, pour 1 langue seulement! +#define INIT_CODE 01+02+1993 + +#define INTER_LINE 38 +#define INTER_SPACE 7 // 16/08/94 de 5 a 7 ! +#define INTER_LEAVE 2 + +#define MAX_CAR 32 +#define SPEAK_SAMPLE 0x1234 +/*-------------------------------------------------------------------------*/ +static LONG Dial_X0=16 ; +static LONG Dial_Y0=334 ; +static LONG Dial_X1=639-16 ; +static LONG Dial_Y1=479-16 ; +static LONG DialMaxSize=((623-8)-(16+8)); + +static char BufLine[256] ; +static char *PtLine ; +static LONG SizeLine ; +static LONG NbSpace ; +static LONG NbBigSpace ; +static LONG SizeSpace ; +static LONG LenLine ; +static LONG SizeWord ; + +/*-------------------------------------------------------------------------*/ + +static UBYTE BufferMultiText[256] ; +static LONG IslandMultiText = -1 ; +static LONG NumMultiText = -1 ; + +LONG FlecheForcee = FALSE ; +static ULONG SaveTimerForCar; +/*-------------------------------------------------------------------------*/ + +UWORD MaxText ; + +static char FileText[256] ; + +#define NB_LANGUAGES 5 + +LONG Language = 1 ; // English +LONG LastFileInit=-1 ; + +char *TabLanguage[] = { + // Ne pas toucher l'ordre cause HQR + "English", + "Fran‡ais", + "Deutsch", + "Espa¤ol", + "Italiano" } ; + + +char *ListLanguage[] = { "EN_", "FR_", "DE_", "SP_", "IT_" } ; + +char *ListFileText[] = { "sys", + "cre", + "gam", + "000", + "001", + "002", + "003", + "004", + "005", + "006", + "007", + "008", + "009", + "010", + "011" } ; +// Fred flag de cadre shade + +WORD FlagMessageShade = TRUE ; + +typedef struct +{ + WORD c ; + WORD x ; + WORD y ; + +} T_STACKCAR ; + +static T_STACKCAR StackCar[MAX_CAR] ; + +static LONG NbCar ; + +static LONG NbDegrade ; +static LONG MinDegrade ; +static LONG MaxDegrade ; +static LONG StepDegrade ; +UBYTE *BufText=0L ; +static UBYTE *PtText=0L ; +static LONG SizeText ; + +UWORD *BufOrder = 0L ; + +LONG FlagSpeak=FALSE ;// cf InitLanguage +//------------------------------ +#ifdef CDROM +WORD NumObjSpeak = -1 ; +LONG FlagVoiceCD=FALSE ;// cf InitLanguage +static LONG FlagKeepVoice=0 ; + LONG FlagDisplayText=1 ;// ON par default +static LONG FlagNextVoc=FALSE ; +ULONG *BufMemoSeek=0 ; +static ULONG FdNar=0 ; +static ULONG FdCd=0 ; +typedef struct +{ + char NameHD[13+sizeof(PATH_NAR_HD)] ; + ULONG SaveTimer ; + ULONG SizeFileHD ; + +} T_FILEONHD ; + +T_FILEONHD TabFileOnHD[MAX_FILE_VOICE] ; + +ULONG TotalSizeFileHD = 0 ; +LONG LanguageCD = 0 ;// Fran‡ais, a changer of course! +LONG NbFileOnHD = 0 ;// No File for the moment +LONG MaxVoice=0 ; +#endif +//------------------------------ + +static char *PtDial ; +static char Word[256] ; +static char *PtWord ; +static LONG X_Dial, Y_Dial ; +static LONG NbLineDial ; +static LONG MaxLineDial=3 ; +static LONG FlagEnd3Line=FALSE; +static LONG FlagRunningDial=FALSE; +static LONG FlagEndDial=FALSE; +static LONG CurrentDial=0 ; +static LONG LenWord ; + +/*-------------------------------------------------------------------------*/ +void TimeBar( ULONG max, ULONG val ) +{ + ULONG x, dx ; + + MemoClip() ; + UnSetClip() ; + + CopyBlock( 16, 400, 623, 440, Log, 16, 400, Screen ); + + x = RegleTrois32( 17, 622, max, val ) ;// Lib_3D + + PalOne( 14, 23,0,64 ) ; + PalOne( 15, 0,255,255 ) ; + + Rect( 16, 400, 623, 440, 15 ) ; + Box( 17, 401, x, 439, 14 ) ; + + CoulFont( 15 ) ; + dx = SizeFont( PleaseWait ) ; + Font( 320-dx/2, 400, PleaseWait ); + + CopyBlockPhys( 16, 400, 623, 440 ); + + CopyBlock( 16, 400, 623, 440, Screen, 16, 400, Log ); + + RestoreClip() ; +} +/*-------------------------------------------------------------------------*/ + +void InitLanguage() +{ + UBYTE string[256] ; + LONG n ; + + strcpy( string, Def_ReadString( PathConfigFile, "Language" ) ) ; + + for( n=0; nNameHD ))// On ne sait jamais, + Delete( pt->NameHD );// un bug est si vite arrive :-o + } + + TotalSizeFileHD = 0 ; +} +/*-------------------------------------------------------------------------*/ +void CalcTotalSizeFileOnHD() +{ + T_FILEONHD *pt ; + LONG i ; + + TotalSizeFileHD = 0 ; + pt = TabFileOnHD ; + + for ( i = 0 ; i < NbFileOnHD ; i++, pt++ ) + TotalSizeFileHD += pt->SizeFileHD ; + +} +/*-------------------------------------------------------------------------*/ +#ifdef LORAN +void AffStatusVoiceFile() +{ + T_FILEONHD *pt ; + LONG i ; + + Text( 10, 8, "%FStatus des fichiers voix :") ; + + pt = TabFileOnHD; + for ( i = 0 ; i < NbFileOnHD ; i++, pt++ ) + { + Text( 10, i*10+16, "%FName : %s Size : %L Time : %L", pt->NameHD, pt->SizeFileHD, pt->SaveTimer ) ; + } + while( !Key ) ; + while( Key ) ; +} +#endif +/*-------------------------------------------------------------------------*/ +void AddFileNameOnHD( char *filename, ULONG size, ULONG timer ) +{ + T_FILEONHD *pt ; + LONG i ; + + pt = TabFileOnHD ; + + for ( i = 0 ; i < NbFileOnHD ; i++, pt++ ) + { + if ( !strcmp( pt->NameHD, filename )) break ; + } + + strcpy( pt->NameHD, filename ) ;// Eventuelle recopie... + pt->SaveTimer = timer ; + pt->SizeFileHD = size ; + + if ( i == NbFileOnHD ) NbFileOnHD++ ;// Maj ou Add + + CalcTotalSizeFileOnHD() ;// Place prise +} +/*-------------------------------------------------------------------------*/ +void DeleteOlderFileHD() +{ + T_FILEONHD *pt, *pt1 ; + LONG i ; + ULONG min, num ; + + min = 0xFFFFFFFFL ;// le plus r‚cent, non? + + num = 0 ;// Suis oblig‚ dans trouv‚ un! + + pt = TabFileOnHD ; + + for ( i = 0 ; i < NbFileOnHD ; i++, pt++ ) + { + if ( pt->SaveTimer <= min ) + { + min = pt->SaveTimer ; + num = i ; + } + } + + pt-- ;// Stay on Last Entry + + pt1 = &TabFileOnHD[num] ; + + if ( FileSize( pt1->NameHD )) Delete( pt1->NameHD );// cf Del upper + + TotalSizeFileHD -= pt1->SizeFileHD ;// Maj TotalSizeFileHD + + strcpy( pt1->NameHD, pt->NameHD ) ;// Permut Current & Last + pt1->SaveTimer = pt->SaveTimer ; + NbFileOnHD-- ;// One less +} +/*-------------------------------------------------------------------------*/ +// Copy File CD On HD ( filename for CD must don't contain drive !!!) +LONG CopyFileCD_HD( char *filecd, char *filehd ) +{ + ULONG fd ; + LONG size, wr; + LONG i, sect ; + char fname[256]; + + + fname[0] = DriveCDR+'A' ; + fname[1] = ':' ; + fname[2] = 0 ; + strcat( fname, filecd ) ; + + fd = OpenRead( fname ) ; + if ( !fd ) return(0); + Close(fd) ; + + GetFileCDR( filecd ) ;// => FileCD_Start, FileCD_Sect & FileCD_Size + + size = GetHDFreeSize() ;// HD Free Space + + size -= (1024L*1024L) ;// 1 megas marge + + if ( FileCD_Size >= size ) return(0); + + fd = OpenWrite( filehd ) ; + if ( !fd ) return(0) ; +//------------------------------------------------ 64Ko fast copy :-) + sect = FileCD_Start+FileCD_Sect ; + size = FileCD_Size ; + + for ( i = FileCD_Start ; i <= sect-32 ; i += 32 ) + { + if (ReadLongCDR( i, 32, BufSpeak )) + { + Close(fd) ; + Delete( filehd ); + return(0) ; + } + wr = Write( fd, BufSpeak, 256L*256L ) ; + if ( wr != 256L*256L ) + { + Close(fd) ; + Delete( filehd ); + return(0) ; + } + size -= (256L*256L) ; + TimeBar( FileCD_Size, FileCD_Size-size ); + } +//------------------------------------------------ Copy left Bytes + sect -= i ; + + if ( sect ) + { + if (ReadLongCDR( i, sect, BufSpeak )) + { + Close(fd) ; + Delete( filehd ); + return(0) ; + } + wr = Write( fd, BufSpeak, size ) ; + if ( wr != size ) // Juste a la fin ! :-( + { + Close(fd) ; + Delete( filehd ); + return(0) ; + } + } + + TimeBar( FileCD_Size, FileCD_Size ); + Close(fd) ; + + return(1) ; +} +/*-------------------------------------------------------------------------*/ +LONG TryCopyFileCD_HD( char *filecd, char *filehd ) +{ + ULONG freesize ; + + freesize = GetHDFreeSize()-(1024L*1024L) ;// 1 Mega de marge + + if (!GetFileCDR( filecd )) return(0);// Ne doit Jamais Arriver! + + if ( freesize > FileCD_Size ) // Y a la place :-) + return( CopyFileCD_HD( filecd, filehd )) ; + +//------------------------------ Ok, y a pas la place for the moment :-( + + if ( !NbFileOnHD ) return(0) ;// Nothing to delete :-< + + if ( TotalSizeFileHD+freesize < FileCD_Size ) + return(0) ;// We can't do nothing :-[ + + while( freesize < FileCD_Size ) // Keep hope... ;-) + { + DeleteOlderFileHD() ; + freesize = GetHDFreeSize()-(1024L*1024L); + } + +//----------------------------- Ok, maintenant on a forc‚ment la place... + + return( CopyFileCD_HD( filecd, filehd )) ;// :-) +} +/*-------------------------------------------------------------------------*/ +void CloseFdNar() +{ + if ( FdNar )// Fichier ouvert CD ou HD, on doit le fermer + { + Close(FdNar) ; + FdNar = 0L ; + } +} +/*-------------------------------------------------------------------------*/ +void InitFileNar( char *file, LONG from ) +{ + ULONG offset, wr ; + + CloseFdNar() ; + + FlagVoiceCD = 0 ;//Je touche pas au CD pour le moment + + if (( from == FROM_CD ) AND ( GetMusicCD() != -1 )) + StopMusicCD() ; + + FdNar = OpenRead( file ) ;// CD or HD, it's working + // with FdNar, so... ;-) + if ( !FdNar ) return ; + + offset = 0 ; + + while(!offset) // Sans Filet + { + wr = Read( FdNar, &offset, 4L ) ; + } + + MaxVoice = (offset/4)-1 ;// Normalement en phase + // avec MaxText mais bon, + // en chantier... {:) --D (un ouvrier, je sais, il est nul celui la, d‚sol‚...) + Seek( FdNar, 0L, SEEK_START ) ; + + wr = Read( FdNar, BufMemoSeek, offset ) ; + if ( wr != offset ) + { + CloseFdNar() ; + return ; + } + + FlagVoiceCD = from ;// 0 si HD, 1 si CD (cf InitSpeak ) +} +/*-------------------------------------------------------------------------*/ +/*-------------------------------------------------------------------------*/ +void InitSpeak( LONG file ) +{ + LONG size ; + char filehd[256] ; + char filenar[256] ; + +// if ( DriveCDR < 0 ) return ;// a virer + + strcpy( filehd, PATH_NAR_HD ) ; + strcat( filehd, ListLanguage[LanguageCD] ); + strcat( filehd, ListFileText[file]) ; + AddExt( filehd, EXT_NAR) ; + + if ( size = FileSize( filehd )) // Already on HD + { + AddFileNameOnHD( filehd, size, ComputeTime() );// Maj Timer + Touch( filehd ) ; + InitFileNar( filehd, FROM_HD ) ; + return ; + } + + strcpy( filenar, PATH_NAR_CD ) ; + strcat( filenar, ListLanguage[LanguageCD] ); + strcat( filenar, ListFileText[file]) ; + AddExt( filenar, EXT_NAR) ; + + if ( GetMusicCD() != -1 ) StopMusicCD() ; + + if ( !TryCopyFileCD_HD( filenar, filehd ) ) + { + filehd[0] = DriveCDR+'A' ; + filehd[1] = ':' ; + filehd[2] = 0 ; + strcat( filehd, filenar ) ; + InitFileNar( filehd, FROM_CD ) ;// CD + } + else + { + AddFileNameOnHD( filehd, FileCD_Size, ComputeTime() );// FileCD_Size TryCopy... + InitFileNar( filehd, FROM_HD ) ;// HD + } +} +/*-------------------------------------------------------------------------*/ +void PlaySpeakVoc(LONG fd) +{ + LONG size ; + LONG sizelzss; + WORD method ; + ULONG volleft = 512 ; + ULONG volright = 512 ; + + + Read( fd, &size, 4L ) ; + Read( fd, &sizelzss, 4L ) ; + Read( fd, &method, 2L ) ; + + if ( method == 0 ) Read( fd, BufSpeak, size ) ; + else + { + CopyScreen( Screen, Log ) ; + Read( fd, Screen, sizelzss ) ;/* 256Ko ds Screen */ + Expand( Screen, BufSpeak, size ); + CopyScreen( Log, Screen ) ; + } + + FlagNextVoc = *BufSpeak ; +/* +#ifndef LORAN + if( NumObjSpeak != -1 ) + { + ProjettePoint( ListObjet[NumObjSpeak].PosObjX-WorldXCube, + ListObjet[NumObjSpeak].PosObjY-WorldYCube, + ListObjet[NumObjSpeak].PosObjZ-WorldZCube ) ; + + GiveBalance( Xp, Yp, 724, &volleft, &volright ) ; + } +#endif +*/ +// Loran, modif du 4/10/94 au cas ou SayMessage avant ( crac HP ) + if ( WaveInList(SPEAK_SAMPLE)) WaveStopOne(SPEAK_SAMPLE) ; + +#ifdef LORAN + WavePlay( SPEAK_SAMPLE, 0x1000, 1, 0, 1024, 1024, BufSpeak ) ; +#else + WavePlay( SPEAK_SAMPLE, 0x1000, 1, 0, volleft, volright, BufSpeak ) ; +#endif + + NumObjSpeak = -1 ; + + +} +/*-------------------------------------------------------------------------*/ +LONG TestSpk( LONG fd ) +{ + if ( !FlagSpeak ) return(0) ;// Le joueur ne veut pas + if ( !fd ) return(0) ;// Le programme ne peut pas + + if ( WaveInList( SPEAK_SAMPLE )) return(1) ;// ‡a joue... + + if ( FlagNextVoc ) // Ya une suite... + { + PlaySpeakVoc( fd ) ;// Scratch Screen + return(1) ;// Ca continue de jouer... + } + + return(0) ; // A plus, snif... :-( +} +/*-------------------------------------------------------------------------*/ +LONG TestSpeak() +{ + return(TestSpk( FdNar )); +} +/*-------------------------------------------------------------------------*/ +//#ifdef A_VOIR_SI_UTIL_STOP_MUSIC_BEFORE_PLAYING + +LONG TestSpeakFromCD() +{ + LONG ret ; + + if ( DriveCDR < 0 ) return(0) ; + + ret = TestSpk( FdCd ) ; + + if (( !ret ) AND ( FdCd )) + { + Close(FdCd) ; + FdCd = 0L ; + } + + return( ret ) ; +} +/*-------------------------------------------------------------------------*/ +void SpeakFromCD( LONG file, LONG text ) +{ + UWORD *pt ; + LONG num, offset ; + LONG max ; + char tmpname[256] ; + + if ( DriveCDR < 0 ) return ; + + strcpy( tmpname, PATH_TXT ) ;// Pas FileText! + strcat( tmpname, ListLanguage[LanguageCD] ) ; + strcat( tmpname, ListFileText[file]) ; + AddExt( tmpname, ".ord") ; + + +//-------------------------------------- + max = FileSize( tmpname )/2 ; + Load( tmpname, BufSpeak ) ;// Ne pas bousiller BufOrder! + + pt = (UWORD*)BufSpeak ; + + for ( num = 0 ; num < max ; num++ ) + { + if ( *pt++ == text ) + break ; + } + + if ( num == max ) return ; +//-------------------------------------- + + tmpname[0] = DriveCDR+'A' ; + tmpname[1] = ':' ; + tmpname[2] = 0 ; + strcat( tmpname, PATH_NAR_CD ) ; + strcat( tmpname, ListLanguage[LanguageCD] ) ; + strcat( tmpname, ListFileText[file]) ; + AddExt( tmpname, EXT_NAR) ; + + FdCd = OpenRead( tmpname ) ; + if ( !FdCd ) return ; + + Seek( FdCd, num*4L, SEEK_START ); + + Read( FdCd, &offset, 4L ) ; + + if ( !offset ) + { + Close(FdCd) ; + return ; + } + + Seek( FdCd, offset, SEEK_START ); + PlaySpeakVoc(FdCd) ; +} +/*-------------------------------------------------------------------------*/ +LONG IsVoiceFileOnHD( LONG island ) +{ + char filehd[_MAX_PATH] ; + + strcpy( filehd, PATH_NAR_HD ) ; + strcat( filehd, ListLanguage[LanguageCD] ) ; + strcat( filehd, ListFileText[island]) ; + AddExt( filehd, EXT_NAR) ; + + if ( FileSize( filehd )) return( 1L ) ; + + return(0L) ; +} +/*-------------------------------------------------------------------------*/ +LONG Speak( LONG text ) +{ + LONG num, offset ; + + if ( !FdNar ) return(0L) ; + + num = FindText( text ) ; + + if (( num == -1 ) + OR ( num >= MaxVoice )) return(0L) ;// Ne doit pas arriv‚, + // sauf en cours de dvp... + offset = BufMemoSeek[num] ; + + if ( !offset ) return(0L) ; + + Seek( FdNar, offset, SEEK_START ); + PlaySpeakVoc( FdNar ) ; + return(1L) ; +} +/*-------------------------------------------------------------------------*/ +void StopSpeak() +{ + FlagNextVoc = FALSE ;// Important, dans tout les cas ! + if ( !FlagSpeak ) return ; + if ( !FdNar ) return ; + if ( WaveInList(SPEAK_SAMPLE)) WaveStopOne(SPEAK_SAMPLE) ; +} +/*-------------------------------------------------------------------------*/ +#endif +#ifdef TITRE +/*-------------------------------------------------------------------------*/ + Ûßßßß ÛßßßÜ ÛßßßÛ ÛßßßÛ ÛÜ ÜÛ Ûßßßß ÛÛÜ Û ÛßßßÜ +// ÛÛ ÛÛ Û ÛÛßÛß ÛÛ Û ÛÛß Û ÛÛßß ÛÛßÛÛ ÛÛ Û + ßßßßß ßßßß ßß ß ßßßßß ßß ß ßßßßß ßß ß ßßßß +/*-------------------------------------------------------------------------*/ +#endif +/*-------------------------------------------------------------------------*/ +void InitDial( LONG file ) +{ + char *pt ; + LONG i, j, size ; + LONG offset0 ; + LONG offset1 ; + LONG code ; + + if ( LastFileInit == file ) return ; + LastFileInit = file ; + +#ifdef CRYPTAGE + strcpy( FileText, PATH_TXT ) ; + strcat( FileText, ListLanguage[Language] ) ; + strcat( FileText, ListFileText[file]) ; + AddExt( FileText, ".ord") ; + + MaxText = FileSize( FileText ) / 2 ;/* WORD */ + Load( FileText, BufOrder ) ; + AddExt( FileText, ".dia") ; + Load( FileText, BufText ) ; +//-------------------------- Decryptage + + for ( i = 0 ; i < MaxText ; i++ ) + { + offset0 = *(UWORD*)(BufText+(i+0)*2) ; + offset1 = *(UWORD*)(BufText+(i+1)*2) ; + + size = offset1 - offset0 ; + + code = INIT_CODE ; + + pt = BufText + offset0 ; + + for ( j = 0 ; j < size ; j++ ) + *pt++ ^= (code++) ; + } + +#else + strcpy( FileText, PATH_TXT ) ; + strcat( FileText, NAME_HQR_TEXT ) ; + + MaxText = Load_HQR( FileText, BufOrder, + ( Language*MAX_TEXT_LANG*2)+(file*2)+0)/2 ; + + Load_HQR( FileText, BufText, + ( Language*MAX_TEXT_LANG*2)+(file*2)+1) ; + + +#endif + +#ifdef CDROM + if ( FlagSpeak ) InitSpeak(file) ; +#endif +} +/*-------------------------------------------------------------------------*/ +/*-------------------------------------------------------------------------*/ +void ClearDial() +{ +} +/*-------------------------------------------------------------------------*/ +void GetNextWord(char *ptchaine, char *mot) +{ + char *dst ; + + dst = mot ; + LenWord = 0 ; + + while(( *ptchaine != 0 ) + AND ( *ptchaine != 1 ) + AND ( *ptchaine != ' ' )) + { + *dst++ = *ptchaine++ ; + LenWord++ ; + } + + *dst = 0 ; + SizeWord = SizeFont(mot) ; +} +/*-------------------------------------------------------------------------*/ +void PushCar( LONG x, LONG y, LONG c ) +{ + LONG i ; + + if ( NbCar < MAX_CAR ) + { + StackCar[NbCar].c = c ; + StackCar[NbCar].x = x ; + StackCar[NbCar].y = y ; + NbCar++ ; + } + else + { + for ( i = 0 ; i < MAX_CAR-1 ; i++ ) + { + StackCar[i].c = StackCar[i+1].c ; + StackCar[i].x = StackCar[i+1].x ; + StackCar[i].y = StackCar[i+1].y ; + } + StackCar[MAX_CAR-1].c = c ; + StackCar[MAX_CAR-1].x = x ; + StackCar[MAX_CAR-1].y = y ; + } + + +} +/*-------------------------------------------------------------------------*/ +void AffOneCar( LONG x, LONG y, LONG c, LONG coul ) +{ + LONG x0, y0, x1, y1 ; + + if ( c != 32 ) + { +#ifdef LBA_EDITOR + if ( !QuickMessage ) +#endif + { + CoulFont( 0 ) ; + CarFont( x+2, y+4, c ) ; + } + CoulFont( coul ) ; + CarFont( x, y, c ) ; + x0 = x ; + y0 = y ; + x1 = x+32 ; + y1 = y+38 ; + if ( x0 < Dial_X0+1 ) x0 = Dial_X0+1 ; + if ( y0 < Dial_Y0+1 ) y0 = Dial_Y0+1 ; + if ( x1 > Dial_X1-1 ) x1 = Dial_X1-1 ; + if ( y1 > Dial_Y1-1 ) y1 = Dial_Y1-1 ; + + CopyBlockPhys( x0, y0, x1, y1 ) ; + +// CopyBlockPhys( x, y, x+32, y+38 );// Loran le 20/09/94 + } +} +/*-------------------------------------------------------------------------*/ +void AffAllCar() +{ + T_STACKCAR *pt ; + LONG i, c, x, y ; + + + c = MaxDegrade ; + + pt = &StackCar[NbCar-1] ; + + x = pt->x ; + y = pt->y ; + +#ifdef LBA_EDITOR + if ( !QuickMessage ) +#endif + while( SaveTimerForCar == TimerRef ) ; + + SaveTimerForCar = TimerRef ; + + for ( i = NbCar-1 ; i >= 0 ; i--, pt-- ) + { + CoulFont( c ) ; + AffOneCar( pt->x, pt->y, pt->c, c ) ; + + if ( c-StepDegrade/* >= */ <= MinDegrade ) c -= StepDegrade ; + else c = MinDegrade ; + } +} +/*-------------------------------------------------------------------------*/ +void CoulDial( LONG min, LONG max, LONG step ) +{ + MinDegrade = min ; + MaxDegrade = max ; + StepDegrade = step ; + NbDegrade = (((MaxDegrade-MinDegrade)+1)/StepDegrade) ; +} + +void TestCoulDial( WORD coul ) +{ + MinDegrade = coul*16+12 ; // Loran + MaxDegrade = coul*16 ; + StepDegrade = -1 ; + NbDegrade = 14 ; // Loran +} +/*-------------------------------------------------------------------------*/ +LONG GetText( LONG text ) +{ + UWORD offset0 ; + UWORD offset1 ; + LONG num ; + + num = FindText( text ) ;/* Must have good number */ + if ( num == -1 ) return(0L); + + offset0 = *(UWORD*)(BufText+((num+0)*2L)); + offset1 = *(UWORD*)(BufText+((num+1)*2L)); + + PtText = BufText+offset0 ; + + SizeText = offset1-offset0 ; + + return(1L) ; +} +/*-------------------------------------------------------------------------*/ +void AffFleche() +{ + TabPoly[0] = MinDegrade ; + TabPoly[1] = Dial_X1 - 3 ; + TabPoly[2] = Dial_Y1 - 24 ; + + TabPoly[3] = MinDegrade ; + TabPoly[4] = Dial_X1 - 24 ; + TabPoly[5] = Dial_Y1 - 3 ; + + TabPoly[6] = MaxDegrade ; + TabPoly[7] = Dial_X1 - 3 ; + TabPoly[8] = Dial_Y1 - 3 ; + + TypePoly = 0 ; + NbPolyPoints = 3 ; + if( ComputePoly() ) + FillVertic( TypePoly, MinDegrade ) ; + + CopyBlockPhys( Dial_X1-24, Dial_Y1-24, Dial_X1-3, Dial_Y1-3 ) ; +} +/*-------------------------------------------------------------------------*/ +void InitDialWindow() +{ + CopyBlock( Dial_X0, Dial_Y0, Dial_X1, Dial_Y1, Screen, + Dial_X0, Dial_Y0, Log ) ; + + // Fred message shade on/off + if( FlagMessageShade ) + { + DrawCadre( Dial_X0, Dial_Y0, Dial_X1, Dial_Y1 ) ; + ShadeBox( Dial_X0+1, Dial_Y0+1, Dial_X1-1, Dial_Y1-1, 3 ) ; + } + CopyBlockPhys( Dial_X0, Dial_Y0, Dial_X1, Dial_Y1 ) ; + NbCar = 0 ; + CopyBlock( Dial_X0, Dial_Y0, Dial_X1, Dial_Y1, Log, + Dial_X0, Dial_Y0, Screen ) ; +// CopyScreen( Log, Screen ) ; +} +/*-------------------------------------------------------------------------*/ +void SecondInitDialWindow() +{ + CopyBlock( Dial_X0, Dial_Y0, Dial_X1, Dial_Y1, Screen, + Dial_X0, Dial_Y0, Log ) ; + + CopyBlockPhys( Dial_X0, Dial_Y0, Dial_X1, Dial_Y1 ) ; + NbCar = 0 ; +} +/*-------------------------------------------------------------------------*/ +void NormalWinDial() +{ + Dial_X0 = 16 ; + Dial_Y0 = 334 ; + Dial_X1 = 639-16; + Dial_Y1 = 479-16; + + MaxLineDial = 3 ; + DialMaxSize = ((Dial_X1-8)-(Dial_X0+8)) ; +} +/*-------------------------------------------------------------------------*/ +void BigWinDial() +{ + Dial_X0 = 8 ; + Dial_Y0 = 8 ; + Dial_X1 = 639-8 ; + Dial_Y1 = 479-8 ; + + MaxLineDial = 11 ; + DialMaxSize = ((Dial_X1-8)-(Dial_X0+8)) ; + +} +/*-------------------------------------------------------------------------*/ +/* +void DefWinDial( LONG x0, LONG y0, LONG x1, LONG y1 ) +{ + WORD yh, yb ; + WORD xl, xr ; + + Dial_X0 = x0 ; + Dial_Y0 = y0 ; + Dial_X1 = x1 ; + Dial_Y1 = y1 ; + + xl = Dial_X0+8 ; + xr = Dial_X1-8 ; + yh = Dial_Y0+8 ; + yb = Dial_Y1-40 ; + + DialMaxSize = ((Dial_X1-8)-(Dial_X0+8)) ; + MaxLineDial = (yb-yh)/36 ; +} +*/ +/*-------------------------------------------------------------------------*/ + +void CommonOpenDial( LONG text ) +{ + CloseDial() ; + if ( !GetText( text )) return ; + CurrentDial = text ; + X_Dial = Dial_X0+8 ; + Y_Dial = Dial_Y0+8 ; + NbLineDial = 0 ; + PtDial = PtText ; + *Word = 0 ; + PtWord = Word ; + *BufLine = 0 ; + PtLine = BufLine ; + NbCar = 0 ; + FlagEndDial = FALSE ; + FlagEnd3Line = FALSE ; + FlagRunningDial = TRUE ; + + SetFont( LbaFont, INTER_LEAVE, INTER_SPACE ) ; +} + +/*-------------------------------------------------------------------------*/ + +void OpenDial(LONG text) +{ + CommonOpenDial( text ) ; + + InitDialWindow() ; +#ifdef LBA_EDITOR + if ( QuickMessage ) + { + CoulText( JAUNE, -1 ) ; + Text( Dial_X0+2, Dial_Y0+2, "%FMess:%l ", text ) ; + } +#endif +} +/*-------------------------------------------------------------------------*/ +void OpenDialNoWindow(LONG text) +{ + CommonOpenDial( text ) ; +} +/*-------------------------------------------------------------------------*/ +void GetNextLine() +{ + LONG dx, dd ; + LONG flag ; + + SizeLine = 0 ; + NbSpace = 0 ; + *BufLine = 0 ; + SizeSpace = INTER_SPACE ; + flag = 1 ;// Justifie + + while(TRUE) + { + while( *PtDial == ' ' ) PtDial++; + if ( *PtDial == 0 ) break ; + GetNextWord( PtDial, Word ) ; + if ( SizeLine+SizeSpace+SizeWord > DialMaxSize ) break ; +//------------- Caractere Sp‚ciaux, saut de ligne, de page, etc. + if ( *PtDial == 1 ) + { + PtDial++ ; + flag = 0 ; + break ; + } + if ( *Word == '@' ) + { + flag = 0 ; + PtDial++ ; + if ( SizeLine == 0 )// Line Vide + { + strcpy( BufLine, " " ) ; + SizeLine = INTER_SPACE ; + } + if ( *(Word+1) == 'P' ) + { + NbLineDial = MaxLineDial; + PtDial++ ; + } + break ; + } +//------------- + PtDial += LenWord ; + strcat( BufLine, Word ) ; + strcat( BufLine, " " ) ; + SizeLine += (SizeWord+SizeSpace); + NbSpace++ ; + if ( *PtDial == 0 ) break ; + PtDial++ ; + } + + if ( NbSpace ) NbSpace-- ;// Ne doit jamais arrive :-] + + if (( *PtDial != 0 ) // Derniere Ligne ou Ligne seule + AND ( flag == 1 )) // Pas tout le temps, c'est a c... + { + dx = DialMaxSize-SizeLine ; + dd = dx/NbSpace ; + SizeSpace += dd ; + dd = NbSpace*dd ; + NbBigSpace = dx-dd ; + } + + LenLine = strlen(BufLine) ; + PtLine = BufLine ; +} +/*-------------------------------------------------------------------------*/ +void InitEndPage() +{ + LONG i ; + + *BufLine = 0 ; + for ( i = 0 ; i < NbDegrade ; i++ ) + strcat( BufLine, " ") ; + PtLine = BufLine ; + LenLine = NbDegrade ; + SizeLine = 16 ;// Bidon + NbLineDial = 0 ; +} +/*-------------------------------------------------------------------------*/ +LONG NextDialCar() +{ + LONG dx, dy ; + + if ( FlagRunningDial == FALSE ) return(0) ; + + if ( *PtLine == 0 ) + { + if ( FlagEndDial ) + { + if( FlecheForcee ) + { + AffFleche() ; + } + CloseDial() ; + FlagRunningDial = FALSE ; + return(0) ;// RETURN 0 + } + if ( FlagEnd3Line ) + { + SecondInitDialWindow() ; + FlagEnd3Line = FALSE ; + X_Dial = Dial_X0+8 ; + Y_Dial = Dial_Y0+8 ; + } + if ( *PtDial == 0 ) + { + InitEndPage() ; + FlagEndDial = TRUE ; + return(1) ;// RETURN 1 + } + + GetNextLine() ; + + } + + if ( *PtLine != 0 ) + { + PushCar( X_Dial, Y_Dial, *PtLine ) ; + AffAllCar() ; + GetDxDyMask( *PtLine, &dx, &dy, LbaFont ); + + if ( *PtLine != ' ' ) X_Dial += dx+INTER_LEAVE; + else + { + if ( NbBigSpace ) + { + NbBigSpace-- ; + X_Dial++ ; + } + X_Dial += SizeSpace ; + } + + PtLine++ ; + if ( *PtLine == 0 ) + { + X_Dial = Dial_X0+8 ; + Y_Dial += INTER_LINE ; + + if( ( FlagEnd3Line == TRUE ) + AND (!FlagEndDial) ) + { + AffFleche() ; + return(2) ;// RETURN 2 + } + + NbLineDial++ ; + if ( NbLineDial >= MaxLineDial ) + { + InitEndPage() ; + FlagEnd3Line = TRUE ; + if ( *PtDial == 0 ) + FlagEndDial = TRUE; + } + + } + } + + return(1) ; +} +/*-------------------------------------------------------------------------*/ +void CloseDial() +{ + FlagRunningDial = FALSE ; +} +#ifdef CDROM +/*-------------------------------------------------------------------------*/ +// D I A L C D R O M +/*-------------------------------------------------------------------------*/ +void Dial( LONG text ) +{ + LONG ret = 0 ; + LONG flagabort=0; + + + MemoClip() ; + UnSetClip() ; + + CopyScreen( Log, Screen ) ; + + if ( FlagSpeak ) + ret = Speak(text) ; + + if (( !FlagDisplayText ) // Pas de texte et Voix OK + AND ( ret )) + { + while((TestSpeak()) AND ( Key != K_ESC )) ; + StopSpeak() ; + RestoreClip() ; + return ; + } + + OpenDial( text ); + + while(TRUE) + { + ret = NextDialCar() ; + TestSpeak() ; + if ( ret == 2 ) /* Attente de Touche */ + { + while(( Key ) + OR ( Fire ) + OR ( Joy )) TestSpeak() ;// Tu relaches ? + + while(( !Key ) + AND ( !Fire ) + AND ( !Joy )) TestSpeak() ;// Tu appuies ? + } + + if ( Key == K_ESC )// Player Abort... + { + flagabort = 1 ; + break ; + } + + if ((( ret == 0 ) AND ( !TestSpeak()))// Tout fini + OR ( flagabort )) break ; // Ou Abort by player + } + + StopSpeak() ; + CloseDial() ; +#ifndef LORAN + if(( ret == 0 ) AND ( !flagabort )) + { + while(!(( !Key ) AND ( !Fire ) AND ( !Joy ))) ; + + while(( !Key ) AND ( !Fire ) AND ( !Joy )) ; + } +#endif +/* + if( FlagMessageShade ) + while( Key == K_ESC ) ; // attente relachement que pour escape + // essai: ET que si il y a un cadre (ouf ouf) +*/ + RestoreClip() ; +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +void MyDial( WORD nummess ) // attends une touche si autre page sinon continue +{ + WORD dialstat = 1 ; + + if ( FlagSpeak ) Speak(nummess) ; + + OpenDial( nummess ) ; + + while( dialstat ) + { + dialstat = NextDialCar(); + TestSpeak() ; + if( dialstat == 2 ) // encore 1 page + { + while( Key OR Fire OR Joy ) TestSpeak() ; + while( !Key AND !Fire AND !Joy ) TestSpeak() ; + } + } + + while(TestSpeak()) ;// Wait until silence + + StopSpeak() ;// Security + CloseDial() ; +} +#else +/*-------------------------------------------------------------------------*/ +// D I A L N O C D +/*-------------------------------------------------------------------------*/ +void Dial( LONG text ) +{ + LONG ret ; + + MemoClip() ; + UnSetClip() ; + + CopyScreen( Log, Screen ) ; + + OpenDial( text ); + + while(TRUE) + { + ret = NextDialCar() ; + if ( ret == 2 ) /* Attente de Touche */ + { + while(!(( !Key ) AND ( !Fire ) AND ( !Joy ))) ; + if ( Key == K_ESC ) break ; + while(( !Key ) AND ( !Fire ) AND ( !Joy )) ; + } + + if (( ret == 0 ) OR ( Key == K_ESC )) break ; + } + CloseDial() ; +#ifndef LORAN + if( ret == 0 ) + { + while(!(( !Key ) AND ( !Fire ) AND ( !Joy ))) ; + + while(( !Key ) AND ( !Fire ) AND ( !Joy )) ; + } +#endif +/* + if( FlagMessageShade ) + while( Key == K_ESC ) ; // attente relachement que pour escape + // essai: ET que si il y a un cadre (ouf ouf) +*/ + RestoreClip() ; +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void MyDial( WORD nummess ) // attends une touche si autre page sinon continue +{ + WORD dialstat = 1 ; + + OpenDial( nummess ) ; + + while( dialstat ) + { + dialstat = NextDialCar() ; + if( dialstat == 2 ) // encore 1 page + { + while( Key OR Fire OR Joy ) ; + while( !Key AND !Fire AND !Joy ) ; + } + } + + CloseDial() ; +} +#endif +/*-------------------------------------------------------------------------*/ +// attention size max ou tronqu‚e … 255 car + 0 +char *GetMultiText( LONG text, char *dst ) +{ + char *pts ; + char *ptd ; + LONG smax ; + + if( (text == NumMultiText ) AND (Island == IslandMultiText) ) + { + strcpy( dst, BufferMultiText ) ; + return dst ; + } + + if ( !GetText( text )) + { + *dst = 0 ; + return 0L ; + } + + pts = PtText ; + ptd = dst ; + + smax = SizeText-1 ; + + if( smax > 255 ) smax = 255 ; + + MovMem( PtText, dst, smax ) ; + dst[smax] = 0 ; + + MovMem( dst, BufferMultiText, smax+1 ) ; + NumMultiText = text ; + IslandMultiText = Island ; + + return(dst) ; +} +/*-------------------------------------------------------------------------*/ +#ifdef LBA_EDITOR +void CleanMessage( UBYTE *string, LONG flag ) +{ + CopyScreen( Log, Screen ) ; + Message( string, flag ) ; + CopyScreen( Screen, Log ) ; + Flip() ; +} +#endif +/*-------------------------------------------------------------------------*/ +/*-------------------------------------------------------------------------*/ + + + + + + diff --git a/SOURCES/MESSAGE.DEF b/SOURCES/MESSAGE.DEF new file mode 100644 index 0000000..ba4ffa4 --- /dev/null +++ b/SOURCES/MESSAGE.DEF @@ -0,0 +1,27 @@ +extern void TimeBar(unsigned long ,unsigned long ); +extern void InitLanguage(void); +extern long FindText(long ); +extern void InitDial(long ); +extern void ClearDial(void); +extern void GetNextWord(char *,char *); +extern void PushCar(long ,long ,long ); +extern void AffOneCar(long ,long ,long ,long ); +extern void AffAllCar(void); +extern void CoulDial(long ,long ,long ); +extern void TestCoulDial(short ); +extern long GetText(long ); +extern void AffFleche(void); +extern void InitDialWindow(void); +extern void SecondInitDialWindow(void); +extern void NormalWinDial(void); +extern void BigWinDial(void); +extern void CommonOpenDial(long ); +extern void OpenDial(long ); +extern void OpenDialNoWindow(long ); +extern void GetNextLine(void); +extern void InitEndPage(void); +extern long NextDialCar(void); +extern void CloseDial(void); +extern void Dial(long ); +extern void MyDial(short ); +extern char *GetMultiText(long ,char *); diff --git a/SOURCES/MIXER.C b/SOURCES/MIXER.C new file mode 100644 index 0000000..0422cb6 --- /dev/null +++ b/SOURCES/MIXER.C @@ -0,0 +1,50 @@ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ* + SAMP.C 386 + (c) Adeline 1993 + *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#include "\projet\lib386\lib_sys\adeline.h" +#include "\projet\lib386\lib_sys\lib_sys.h" +#include "\projet\lib386\lib_mix\lib_mix.h" +#include +#include +#include +#include + +char *MixerError = "Error MixerDriver:"; + +extern void *Mixer_listfcts; +extern LONG Mixer_Driver_Enable; + +/*-------------------------------------------------------------------------*/ +LONG MixerInitDLL(char *driverpathname) +{ + char *dll, *drvr; + + // + // Load driver file + // + + dll = FILE_read( driverpathname, NULL); + if (dll==NULL) + { + printf("%s Could not load driver '%s'.\n", MixerError, driverpathname ); + return FALSE ; + } + + drvr=DLL_load(dll,DLLMEM_ALLOC | DLLSRC_MEM,NULL); + if (drvr==NULL) + { + printf("%s Invalid DLL image.\n", MixerError ); + return FALSE ; + } + + Free(dll); + + Mixer_listfcts = *(void **)drvr; + printf("%s", drvr+4); + + return (Mixer_Driver_Enable = TRUE); +} + +/*-------------------------------------------------------------------------*/ diff --git a/SOURCES/MIXER.DEF b/SOURCES/MIXER.DEF new file mode 100644 index 0000000..a91c30d --- /dev/null +++ b/SOURCES/MIXER.DEF @@ -0,0 +1 @@ +extern long MixerInitDLL(char *); diff --git a/SOURCES/OBJECT.C b/SOURCES/OBJECT.C new file mode 100644 index 0000000..3382e23 --- /dev/null +++ b/SOURCES/OBJECT.C @@ -0,0 +1,3444 @@ +#include "c_extern.h" + +/* +WORD GiveMaxLevel( WORD x, WORD y ) ; +void DrawOverBrick( WORD xm, WORD ym, WORD zm ) ; +void DrawOverBrick2( WORD xm, WORD ym, WORD zm ) ; +*/ +UBYTE WorldColBrick( WORD xw, WORD yw, WORD zw ) ; + +WORD Nxw, Nyw, Nzw ; +WORD SaveNxw, SaveNyw, SaveNzw ; +WORD OldX, OldY, OldZ ; +WORD AnimNumObj ; +T_OBJET *APtObj ; + +WORD LastJoyFlag = FALSE ; +WORD LastMyJoy = 0 ; +WORD LastMyFire = 0 ; + +WORD Col1 ; + +void IncrustGrm( WORD numgrm ) ; + +WORD ZoneGrm = -1 ; +WORD IndexGrm = -1 ; + +WORD BetaUsedObj = 0 ; + +extern LONG XMap, YMap, ZMap ; +extern WORD M_Xmin, M_Xmax, M_Ymin, M_Ymax, M_Zmin, M_Zmax ; +extern UBYTE *SearchPtrAnimAction ; + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßßÛ ÛßßÛ Û Ûßßßß Ûßßßß ßßÛßß ÛÛßßß + ÛÛ Û ÛÛßßÛ ÜÜ Û ÛÛßß ÛÛ ÛÛ ßßßßÛ + ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +extern UBYTE *PtrScene ; + +void InitObject( WORD numobj ) +{ + T_OBJET *ptrobj ; + UBYTE *ptr ; + + ptrobj = &ListObjet[numobj] ; + + ptrobj->GenBody = GEN_BODY_NORMAL ; + ptrobj->GenAnim = GEN_ANIM_RIEN ; + + ptrobj->PosObjX = 0 ; + ptrobj->PosObjY = SIZE_BRICK_Y ; + ptrobj->PosObjZ = 0 ; + + ptrobj->Xmin = 0 ; + ptrobj->Xmax = 0 ; + ptrobj->Ymin = 0 ; + ptrobj->Ymax = 0 ; + ptrobj->Zmin = 0 ; + ptrobj->Zmax = 0 ; + + ptrobj->Beta = 0 ; + + ptrobj->SRot = 40 ; + ptrobj->Move = NO_MOVE ; + ptrobj->Info = 0 ; + ptrobj->Info1 = 0 ; + ptrobj->Info2 = 0 ; + ptrobj->Info3 = 0 ; + + ptrobj->Col = 0 ; + ptrobj->ObjCol = -1 ; + ptrobj->CarryBy = -1 ; + + ptrobj->ZoneSce = -1 ; + + ptrobj->Flags = 0 ; + ptrobj->WorkFlags = 0 ; + + ptrobj->LifePoint = 50 ; + ptrobj->Armure = 1 ; + ptrobj->HitBy = -1 ; + + ptrobj->AnimStepBeta = 0 ; + + ptrobj->AnimStepX = 0 ; + ptrobj->AnimStepY = 0 ; + ptrobj->AnimStepZ = 0 ; + +// ptrobj->GenBody = NO_BODY ; +// ptrobj->GenAnim = NO_ANIM ; + ptrobj->Body = -1 ; + ptrobj->Anim = -1 ; + ptrobj->FlagAnim = 0 ; + ptrobj->Frame = 0 ; + + InitRealAngle( 0,0, 0, &ptrobj->RealAngle ) ; + + ptrobj->OffsetTrack = -1 ; + ptrobj->OffsetLife = 0 ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void StartInitObj( WORD numobj ) +{ + T_OBJET *ptrobj ; + WORD m ; + + ptrobj = &ListObjet[numobj] ; + + if( ptrobj->Flags & SPRITE_3D ) + { + if( ptrobj->HitForce != 0 ) + ptrobj->WorkFlags |= OK_HIT ; + + ptrobj->Body = -1 ; + InitSprite( ptrobj->Sprite, numobj ) ; + + InitRealAngle( 0,0,0, &ptrobj->RealAngle ) ; + + if( ptrobj->Flags & SPRITE_CLIP ) + { + ptrobj->AnimStepX = ptrobj->PosObjX ; + ptrobj->AnimStepY = ptrobj->PosObjY ; + ptrobj->AnimStepZ = ptrobj->PosObjZ ; + } + } + else + { + ptrobj->Body = -1 ; + InitBody( ptrobj->GenBody, numobj ) ; + + ptrobj->Anim = -1 ; + ptrobj->FlagAnim = 0 ; + if( ptrobj->Body != -1 ) + { + InitAnim( ptrobj->GenAnim, ANIM_REPEAT, NO_ANIM, numobj ) ; + } + + InitRealAngle( ptrobj->Beta, + ptrobj->Beta, + 0, &ptrobj->RealAngle ) ; + } + + ptrobj->OffsetTrack = -1 ; + ptrobj->LabelTrack = -1 ; + ptrobj->OffsetLife = 0 ; +} + + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void StartInitAllObjs() +{ + WORD n ; + + for( n=1; nPtrFile3D = PtrFile3dSportif ; + AnimRienSportif = SearchAnim( GEN_ANIM_RIEN, NUM_PERSO ) ; + + HQRM_Load( PATH_RESSOURCE"FILE3D.HQR",FILE_3D_AGRESSIF, &PtrFile3dAgressif ) ; + CHECK_MEMORY + ptrobj->PtrFile3D = PtrFile3dAgressif ; + AnimRienAgressif = SearchAnim( GEN_ANIM_RIEN, NUM_PERSO ) ; + + HQRM_Load( PATH_RESSOURCE"FILE3D.HQR",FILE_3D_DISCRET, &PtrFile3dDiscret ) ; + CHECK_MEMORY + ptrobj->PtrFile3D = PtrFile3dDiscret ; + AnimRienDiscret = SearchAnim( GEN_ANIM_RIEN, NUM_PERSO ) ; + + HQRM_Load( PATH_RESSOURCE"FILE3D.HQR",FILE_3D_PROTOPACK, &PtrFile3dProtopack ) ; + CHECK_MEMORY + ptrobj->PtrFile3D = PtrFile3dProtopack ; + AnimRienProtopack = SearchAnim( GEN_ANIM_RIEN, NUM_PERSO ) ; + + HQRM_Load( PATH_RESSOURCE"FILE3D.HQR",FILE_3D_NORMAL, &PtrFile3dNormal ) ; + CHECK_MEMORY + ptrobj->PtrFile3D = PtrFile3dNormal ; + AnimRienNormal = SearchAnim( GEN_ANIM_RIEN, NUM_PERSO ) ; + + ptrobj->PtrAnimAction = SearchPtrAnimAction ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void InitPerso() +{ + T_OBJET *ptrobj ; + + InitObject( NUM_PERSO ) ; + + ptrobj = &ListObjet[NUM_PERSO] ; + + ptrobj->GenBody = GEN_BODY_NORMAL ; + + ptrobj->LifePoint = 50 ; + + ptrobj->CoulObj = 4 ; /* bleu twinkel */ + + NbGoldPieces = 0 ; + NbLittleKeys = 0 ; + MagicPoint = 0 ; + MagicBall = -1 ; + NbCloverBox = 2 ; + NbFourLeafClover = 2 ; + Weapon = 0 ; +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void SetComportement( WORD comportement ) +{ + T_OBJET *ptrobj ; + WORD memogenbody ; + + ptrobj = &ListObjet[ NUM_PERSO ] ; + + switch( comportement ) + { + case C_NORMAL: + Comportement = C_NORMAL ; + ptrobj->PtrFile3D = PtrFile3dNormal ; + break ; + + case C_SPORTIF: + Comportement = C_SPORTIF ; + ptrobj->PtrFile3D = PtrFile3dSportif ; + break ; + + case C_AGRESSIF: + Comportement = C_AGRESSIF ; + ptrobj->PtrFile3D = PtrFile3dAgressif ; + break ; + + case C_DISCRET: + Comportement = C_DISCRET ; + ptrobj->PtrFile3D = PtrFile3dDiscret ; + break ; + + case C_PROTOPACK: + Comportement = C_PROTOPACK ; + ptrobj->PtrFile3D = PtrFile3dProtopack ; + break ; + } + + memogenbody = ptrobj->GenBody ; + ptrobj->GenBody = NO_BODY ; + ptrobj->Body = -1 ; + InitBody( memogenbody, NUM_PERSO ) ; + + ptrobj->GenAnim = NO_ANIM ; + ptrobj->FlagAnim = 0 ; + InitAnim( GEN_ANIM_RIEN, ANIM_REPEAT, NO_ANIM, NUM_PERSO ) ; +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +// reinitialise tout perso sans toucher … sa position + +void RestartPerso() +{ + T_OBJET *ptrobj ; + UBYTE memogenbody ; + + ptrobj = &ListObjet[NUM_PERSO] ; + + ptrobj->Move = MOVE_MANUAL ; + + ptrobj->WorkFlags = 0 ; + ptrobj->Flags = OBJ_FALLABLE + + CHECK_ZONE + + CHECK_OBJ_COL + + CHECK_BRICK_COL + + CHECK_CODE_JEU ; + + ptrobj->Armure = 1 ; + + ptrobj->OffsetTrack = -1 ; + ptrobj->LabelTrack = -1 ; + ptrobj->OffsetLife = 0 ; + ptrobj->ZoneSce = -1 ; + +ptrobj->Beta = SaveBeta ; + + InitRealAngle( ptrobj->Beta, + ptrobj->Beta, + 0, &ptrobj->RealAngle ) ; + +SetComportement( SaveComportement ) ; +// SetComportement( Comportement ) ; + + FlagWater = FALSE ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* Call Every Change Cube */ + +void ClearFlagsCube() +{ + WORD n ; + + for( n=0; nLifePoint <= 0 ) return ; + + ptrobjt->HitBy = numhitter ; + + if( ptrobjt->Armure <= hitforce ) + { + if((ptrobjt->GenAnim == GEN_ANIM_CHOC) + OR (ptrobjt->GenAnim == GEN_ANIM_CHOC2) ) + { + memo = ptrobjt->Frame ; + ptrobjt->Frame = 1 ; + GereAnimAction( ptrobjt, num ) ; + ptrobjt->Frame = memo ; + } + else + { + if( beta != -1 ) + InitRealAngle( beta,beta, 0, &ptrobjt->RealAngle ) ; + + if( !(rand()&1) ) + InitAnim( GEN_ANIM_CHOC, ANIM_INSERT, NO_ANIM, num ) ; + else + InitAnim( GEN_ANIM_CHOC2, ANIM_INSERT, NO_ANIM, num ) ; + } + + /* effet special choc */ + /* etoile */ + InitSpecial( ptrobjt->PosObjX, + ptrobjt->PosObjY+1000, + ptrobjt->PosObjZ, + 0 ) ; + + if( num == NUM_PERSO ) + { + LastJoyFlag = TRUE ; + } + + ptrobjt->LifePoint -= hitforce ; + + /* attention dans l'outil LifePoint est un word + si ca devient un UBYTE pas de signe */ +// if( ptrobjt->LifePoint > 127 ) ptrobjt->LifePoint = 0 ; + if( ptrobjt->LifePoint < 0 ) ptrobjt->LifePoint = 0 ; + } + else + { + InitAnim( GEN_ANIM_ENCAISSE, ANIM_INSERT, NO_ANIM, num ) ; + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +LONG CheckZvOnZv( WORD numobj, WORD numobjt ) +{ + T_OBJET *ptrobj ; + T_OBJET *ptrobjt ; + WORD x0,y0,z0, x1,y1,z1 ; + WORD xt0,yt0,zt0, xt1,yt1,zt1 ; + + ptrobj = &ListObjet[numobj] ; + + x0 = Nxw + ptrobj->Xmin ; + x1 = Nxw + ptrobj->Xmax ; + y0 = Nyw + ptrobj->Ymin ; + y1 = Nyw + ptrobj->Ymax ; + z0 = Nzw + ptrobj->Zmin ; + z1 = Nzw + ptrobj->Zmax ; + + ptrobjt = &ListObjet[numobjt] ; + + xt0 = ptrobjt->PosObjX + ptrobjt->Xmin ; + xt1 = ptrobjt->PosObjX + ptrobjt->Xmax ; + yt0 = ptrobjt->PosObjY + ptrobjt->Ymin ; + yt1 = ptrobjt->PosObjY + ptrobjt->Ymax ; + zt0 = ptrobjt->PosObjZ + ptrobjt->Zmin ; + zt1 = ptrobjt->PosObjZ + ptrobjt->Zmax ; + + if( x0 < xt1 + AND x1 > xt0 + AND y0 <= (yt1+1) + AND y0 > (yt1 - SIZE_BRICK_Y) + AND y1 > yt0 + AND z0 < zt1 + AND z1 > zt0 ) + { + return TRUE ; + } + + return FALSE ; +} +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +WORD CheckObjCol( WORD numobj ) +{ + WORD n, angle ; + T_OBJET *ptrobj ; + T_OBJET *ptrobjt ; + WORD x0,y0,z0, x1,y1,z1 ; + WORD xt0,yt0,zt0, xt1,yt1,zt1 ; + + ptrobj = &ListObjet[numobj] ; + + x0 = Nxw + ptrobj->Xmin ; + x1 = Nxw + ptrobj->Xmax ; + y0 = Nyw + ptrobj->Ymin ; + y1 = Nyw + ptrobj->Ymax ; + z0 = Nzw + ptrobj->Zmin ; + z1 = Nzw + ptrobj->Zmax ; + + ptrobjt = ListObjet ; + + ptrobj->ObjCol = -1 ; + + for( n=0; nBody != -1) + AND (!(ptrobj->Flags&INVISIBLE)) + AND (ptrobjt->CarryBy != numobj) ) + { + + xt0 = ptrobjt->PosObjX + ptrobjt->Xmin ; + xt1 = ptrobjt->PosObjX + ptrobjt->Xmax ; + yt0 = ptrobjt->PosObjY + ptrobjt->Ymin ; + yt1 = ptrobjt->PosObjY + ptrobjt->Ymax ; + zt0 = ptrobjt->PosObjZ + ptrobjt->Zmin ; + zt1 = ptrobjt->PosObjZ + ptrobjt->Zmax ; + + if( x0 < xt1 + AND x1 > xt0 + AND y0 < yt1 + AND y1 > yt0 + AND z0 < zt1 + AND z1 > zt0 ) + { + ptrobj->ObjCol = n ; + + if( ptrobjt->Flags & OBJ_CARRIER ) + { + // je touche un transporteur + if( ptrobj->WorkFlags & FALLING ) + { + Nyw = yt1 - ptrobj->Ymin + 1 ; + ptrobj->CarryBy = n ; + continue ; + } + else + { + if( CheckZvOnZv( numobj, n ) ) + { + // je marche sur un transporteur */ + Nyw = yt1 - ptrobj->Ymin + 1 ; + ptrobj->CarryBy = n ; + continue ; + } + } + } + else + { // je marche sur quelqu'un + if( CheckZvOnZv( numobj, n ) ) + { + HitObj( numobj, n, 1, -1 ) ; + } + } + + angle = GetAngle( Nxw,Nzw, + ptrobjt->PosObjX,ptrobjt->PosObjZ ) ; + + // test obj pushable + if( (ptrobjt->Flags & PUSHABLE) + AND !(ptrobj->Flags & PUSHABLE) ) // protect reaction en chaine + { +/* if( numobj == NUM_PERSO ) + { + InitAnim( "pousse", ANIM_REPEAT, 0, NUM_PERSO ) ; + } +*/ + ptrobjt->AnimStepY = 0 ; + + if( ptrobjt->Flags & MINI_ZV ) + { // magouille boxxle + if( angle >= 128 AND angle < 384 ) + if( ptrobj->Beta >= 128 AND ptrobj->Beta < 384 ) + ptrobjt->AnimStepX = SIZE_BRICK_XZ/4 + SIZE_BRICK_XZ/8 ; + if( angle >= 384 AND angle < 640 ) + if( ptrobj->Beta >= 384 AND ptrobj->Beta < 640 ) + ptrobjt->AnimStepZ = -SIZE_BRICK_XZ/4 + SIZE_BRICK_XZ/8 ; + if( angle >= 640 AND angle < 896 ) + if( ptrobj->Beta >= 640 AND ptrobj->Beta < 896 ) + ptrobjt->AnimStepX = -SIZE_BRICK_XZ/4 + SIZE_BRICK_XZ/8 ; + if( angle >= 896 OR angle < 128 ) + if( ptrobj->Beta >= 896 OR ptrobj->Beta < 128 ) + ptrobjt->AnimStepZ = SIZE_BRICK_XZ/4 + SIZE_BRICK_XZ/8 ; + } + else + { // induit deplacement avant reajustement ? + + ptrobjt->AnimStepX = Nxw - ptrobj->OldPosX ; + ptrobjt->AnimStepZ = Nzw - ptrobj->OldPosZ ; + } + } + + // joli mais ne fonctionne qu'avec + // des ZV carres + + // donc rustine tempo +// if( ptrobjt->Xmax-ptrobjt->Xmin == +// ptrobjt->Zmax-ptrobjt->Zmin ) + if( (ptrobjt->Xmax-ptrobjt->Xmin == + ptrobjt->Zmax-ptrobjt->Zmin ) + AND + (ptrobj->Xmax-ptrobj->Xmin == + ptrobj->Zmax-ptrobj->Zmin) ) + { // si ZV carre + + + if( angle >= 128 AND angle < 384 ) + Nxw = xt0 - ptrobj->Xmax ; + if( angle >= 384 AND angle < 640 ) + Nzw = zt1 - ptrobj->Zmin ; + if( angle >= 640 AND angle < 896 ) + Nxw = xt1 - ptrobj->Xmin ; + if( angle >= 896 OR angle < 128 ) + Nzw = zt0 - ptrobj->Zmax ; + } + else + { + if( !(ptrobj->WorkFlags & FALLING) ) // gloups + { + // refuse pos + Nxw = OldX ; + Nyw = OldY ; + Nzw = OldZ ; + } + } + } + } + } + + // test deplace la ZV plus en avant si frappe + + if( ptrobj->WorkFlags & OK_HIT ) + { + Rotate( 0, 200, ptrobj->Beta ) ; + + x0 = Nxw + ptrobj->Xmin + X0 ; + x1 = Nxw + ptrobj->Xmax + X0 ; + y0 = Nyw + ptrobj->Ymin ; + y1 = Nyw + ptrobj->Ymax ; + z0 = Nzw + ptrobj->Zmin + Y0 ; + z1 = Nzw + ptrobj->Zmax + Y0 ; + + ptrobjt = ListObjet ; + + for( n=0; nBody != -1) + AND (!(ptrobj->Flags&INVISIBLE)) + AND (ptrobjt->CarryBy != numobj) ) + { + xt0 = ptrobjt->PosObjX + ptrobjt->Xmin ; + xt1 = ptrobjt->PosObjX + ptrobjt->Xmax ; + yt0 = ptrobjt->PosObjY + ptrobjt->Ymin ; + yt1 = ptrobjt->PosObjY + ptrobjt->Ymax ; + zt0 = ptrobjt->PosObjZ + ptrobjt->Zmin ; + zt1 = ptrobjt->PosObjZ + ptrobjt->Zmax ; + + if( x0 < xt1 + AND x1 > xt0 + AND y0 < yt1 + AND y1 > yt0 + AND z0 < zt1 + AND z1 > zt0 ) + { + HitObj( numobj, n, ptrobj->HitForce, ptrobj->Beta+512 ) ; + ptrobj->WorkFlags &= ~OK_HIT ; + } + } + } + } + return ptrobj->ObjCol ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void CheckCarrier( WORD numobj ) +{ + WORD n ; + + if( ListObjet[numobj].Flags & OBJ_CARRIER ) + { + for( n=0; nPosObjX + ptrobj->Xmin ; + x1 = ptrobj->PosObjX + ptrobj->Xmax ; + y0 = ptrobj->PosObjY + ptrobj->Ymin ; + y1 = ptrobj->PosObjY + ptrobj->Ymax ; + z0 = ptrobj->PosObjZ + ptrobj->Zmin ; + z1 = ptrobj->PosObjZ + ptrobj->Zmax ; + + if( (x0<0) OR (x0>SIZE_BRICK_XZ*63) ) return FALSE ; + if( (x1<0) OR (x1>SIZE_BRICK_XZ*63) ) return FALSE ; + if( (z0<0) OR (z0>SIZE_BRICK_XZ*63) ) return FALSE ; + if( (z1<0) OR (z1>SIZE_BRICK_XZ*63) ) return FALSE ; + + // test decors + + if( WorldColBrickFull( x0, y0, z0, ptrobj->Ymax ) ) return FALSE ; + if( WorldColBrickFull( x1, y0, z0, ptrobj->Ymax ) ) return FALSE ; + if( WorldColBrickFull( x1, y0, z1, ptrobj->Ymax ) ) return FALSE ; + if( WorldColBrickFull( x0, y0, z1, ptrobj->Ymax ) ) return FALSE ; + + // test liste des objets + + ptrobjt = ListObjet ; + for( n=0; nBody != -1) + AND (!(ptrobj->Flags&INVISIBLE)) + AND (ptrobjt->CarryBy != numobj) ) + { + xt0 = ptrobjt->PosObjX + ptrobjt->Xmin ; + xt1 = ptrobjt->PosObjX + ptrobjt->Xmax ; + yt0 = ptrobjt->PosObjY + ptrobjt->Ymin ; + yt1 = ptrobjt->PosObjY + ptrobjt->Ymax ; + zt0 = ptrobjt->PosObjZ + ptrobjt->Zmin ; + zt1 = ptrobjt->PosObjZ + ptrobjt->Zmax ; + + if( x0 < xt1 + AND x1 > xt0 + AND y0 < yt1 + AND y1 > yt0 + AND z0 < zt1 + AND z1 > zt0 ) + { // collision pos refus‚e + return FALSE ; + } + } + } + return TRUE ; +} + + + + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßÛ ÛßßßÛ ÛßßßÜ Û Üß + ÛÛßßÛ ÛÛ Û ÛÛ Û ÛÛß + ßßßßß ßßßßß ßßßß ßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void InitBody( UBYTE gennewbody, + WORD numobj ) +{ + WORD newbody ; + WORD oldbody ; + T_OBJET *ptrobj ; + WORD *ptr ; + WORD size ; + WORD x0,x1,z0,z1 ; + UBYTE *ptr3do ; + + ptrobj = &ListObjet[numobj] ; + + if( ptrobj->Flags & SPRITE_3D ) return ; + + + // grosse rustine anti boom okazou + if( numobj == NUM_PERSO ) + { + if( Comportement == C_PROTOPACK ) + { + if( (gennewbody != GEN_BODY_NORMAL) + AND (gennewbody != GEN_BODY_TUNIQUE) ) + { + SetComportement( C_NORMAL ) ; + } + } + } + +// if( gennewbody == ptrobj->GenBody ) return ; + + if( gennewbody != NO_BODY ) + { + newbody = SearchBody( gennewbody, numobj ) ; + } + else + { + newbody = -1 ; + } + + if( newbody != -1 ) + { + if( newbody != ptrobj->Body ) + { + oldbody = ptrobj->Body ; + ptrobj->Body = newbody ; + ptrobj->GenBody = gennewbody ; + + if( M_Xmin == -32000 ) + { + ptr = (WORD*)(PtrBody[ptrobj->Body] + 2) ; + + x0 = *ptr++ ; + x1 = *ptr++ ; + ptrobj->Ymin = *ptr++ ; + ptrobj->Ymax = *ptr++ ; + z0 = *ptr++ ; + z1 = *ptr++ ; + + if( ptrobj->Flags & MINI_ZV ) + { + // plus petit + if( x1 - x0 < z1 - z0 ) + size = (x1 - x0) / 2 ; + else + size = (z1 - z0) / 2 ; + } + else + { + // moyenne + size = ((x1 - x0) + (z1 - z0)) / 4 ; + } + + ptrobj->Xmin = -size ; + ptrobj->Xmax = +size ; + ptrobj->Zmin = -size ; + ptrobj->Zmax = +size ; + } + else + { + ptrobj->Xmin = M_Xmin ; + ptrobj->Xmax = M_Xmax ; + ptrobj->Ymin = M_Ymin ; + ptrobj->Ymax = M_Ymax ; + ptrobj->Zmin = M_Zmin ; + ptrobj->Zmax = M_Zmax ; + } + + if( (oldbody != -1) AND (ptrobj->Anim != -1) ) + { + CopyInterAnim( PtrBody[oldbody], PtrBody[ptrobj->Body] ) ; + } + } + } + else + { + + ptrobj->GenBody = NO_BODY ; + ptrobj->Body = -1 ; + + ptrobj->Ymin = 0 ; + ptrobj->Ymax = 0 ; + ptrobj->Xmin = 0 ; + ptrobj->Xmax = 0 ; + ptrobj->Zmin = 0 ; + ptrobj->Zmax = 0 ; + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void InitSprite( WORD newsprite, + WORD numobj ) +{ + T_OBJET *ptrobj ; + WORD *ptr ; + + ptrobj = &ListObjet[numobj] ; + + if( !(ptrobj->Flags & SPRITE_3D) ) return ; + + if( newsprite != -1 AND newsprite != ptrobj->Body ) + { + ptrobj->Body = newsprite ; + + ptr = &PtrZvExtra[ newsprite*8 + 2 ] ; + + ptrobj->Xmin = *ptr++ ; + ptrobj->Xmax = *ptr++ ; + ptrobj->Ymin = *ptr++ ; + ptrobj->Ymax = *ptr++ ; + ptrobj->Zmin = *ptr++ ; + ptrobj->Zmax = *ptr++ ; + } +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßßÛ ÛÛÜ Û Û ÛÜ ÜÛ ÛÛßßß + ÛÛßßÛ ÛÛßÛÛ ÛÛ ÛÛß Û ßßßßÛ + ßß ß ßß ß ßß ßß ß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +WORD InitAnim( UBYTE gennewanim, + WORD flag, + UBYTE gennextanim, + WORD numobj ) +{ + WORD newanim, nextanim ; + T_OBJET *ptrobj ; + UBYTE tempstringnext[256] ; + + ptrobj = &ListObjet[numobj] ; + +/* +if( numobj == 11 ) +{ + CoulText( 15,0 ) ; + Text( 40,40, "%Fanim %d sur 11", gennewanim ) ; +} +if( numobj == 5 ) +{ + CoulText( 15,0 ) ; + Text( 40,100, "%Fanim %d sur 5", gennewanim ) ; + + if( gennewanim != 0 ) + { + Text( 70,100, "%Fexplose" ) ; + } +} + +*/ + // debug protect + if( ptrobj->Body == -1 ) + { +#ifdef DEBUG_TOOLS + Message( "Anim sur un objet avec Body = -1 !", TRUE ) ; +#endif + return FALSE ; + } + if( ptrobj->Flags & SPRITE_3D ) return FALSE ; // -1 ; + + if( (gennewanim == ptrobj->GenAnim) + AND (ptrobj->Anim != -1) +// AND (newanim == ptrobj->Anim) +// AND (flag == ptrobj->FlagAnim) + ) return TRUE ; + + if( gennextanim == NO_ANIM ) + { + if( ptrobj->FlagAnim != ANIM_ALL_THEN ) + { + gennextanim = ptrobj->GenAnim ; + } + } + + newanim = SearchAnim( gennewanim, numobj ) ; + if( newanim == -1 ) + { + newanim = SearchAnim( GEN_ANIM_RIEN, numobj ) ; + } + + if( flag != ANIM_SET ) + { + if( ptrobj->FlagAnim == ANIM_ALL_THEN ) + { + ptrobj->NextGenAnim = gennewanim ; + return FALSE ; + } + } + +/*if( numobj==2 ) +{ +CoulText( 15, 0 ) ; +Text( 10,100, "%FInitAnim GenAnim:%d Anim:%d ", gennewanim, newanim ) ; +}*/ + + +// if( (newanim != ptrobj->Anim) OR (flag != ptrobj->FlagAnim) ) + { + if( flag == ANIM_INSERT ) + { + flag = ANIM_ALL_THEN ; + gennextanim = ptrobj->GenAnim ; + + if( (gennextanim == GEN_ANIM_LANCE) + OR (gennextanim == GEN_ANIM_TOMBE) + OR (gennextanim == GEN_ANIM_RECEPTION) + OR (gennextanim == GEN_ANIM_RECEPTION_2) ) + gennextanim = GEN_ANIM_RIEN ; + // peut etre gennextanim = ptrobj->GenNextAnim ; + } + + if( flag == ANIM_SET ) + { + flag = ANIM_ALL_THEN ; + } + +/* if( flag == ANIM_REPEAT ) + { + gennextanim = ptrobj->GenAnim ; + } +*/ + if( ptrobj->Anim == -1 ) + { + SetAnimObjet( 0, + HQR_Get( HQR_Anims, newanim ), + PtrBody[ptrobj->Body] ) ; + } + else + { + PtrBufferAnim += StockInterAnim( PtrBufferAnim, PtrBody[ptrobj->Body] ) ; + if( PtrBufferAnim > BufferAnim + 5000 - 512 ) PtrBufferAnim = BufferAnim ; + } + + ptrobj->Anim = newanim ; + ptrobj->GenAnim = gennewanim ; + ptrobj->NextGenAnim = gennextanim ; + ptrobj->PtrAnimAction = SearchPtrAnimAction ; + + ptrobj->FlagAnim = flag ; + ptrobj->Frame = 0 ; + + ptrobj->WorkFlags &= ~(OK_HIT + ANIM_END) ; + ptrobj->WorkFlags |= NEW_FRAME ; + + if( ptrobj->PtrAnimAction != 0 ) + { +/* +if( numobj == 11 ) +{ + CoulText( 15,0 ) ; + Text( 40,50, "%Faction sur 11" ) ; +} +if( numobj == 5 ) +{ + CoulText( 15,0 ) ; + Text( 40,110, "%Faction sur 5" ) ; +} +*/ + + + GereAnimAction( ptrobj, numobj ) ; + } +/* +if( numobj == 5 ) +{ + CoulText( 15,0 ) ; + Text( 40,120, "%Fapres sur 5" ) ; +} +*/ + + ptrobj->AnimStepBeta = 0 ; + ptrobj->AnimStepX = 0 ; + ptrobj->AnimStepY = 0 ; + ptrobj->AnimStepZ = 0 ; + } + return TRUE ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/* gestion anim */ + +void ReajustPos( UBYTE col ) +{ + WORD xw, yw, zw ; + + if( !col ) return ; + + xw = XMap * SIZE_BRICK_XZ - DEMI_BRICK_XZ ; /* coin superieur gauche de la brick */ + yw = YMap * SIZE_BRICK_Y ; + zw = ZMap * SIZE_BRICK_XZ - DEMI_BRICK_XZ ; + + switch( col ) /* collision complexes */ + { + case 6: + if( Nxw-xw < Nzw-zw ) col = 3 ; + else col = 2 ; + break ; + + case 7: + if( Nxw-xw < Nzw-zw ) col = 5 ; + else col = 4 ; + break ; + + case 10: + if( Nxw-xw < Nzw-zw ) col = 2 ; + else col = 3 ; + break ; + + case 11: + if( Nxw-xw < Nzw-zw ) col = 4 ; + else col = 5 ; + break ; + + case 8: + if( SIZE_BRICK_XZ-(Nxw-xw) > Nzw-zw ) col = 4 ; + else col = 2 ; + break ; + + case 9: + if( SIZE_BRICK_XZ-(Nxw-xw) > Nzw-zw ) col = 5 ; + else col = 3 ; + break ; + + case 12: + if( SIZE_BRICK_XZ-(Nxw-xw) > Nzw-zw ) col = 2 ; + else col = 4 ; + break ; + + case 13: + if( SIZE_BRICK_XZ-(Nxw-xw) > Nzw-zw ) col = 3 ; + else col = 5 ; + break ; + } + + switch( col ) /* collision de base */ + { + case 2: + Nyw = yw + BoundRegleTrois( 0, SIZE_BRICK_Y, SIZE_BRICK_XZ, Nxw - xw ) ; + break ; + + case 3: + Nyw = yw + BoundRegleTrois( 0, SIZE_BRICK_Y, SIZE_BRICK_XZ, Nzw - zw ) ; + break ; + + case 4: + Nyw = yw + BoundRegleTrois( SIZE_BRICK_Y, 0, SIZE_BRICK_XZ, Nzw - zw ) ; + break ; + + case 5: + Nyw = yw + BoundRegleTrois( SIZE_BRICK_Y, 0, SIZE_BRICK_XZ, Nxw - xw ) ; + break ; + } +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +void ReceptionObj() +{ + if( AnimNumObj == NUM_PERSO ) + { + if( StartYFalling - Nyw >= 16 * SIZE_BRICK_Y ) + { // trop haut mort directe + InitSpecial( APtObj->PosObjX, + APtObj->PosObjY+1000, + APtObj->PosObjZ, + 0 ) ; + APtObj->LifePoint = 0 ; + InitAnim( GEN_ANIM_RECEPTION_2, ANIM_ALL_THEN, GEN_ANIM_RIEN, AnimNumObj ) ; + } + else + if( StartYFalling - Nyw >= 8 * SIZE_BRICK_Y ) + { // se fait mal + InitSpecial( APtObj->PosObjX, + APtObj->PosObjY+1000, + APtObj->PosObjZ, + 0 ) ; + APtObj->LifePoint -- ; + InitAnim( GEN_ANIM_RECEPTION_2, ANIM_ALL_THEN, GEN_ANIM_RIEN, AnimNumObj ) ; + } + else + if( StartYFalling - Nyw > 1 ) + { // reception normale + InitAnim( GEN_ANIM_RECEPTION, ANIM_ALL_THEN, GEN_ANIM_RIEN, AnimNumObj ) ; + } + else + { + InitAnim( GEN_ANIM_RIEN, ANIM_REPEAT, 0, AnimNumObj ) ; + } + + StartYFalling = 0 ; + } + else + { + InitAnim( GEN_ANIM_RECEPTION, ANIM_ALL_THEN, APtObj->NextGenAnim, AnimNumObj ) ; + } +// APtObj->Falling = FALSE ; + APtObj->WorkFlags &= ~FALLING ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DoCornerReajust( WORD nx, WORD ny, WORD nz, WORD coin ) +{ + UBYTE col, orgcol ; + + orgcol = WorldColBrick( Nxw, Nyw, Nzw ) ; + + Nxw += nx ; + Nyw += ny ; + Nzw += nz ; + + if( Nxw < 0 ) goto fincorner ; + if( Nzw < 0 ) goto fincorner ; + if( Nxw > 63*SIZE_BRICK_XZ ) goto fincorner ; + if( Nzw > 63*SIZE_BRICK_XZ ) goto fincorner ; + + ReajustPos( orgcol ) ; + + if( (col = WorldColBrick( Nxw, Nyw, Nzw )) != 0 ) + { + if( col == 1 ) + { + Col1 |= coin ; + + if( WorldColBrick( Nxw, Nyw, OldZ+nz ) == 1 ) + { + if( WorldColBrick( OldX+nx, Nyw, Nzw ) != 1 ) + { + SaveNxw = OldX ; + } + } + else + { + SaveNzw = OldZ ; + } + } + } + +fincorner: + + Nxw = SaveNxw ; + Nyw = SaveNyw ; + Nzw = SaveNzw ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DoCornerReajustTwinkel( WORD nx, WORD ny, WORD nz, WORD coin ) +{ + UBYTE col, orgcol ; + + orgcol = WorldColBrick( Nxw, Nyw, Nzw ) ; + + Nxw += nx ; + Nyw += ny ; + Nzw += nz ; + + if( Nxw < 0 ) goto fincorner ; + if( Nzw < 0 ) goto fincorner ; + if( Nxw > 63*SIZE_BRICK_XZ ) goto fincorner ; + if( Nzw > 63*SIZE_BRICK_XZ ) goto fincorner ; + + ReajustPos( orgcol ) ; + + if( (col = WorldColBrickFull( Nxw, Nyw, Nzw, APtObj->Ymax )) != 0 ) + { + if( col == 1 ) + { + Col1 |= coin ; + + if( WorldColBrickFull( Nxw, Nyw, OldZ+nz, APtObj->Ymax ) == 1 ) + { + if( WorldColBrickFull( OldX+nx, Nyw, Nzw, APtObj->Ymax ) != 1 ) + { + SaveNxw = OldX ; + } + } + else + { + SaveNzw = OldZ ; + } + } + } + +fincorner: + + Nxw = SaveNxw ; + Nyw = SaveNyw ; + Nzw = SaveNzw ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void DoAnim( WORD numobj ) +{ + LONG flag ; + T_OBJET *ptrobj ; + WORD numanim ; + UBYTE *ptranim ; + UBYTE *ptrbody ; + WORD xw, yw, zw ; + UBYTE col, orgcol ; + LONG angle ; + WORD nb, n, nu ; + + APtObj = ptrobj = &ListObjet[(AnimNumObj = numobj)] ; + + if( APtObj->Body == -1 ) return ; + + OldX = APtObj->OldPosX ; + OldY = APtObj->OldPosY ; + OldZ = APtObj->OldPosZ ; + + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* gestion DEP OBJET SPRITE */ + + if( APtObj->Flags & SPRITE_3D ) + { + if( APtObj->HitForce != 0 ) + APtObj->WorkFlags |= OK_HIT ; + + /* gestion anim pour sprite */ + + Nxw = APtObj->PosObjX ; + Nyw = APtObj->PosObjY ; + Nzw = APtObj->PosObjZ ; + + if( !(APtObj->WorkFlags & FALLING) ) + { + if( APtObj->SRot != 0 ) /* vitesse deplacement */ + { + n = GetRealValue( &APtObj->RealAngle ) ; + if( !n ) /* tanpis machine trop speed */ + { + if( APtObj->RealAngle.EndValue > 0 ) + n = 1 ; + else + n = -1 ; + } + + Rotate( n,0, APtObj->FlagAnim ) ; /* alpha */ + Nyw = APtObj->PosObjY - Y0 ; + Rotate( 0, X0, APtObj->Beta ) ; + Nxw = APtObj->PosObjX + X0 ; + Nzw = APtObj->PosObjZ + Y0 ; + + InitRealValue( 0, APtObj->SRot, + 50, &APtObj->RealAngle ) ; + + if( APtObj->WorkFlags & AUTO_STOP_DOOR ) + { + // c'est obligatoirement un sprite_clip + if( APtObj->DoorWidth ) + { + // distance ouverture max + if( Distance2D( Nxw, + Nzw, + APtObj->AnimStepX, + APtObj->AnimStepZ ) + >= APtObj->DoorWidth ) + { + // recalage violent + switch( APtObj->Beta ) + { + case 768: // left + Nxw = APtObj->AnimStepX - APtObj->DoorWidth ; + break ; + + case 256: // right + Nxw = APtObj->AnimStepX + APtObj->DoorWidth ; + break ; + + case 512: // up + Nzw = APtObj->AnimStepZ - APtObj->DoorWidth ; + break ; + + case 0: // down + Nzw = APtObj->AnimStepZ + APtObj->DoorWidth ; + break ; + } + APtObj->WorkFlags &= ~AUTO_STOP_DOOR ; + APtObj->SRot = 0 ; + } + } + else + { // je me ferme + flag = FALSE ; + + switch( APtObj->Beta ) + { + case 768: // left + if( Nxw >= APtObj->AnimStepX ) flag = TRUE ; + break ; + + case 256: // right + if( Nxw <= APtObj->AnimStepX ) flag = TRUE ; + break ; + + case 512: // up + if( Nzw >= APtObj->AnimStepZ ) flag = TRUE ; + break ; + + case 0: // down + if( Nzw <= APtObj->AnimStepZ ) flag = TRUE ; + break ; + } + +/* if( Distance2D( Nxw, + Nzw, + APtObj->AnimStepX, + APtObj->AnimStepZ ) + < 100 ) + // attention si porte decal‚e +*/ if( flag ) + { + // position d'origine + + Nxw = APtObj->AnimStepX ; + Nyw = APtObj->AnimStepY ; + Nzw = APtObj->AnimStepZ ; + + APtObj->WorkFlags &= ~AUTO_STOP_DOOR ; + APtObj->SRot = 0 ; + } + } + } // auto stop door + } + + if( APtObj->Flags & PUSHABLE ) + { + Nxw += APtObj->AnimStepX ; + Nyw += APtObj->AnimStepY ; + Nzw += APtObj->AnimStepZ ; + + if( APtObj->Flags & MINI_ZV ) // boxxle + { + Nxw = (Nxw / (SIZE_BRICK_XZ/4)) * (SIZE_BRICK_XZ/4) ; + Nzw = (Nzw / (SIZE_BRICK_XZ/4)) * (SIZE_BRICK_XZ/4) ; + } + + APtObj->AnimStepX = 0 ; + APtObj->AnimStepY = 0 ; + APtObj->AnimStepZ = 0 ; + } + } + +/* if( Nxw == OldX + AND Nyw == OldY + AND Nzw == OldZ ) return ; // did not move +*/ + } + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* gestion anim/DEP OBJET 3D */ + + else /* pas SPRITE_3D donc obj articul‚s */ + + if( APtObj->Anim != -1 ) + { + numanim = APtObj->Anim ; + + ptranim = HQR_Get( HQR_Anims, numanim ) ; + ptrbody = PtrBody[APtObj->Body] ; + + flag = SetInterDepObjet( APtObj->Frame, ptranim, ptrbody ) ; + + if( AnimMasterRot ) + APtObj->WorkFlags |= ANIM_MASTER_ROT ; + else + APtObj->WorkFlags &= ~ANIM_MASTER_ROT ; + APtObj->Beta = (APtObj->Beta + AnimStepBeta - APtObj->AnimStepBeta) & 1023 ; + + APtObj->AnimStepBeta = AnimStepBeta ; + + Rotate( AnimStepX, AnimStepZ, APtObj->Beta ) ; + AnimStepX = X0 ; + AnimStepZ = Y0 ; + + Nxw = APtObj->PosObjX + AnimStepX - APtObj->AnimStepX ; + Nyw = APtObj->PosObjY + AnimStepY - APtObj->AnimStepY ; + Nzw = APtObj->PosObjZ + AnimStepZ - APtObj->AnimStepZ ; + + APtObj->AnimStepX = AnimStepX ; + APtObj->AnimStepY = AnimStepY ; + APtObj->AnimStepZ = AnimStepZ ; + + APtObj->WorkFlags &= ~(ANIM_END+NEW_FRAME) ; + if( flag ) + { +/*-----------------------------------------------------------------*/ +/* si nouvelle frame */ + APtObj->Frame++ ; + APtObj->WorkFlags |= NEW_FRAME ; + +/*-----------------------------------------------------------------*/ +/* gestion des actions d‚clench‚es par des anims/frames */ + + if( APtObj->PtrAnimAction != 0 ) + { + GereAnimAction( APtObj, numobj ) ; + } + +/*-----------------------------------------------------------------*/ +/* frame suivante test fin anim */ + if( APtObj->Frame == GetNbFramesAnim( ptranim ) ) + { + APtObj->WorkFlags &= ~OK_HIT ; + + if( APtObj->FlagAnim == ANIM_REPEAT ) + { + APtObj->Frame = GetBouclageAnim( ptranim ) ; + } + else /* ANIM[_ALL]_THEN */ + { + APtObj->GenAnim = APtObj->NextGenAnim ; + APtObj->Anim = SearchAnim( APtObj->GenAnim, numobj ) ; + if( APtObj->Anim == -1 ) + { + APtObj->Anim = SearchAnim( GEN_ANIM_RIEN, numobj ) ; + APtObj->GenAnim = GEN_ANIM_RIEN ; + } + APtObj->PtrAnimAction = SearchPtrAnimAction ; + + APtObj->FlagAnim = ANIM_REPEAT ; + APtObj->Frame = 0 ; + APtObj->HitForce = 0 ; + } + + if( APtObj->PtrAnimAction != 0 ) + { + GereAnimAction( APtObj, numobj ) ; + } + APtObj->WorkFlags |= ANIM_END ; + } + APtObj->AnimStepBeta = 0 ; + APtObj->AnimStepX = 0 ; + APtObj->AnimStepY = 0 ; + APtObj->AnimStepZ = 0 ; + +/*-----------------------------------------------------------------*/ + + }/* new frame */ + }/* if anim != -1 */ + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +// pour tous obj/sprite 3d + + // je suis porte par un CARRIER / par quelqu'un ? + if( (nu = APtObj->CarryBy) != -1 ) + { + Nxw -= ListObjet[nu].OldPosX ; + Nyw -= ListObjet[nu].OldPosY ; + Nzw -= ListObjet[nu].OldPosZ ; + + Nxw += ListObjet[nu].PosObjX ; + Nyw += ListObjet[nu].PosObjY ; + Nzw += ListObjet[nu].PosObjZ ; + + if( !CheckZvOnZv( numobj, nu ) ) + { + APtObj->CarryBy = -1 ; + } + } + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +// je tombe + + if( APtObj->WorkFlags & FALLING ) + { + /* gestion chute avec proportion sur y */ + Nxw = OldX ; + Nyw = OldY + StepFalling ; + Nzw = OldZ ; + } + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/* test/reajuste pos */ + +// ? APtObj->ObjCol = -1 ; + +if( APtObj->Flags & CHECK_BRICK_COL ) +{ + YMap = 0 ; + +/* reajuste le nyw (nouvelle pos) par rapport … la col en cours */ + + if( (col = WorldColBrick( OldX, OldY, OldZ )) != 0 ) + { + if( col == 1 ) + { + Message( "currentpos dans col 1 ?", FALSE ) ; + + Nyw = (Nyw/SIZE_BRICK_Y)*SIZE_BRICK_Y+SIZE_BRICK_Y ; + + APtObj->PosObjY = Nyw ; // essai rejette perso + } + else + { + ReajustPos( col ) ; + } + } + + if( APtObj->Flags & CHECK_OBJ_COL ) + { + CheckObjCol( numobj ) ; + } + + if( APtObj->CarryBy != -1 ) + { + if( APtObj->WorkFlags & FALLING ) + { + ReceptionObj() ; + } + } + +// þþþþþþþþþ 4 coins test la col de la nouvelle pos + size zv + +// if( !(APtObj->Flags & SPRITE_3D) ) + { + + SaveNxw = Nxw ; + SaveNyw = Nyw ; + SaveNzw = Nzw ; + + Col1 = 0 ; + + if( (numobj == NUM_PERSO) AND ((ptrobj->Flags&COL_BASSE) == 0) ) + { + DoCornerReajustTwinkel( APtObj->Xmin, APtObj->Ymin, APtObj->Zmin, 1 ) ; + DoCornerReajustTwinkel( APtObj->Xmax, APtObj->Ymin, APtObj->Zmin, 2 ) ; + DoCornerReajustTwinkel( APtObj->Xmax, APtObj->Ymin, APtObj->Zmax, 4 ) ; + DoCornerReajustTwinkel( APtObj->Xmin, APtObj->Ymin, APtObj->Zmax, 8 ) ; + } + else + { + DoCornerReajust( APtObj->Xmin, APtObj->Ymin, APtObj->Zmin, 1 ) ; + DoCornerReajust( APtObj->Xmax, APtObj->Ymin, APtObj->Zmin, 2 ) ; + DoCornerReajust( APtObj->Xmax, APtObj->Ymin, APtObj->Zmax, 4 ) ; + DoCornerReajust( APtObj->Xmin, APtObj->Ymin, APtObj->Zmax, 8 ) ; + } + + // choc si on court + + if( (Col1 != 0) + AND !(APtObj->WorkFlags & FALLING) + AND (AnimNumObj == NUM_PERSO) + AND (Comportement == C_SPORTIF) + AND (APtObj->GenAnim == GEN_ANIM_MARCHE) ) + { + Rotate( APtObj->Xmin, APtObj->Zmin, APtObj->Beta + 896 + 512 ) ; + X0 += Nxw ; + Y0 += Nzw ; + + if( (X0 >= 0) AND (Y0 >= 0) AND (X0 <= 63*SIZE_BRICK_XZ) AND (Y0 <= 63*SIZE_BRICK_XZ) + AND (WorldColBrick( X0, Nyw+256, Y0 ) != 0) ) + { + InitSpecial( APtObj->PosObjX, + APtObj->PosObjY+1000, + APtObj->PosObjZ, + 0 ) ; + InitAnim( GEN_ANIM_CHOC, ANIM_ALL_THEN, GEN_ANIM_RIEN, AnimNumObj ) ; + if( AnimNumObj == NUM_PERSO ) LastJoyFlag = TRUE ; + APtObj->LifePoint -= 1 ; + } + } + } + +// þþþþþþþþþ test la col de la nouvelle pos reelle + +/* if( (AnimNumObj == NUM_PERSO) AND ((ptrobj->Flags&COL_BASSE) == 0) ) + { + col = WorldColBrickFull( Nxw, Nyw, Nzw, APtObj->Ymax ) ; + } + else + { +*/ + col = WorldColBrick( Nxw, Nyw, Nzw ) ; + +// } + + APtObj->Col = col ; + +// if( (APtObj->Col = col = WorldColBrick( Nxw, Nyw, Nzw )) != 0 ) + if( col != 0 ) + { + if( col == 1 ) + { + if( APtObj->WorkFlags & FALLING ) + { + ReceptionObj() ; + Nyw = YMap*SIZE_BRICK_Y+SIZE_BRICK_Y ; + } + else + { + if( numobj == NUM_PERSO ) + { + if( (Comportement == C_SPORTIF) + AND (APtObj->GenAnim == GEN_ANIM_MARCHE) ) + { + InitSpecial( APtObj->PosObjX, + APtObj->PosObjY+1000, + APtObj->PosObjZ, + 0 ) ; + InitAnim( GEN_ANIM_CHOC, ANIM_ALL_THEN, GEN_ANIM_RIEN, AnimNumObj ) ; + if( numobj == NUM_PERSO ) LastJoyFlag = TRUE ; + APtObj->LifePoint -= 1 ; + } + + } + +/* if( (AnimNumObj == NUM_PERSO) AND ((ptrobj->Flags&COL_BASSE) == 0) ) + { + // fait glisser twinsen +//þþþþþþþþþ // regarde de dep X puis Z par rapport … old pos + if( WorldColBrickFull( Nxw, Nyw, OldZ, APtObj->Ymax ) != 0 ) + { + if( WorldColBrickFull( OldX, Nyw, Nzw, APtObj->Ymax ) != 0 ) + { + return ; // pos pas acceptee + } + else + { + Nxw = OldX ; + } + } + else + { + Nzw = OldZ ; + } + } + else + { +*/ + // fait glisser +//þþþþþþþþþ // regarde de dep X puis Z par rapport … old pos + + if( WorldColBrick( Nxw, Nyw, OldZ ) != 0 ) + { + if( WorldColBrick( OldX, Nyw, Nzw ) != 0 ) + { + return ; /* pos pas acceptee */ + } + else + { + Nxw = OldX ; + } + } + else + { + Nzw = OldZ ; + } +// } + } + } + else + { +// if( APtObj->Falling ) + if( APtObj->WorkFlags & FALLING ) + { + ReceptionObj() ; + } + ReajustPos( col ) ; + } + +// APtObj->Falling = FALSE ; + APtObj->WorkFlags &= ~FALLING ; + } + else /* col == 0 */ + { +/* si sous les pieds != cube plein: susceptible de tomber ou reajuste y */ + + if( (APtObj->Flags & OBJ_FALLABLE) AND (APtObj->CarryBy == -1) ) + { + col = WorldColBrick( Nxw, Nyw-1, Nzw ) ; + if( col ) + { + if( APtObj->WorkFlags & FALLING ) + { + ReceptionObj() ; + } + ReajustPos( col ) ; + } + else + { + if( !(APtObj->WorkFlags & ANIM_MASTER_ROT) ) + { + APtObj->WorkFlags |= FALLING ; + if( numobj == NUM_PERSO AND !StartYFalling ) + StartYFalling = Nyw ; + + InitAnim( GEN_ANIM_TOMBE, ANIM_REPEAT, NO_ANIM , numobj ) ; + } + } + } + } + + if( YMap == -1 ) APtObj->LifePoint = 0 ; // bye bye +} +else /* ! Flags & CHECK_BRICK_COL */ +{ + if( APtObj->Flags & CHECK_OBJ_COL ) + { + CheckObjCol( numobj ) ; + } +} + if( Col1 ) APtObj->Col |= 128 ; + + +/* protege sortie du cube */ + + if( Nxw < 0 ) Nxw = 0 ; + if( Nzw < 0 ) Nzw = 0 ; + if( Nyw < 0 ) Nyw = 0 ; + if( Nxw > 63*SIZE_BRICK_XZ ) Nxw = 63*SIZE_BRICK_XZ ; + if( Nzw > 63*SIZE_BRICK_XZ ) Nzw = 63*SIZE_BRICK_XZ ; + +/* ok enregistre position */ + + APtObj->PosObjX = Nxw ; + APtObj->PosObjY = Nyw ; + APtObj->PosObjZ = Nzw ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛÜ ÜÛ ÛßßßÛ Û Û Ûßßßß + ÛÛß Û ÛÛ Û ÛÛ Üß ÛÛßß + ßß ß ßßßßß ßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void ManualRealAngle( T_OBJET *ptrobj ) +{ + WORD angle = 0 ; + + if( MyJoy & J_LEFT ) angle = +256 ; + if( MyJoy & J_RIGHT ) angle = -256 ; + + InitRealAngleConst( ptrobj->Beta, + ptrobj->Beta + angle, + ptrobj->SRot, + &ptrobj->RealAngle ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void ClearRealAngle( T_OBJET *ptrobj ) +{ + InitRealAngle( ptrobj->Beta, + ptrobj->Beta, + 0, + &ptrobj->RealAngle ) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/* T_OBJET. Info Info1 Info2 Info3 + +FOLLOW num obj +FOLLOW_2 etat label1/label2 distance num obj + + + NumTrack OffsetTrack + +TRACK +TRACK_ATTACK + +*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + + +void DoDir( WORD numobj ) +{ + LONG f ; + T_OBJET *ptrobj ; + UBYTE *ptr ; + WORD info,info1,info2,info3 ; + WORD flag, angle ; + UBYTE macro ; + UBYTE string[256] ; + + ptrobj = &ListObjet[numobj] ; + + if( ptrobj->Body == -1 ) return ; + +/*-------------------------------------------------------------------------*/ + if( ptrobj->WorkFlags & FALLING ) + { + if( ptrobj->Move == MOVE_MANUAL ) + { + ManualRealAngle( ptrobj ) ; + LastMyJoy = MyJoy ; + } + return ; + } + +// if( !(ptrobj->WorkFlags & ANIM_MASTER_ROT) ) + { + if( !(ptrobj->Flags & SPRITE_3D) + AND ptrobj->Move != MOVE_MANUAL ) + { + ptrobj->Beta = GetRealAngle( &ptrobj->RealAngle ) ; + } + } +/* else + { + ClearRealAngle( ptrobj ) ; + } +*/ + switch( ptrobj->Move ) + { +/*-------------------------------------------------------------------------*/ + case MOVE_MANUAL: + + if( numobj == NUM_PERSO ) /* protection anim speciales */ + { + ActionNormal = FALSE ; +/* + if( MyKey == K_F1 ) SetComportement( C_NORMAL ) ; + if( MyKey == K_F2 ) SetComportement( C_SPORTIF ) ; + if( MyKey == K_F3 ) SetComportement( C_AGRESSIF ) ; + if( MyKey == K_F4 ) SetComportement( C_DISCRET ) ; +*/ + switch( Comportement ) + { + case C_NORMAL: + if( MyFire & F_SPACE ) + { + ActionNormal = TRUE ; + } + break ; + + case C_SPORTIF: + if( MyFire & F_SPACE ) + { + InitAnim( GEN_ANIM_SAUTE, ANIM_THEN, GEN_ANIM_RIEN, numobj ) ; + } + break ; + + case C_AGRESSIF: + if( MyFire & F_SPACE ) + { + if( CombatAuto ) + { + LastJoyFlag = TRUE ; + /* essai control direction pendant combat */ + ptrobj->Beta = GetRealAngle( &ptrobj->RealAngle ) ; + + if( (LastFire & F_SPACE) + AND( ptrobj->GenAnim != GEN_ANIM_RIEN ) ) + break ; + + switch( Rnd(3) ) + { + case 0: + InitAnim( GEN_ANIM_COUP_1, ANIM_THEN, GEN_ANIM_RIEN, numobj ) ; + break ; + case 1: + InitAnim( GEN_ANIM_COUP_2, ANIM_THEN, GEN_ANIM_RIEN, numobj ) ; + break ; + case 2: + InitAnim( GEN_ANIM_COUP_3, ANIM_THEN, GEN_ANIM_RIEN, numobj ) ; + break ; + } + } + else + { + if( MyJoy & J_RIGHT ) + InitAnim( GEN_ANIM_COUP_2, ANIM_THEN, GEN_ANIM_RIEN, numobj ) ; + if( MyJoy & J_LEFT ) + InitAnim( GEN_ANIM_COUP_3, ANIM_THEN, GEN_ANIM_RIEN, numobj ) ; + if( MyJoy & J_UP ) + InitAnim( GEN_ANIM_COUP_1, ANIM_THEN, GEN_ANIM_RIEN, numobj ) ; + } + } + break ; + + case C_DISCRET: + if( MyFire & F_SPACE ) + { + InitAnim( GEN_ANIM_CACHE, ANIM_REPEAT, NO_ANIM, numobj ) ; + } + break ; + } + + /* lance balle magique */ + + if( (MyFire & F_ALT) + AND (ListFlagGame[FLAG_CONSIGNE] == 0) ) + { + if( Weapon == 0 ) // balle magique + { + if( ListFlagGame[FLAG_BALLE_MAGIQUE] == 1 ) + { + if( MagicBall == -1 ) + { + InitAnim( GEN_ANIM_LANCE, ANIM_THEN, GEN_ANIM_RIEN, numobj ) ; + } + LastJoyFlag = TRUE ; + /* control direction pendant vis‚e */ + ptrobj->Beta = GetRealAngle( &ptrobj->RealAngle ) ; + } + } + else // sabre magique + { + if( ListFlagGame[FLAG_SABRE_MAGIQUE] == 1 ) + { + if( ptrobj->GenBody != GEN_BODY_SABRE ) + { + InitBody( GEN_BODY_SABRE, NUM_PERSO ) ; + } + // anim frappe rapide + + InitAnim( GEN_ANIM_SABRE, ANIM_THEN, GEN_ANIM_RIEN, numobj ) ; + + LastJoyFlag = TRUE ; + /* control direction pendant vis‚e */ + ptrobj->Beta = GetRealAngle( &ptrobj->RealAngle ) ; + } + } + } + + } /* endif numperso */ + + if( !MyFire OR ActionNormal ) + { + if( MyJoy & J_UP+J_DOWN ) LastJoyFlag = FALSE ; + + if( ((MyJoy != LastMyJoy) OR (MyFire != LastMyFire) ) + AND LastJoyFlag ) + { + InitAnim( GEN_ANIM_RIEN, ANIM_REPEAT, NO_ANIM, numobj ) ; + } + + LastJoyFlag = FALSE ; + + if( MyJoy & J_UP ) + { + if( !FlagClimbing ) + { + InitAnim( GEN_ANIM_MARCHE, ANIM_REPEAT, NO_ANIM, numobj ) ; + } + LastJoyFlag = TRUE ; + } + + if( MyJoy & J_DOWN ) + { + InitAnim( GEN_ANIM_RECULE, ANIM_REPEAT, NO_ANIM, numobj ) ; + LastJoyFlag = TRUE ; + } + + if( MyJoy & J_LEFT ) + { + LastJoyFlag = TRUE ; +// if( ptrobj->Anim == AnimRien ) + if( ptrobj->GenAnim == GEN_ANIM_RIEN ) + { + InitAnim( GEN_ANIM_GAUCHE, ANIM_REPEAT, NO_ANIM, numobj ) ; + } + else + { + if( !(ptrobj->WorkFlags & ANIM_MASTER_ROT) ) + { + ptrobj->Beta = GetRealAngle( &ptrobj->RealAngle ) ; + } + } + } + + if( MyJoy & J_RIGHT ) + { + LastJoyFlag = TRUE ; +// if( ptrobj->Anim == AnimRien ) + if( ptrobj->GenAnim == GEN_ANIM_RIEN ) + { + InitAnim( GEN_ANIM_DROITE, ANIM_REPEAT, NO_ANIM, numobj ) ; + } + else + { + if( !(ptrobj->WorkFlags & ANIM_MASTER_ROT) ) + { + ptrobj->Beta = GetRealAngle( &ptrobj->RealAngle ) ; + } + } + } + } + + ManualRealAngle( ptrobj ) ; + LastMyJoy = MyJoy ; + LastMyFire = MyFire ; + + break ; + +/*-------------------------------------------------------------------------*/ + case MOVE_FOLLOW: +// if( !(ptrobj->WorkFlags & ANIM_MASTER_ROT) ) + { + info3 = ptrobj->Info3 ; /* num obj to follow */ + + angle = GetAngle( ptrobj->PosObjX, + ptrobj->PosObjZ, + ListObjet[info3].PosObjX, + ListObjet[info3].PosObjZ ) ; + + if( ptrobj->Flags & SPRITE_3D ) + { + ptrobj->Beta = angle ; + } + else + { + InitRealAngleConst( ptrobj->Beta, + angle, + ptrobj->SRot, + &ptrobj->RealAngle ) ; + } + } + break ; + +/*-------------------------------------------------------------------------*/ + case MOVE_RANDOM: + if( !(ptrobj->WorkFlags & ANIM_MASTER_ROT) ) + { + if( ptrobj->Col & 128 ) + { + angle = (ptrobj->Beta + (rand()&511) - 256 + 512) & 1023 ; + InitRealAngleConst( ptrobj->Beta, + angle, + ptrobj->SRot, + &ptrobj->RealAngle ) ; + + *(ULONG*)(&ptrobj->Info) = TimerRef + Rnd( 300 ) + 300 ; + InitAnim( GEN_ANIM_RIEN, ANIM_REPEAT, NO_ANIM, numobj ) ; + } + if( !ptrobj->RealAngle.TimeValue ) + { + InitAnim( GEN_ANIM_MARCHE, ANIM_REPEAT, NO_ANIM, numobj ) ; + if( TimerRef > *(ULONG*)(&ptrobj->Info) ) + { + angle = (ptrobj->Beta + (rand()&511) - 256) & 1023 ; + InitRealAngleConst( ptrobj->Beta, + angle, + ptrobj->SRot, + &ptrobj->RealAngle ) ; + + *(ULONG*)(&ptrobj->Info) = TimerRef + Rnd( 300 ) + 300 ; + } + } + } + break ; + +/*-------------------------------------------------------------------------*/ +/* case MOVE_FOLLOW_2: + break ; + + case MOVE_TRACK_ATTACK: + break ; +*/ +/*-------------------------------------------------------------------------*/ + case MOVE_TRACK: + if( ptrobj->OffsetTrack == -1 ) ptrobj->OffsetTrack = 0 ; + break ; + + +/*-------------------------------------------------------------------------*/ + case MOVE_SAME_XZ: + info3 = ptrobj->Info3 ; /* num obj to follow */ + ptrobj->PosObjX = ListObjet[info3].PosObjX ; + ptrobj->PosObjZ = ListObjet[info3].PosObjZ ; + break ; + } +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßßÜ Û ÛÛßßß ÛßßßÛ Û ÛßßßÛ Û Üß + ÛÛ Û ÛÛ ßßßßÛ ÛÛßßß ÛÛ ÛÛßßÛ ÛÛß + ßßßß ßß ßßßßß ßß ßßßßß ßß ß ßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +#ifdef DEBUG_TOOLS + +LONG DrawCube( WORD xw0, WORD yw0, WORD zw0, + WORD xw1, WORD yw1, WORD zw1 ) +{ + LONG x0,y0,x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,x7,y7 ; + WORD coul = 11 ; + WORD coul1 = 13 ; + + ClearScreenMinMax() ; + + ProjettePoint( xw0,yw0,zw0 ) ; + AdjustScreenMax() ; + x0 = Xp ; + y0 = Yp ; + ProjettePoint( xw1,yw0,zw0 ) ; + AdjustScreenMax() ; + x1 = Xp ; + y1 = Yp ; + ProjettePoint( xw1,yw0,zw1 ) ; + AdjustScreenMax() ; + x2 = Xp ; + y2 = Yp ; + ProjettePoint( xw0,yw0,zw1 ) ; + AdjustScreenMax() ; + x3 = Xp ; + y3 = Yp ; + ProjettePoint( xw0,yw1,zw0 ) ; + AdjustScreenMax() ; + x4 = Xp ; + y4 = Yp ; + ProjettePoint( xw1,yw1,zw0 ) ; + AdjustScreenMax() ; + x5 = Xp ; + y5 = Yp ; + ProjettePoint( xw1,yw1,zw1 ) ; + AdjustScreenMax() ; + x6 = Xp ; + y6 = Yp ; + ProjettePoint( xw0,yw1,zw1 ) ; + AdjustScreenMax() ; + x7 = Xp ; + y7 = Yp ; + + SetClip( ScreenXmin, ScreenYmin, ScreenXmax, ScreenYmax ) ; + if( ClipXmin <= ClipXmax + AND ClipYmin <= ClipYmax ) + { + Line( x0,y0, x1,y1, coul ) ; + Line( x1,y1, x2,y2, coul ) ; + Line( x2,y2, x3,y3, coul ) ; + Line( x3,y3, x0,y0, coul ) ; + + Line( x0,y0, x4,y4, coul1 ) ; + Line( x1,y1, x5,y5, coul1 ) ; + Line( x2,y2, x6,y6, coul1 ) ; + Line( x3,y3, x7,y7, coul1 ) ; + Line( x4,y4, x5,y5, coul1 ) ; + Line( x5,y5, x6,y6, coul1 ) ; + Line( x6,y6, x7,y7, coul1 ) ; + Line( x7,y7, x4,y4, coul1 ) ; + return 1 ; + } + return 0 ; +} + + +void DrawZV( T_OBJET *ptr ) +{ + if( DrawCube( ptr->Xmin - WorldXCube, + ptr->Ymin - WorldYCube, + ptr->Zmin - WorldZCube, + ptr->Xmax - WorldXCube, + ptr->Ymax - WorldYCube, + ptr->Zmax - WorldZCube ) ) + { + AddPhysBox( ClipXmin, ClipYmin, ClipXmax, ClipYmax ) ; + } + UnSetClip() ; +} + +#endif + + + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void AffScene( LONG flagflip ) +{ + LONG n, c, cmpt ; + LONG xmin, ymin, xmax, ymax, dx, dy ; + T_OBJET *ptrobj ; + T_EXTRA *ptrextra ; + T_TRACK *ptrtrack ; + T_ZONE *ptrz ; + T_INCRUST_DISP *ptrdisp ; + T_SORT *ptrtri ; + WORD *ptr ; + LONG nbobjets ; + LONG err ; + WORD numobj, typeobj ; + WORD x,y,z, x0,y0, xw, yw, zw, xm, ym, zm ; + WORD num ; + WORD ztri ; + WORD oldxporg ; + WORD oldyporg ; + UBYTE string[40] ; + UBYTE *ptranim, *ptrbody ; + + WORD txmin, tymin, tzmin, txmax, tymax, tzmax ; + WORD pxmin, pymin, pzmin, pxmax, pymax, pzmax ; + WORD twinsenpos, twinsenz ; + LONG shadowtwinsen, i ; + +/*------------------------------------------------------------------------*/ + +// xw = StartXCube*SIZE_BRICK_XZ ; +// yw = StartYCube*SIZE_BRICK_Y ; +// zw = StartZCube*SIZE_BRICK_XZ ; + + oldxporg = XpOrgw ; + oldyporg = YpOrgw ; + +/*------------------------------------------------------------------------*/ +/* cls */ + + UnSetClip() ; + + if( !flagflip ) + { + ClsBoxes() ; /* nettoie Log */ + } + else + { + SaveTimer() ; + Cls() ; + AffGrille() ; + ChangeIncrustPos( oldxporg,oldyporg, XpOrgw, YpOrgw ) ; + HQ_ChangeBalanceSamples( oldxporg, oldyporg ) ; + CopyScreen( Log, Screen ) ; + } + +/*------------------------------------------------------------------------*/ +/* objets scenarique 3D ou sprite */ + + nbobjets = 0 ; + ptrobj = ListObjet ; + + for( n=0; nWorkFlags &= ~WAS_DRAWN ; + + // si zone grm en cours n'affiche pas les objets au dessus ! + if( ZoneGrm != -1 ) + { + ptrz = &ListZone[IndexGrm] ; + if( ptrobj->PosObjY > ListZone[IndexGrm].Y1 ) + { + continue ; + } + } + + if( (ptrobj->Flags & OBJ_BACKGROUND) + AND (flagflip == FALSE) ) + { + // rustine: renseigne qd meme moteur presence sprite + // pour obj_back si dans l'‚cran + ProjettePoint( ptrobj->PosObjX-WorldXCube, + ptrobj->PosObjY-WorldYCube, + ptrobj->PosObjZ-WorldZCube ) ; + if( (Xp>VIEW_X0) AND (XpVIEW_Y0) AND (YpWorkFlags |= WAS_DRAWN ; + } + continue ; + } + + if( (ptrobj->Body != -1) + AND (!(ptrobj->Flags&INVISIBLE)) ) + { + /* preclip */ + ProjettePoint( ptrobj->PosObjX-WorldXCube, + ptrobj->PosObjY-WorldYCube, + ptrobj->PosObjZ-WorldZCube ) ; + + // agrandie la zone de visualisation que pour les portes (sprite_clip) + + if( ( (ptrobj->Flags&SPRITE_CLIP) + AND (Xp>-112) AND (Xp<(640+112)) AND (Yp>-50) AND (Yp<(480+171))) + + OR ( (!(ptrobj->Flags&SPRITE_CLIP)) + AND (Xp>VIEW_X0) AND (XpVIEW_Y0) AND (YpVIEW_X0) AND (XpVIEW_Y0) AND (YpPosObjX - WorldXCube + + ptrobj->PosObjZ - WorldZCube ; + + /* magouille pour etre sur qu'un carrier est + dessous l'eventuel objet port‚ */ + + // arg ! moche si 2 obj sur carrier + if( (num=ptrobj->CarryBy) != -1 ) + { + ztri = ListObjet[num].PosObjX - WorldXCube + + ListObjet[num].PosObjZ - WorldZCube + + 2 ; + } + + if( ptrobj->Flags & SPRITE_3D ) + { + ListTri[nbobjets].NumObj = n + TYPE_OBJ_SPRITE ; + + if( ptrobj->Flags & SPRITE_CLIP ) + { + ztri = ptrobj->AnimStepX - WorldXCube + + ptrobj->AnimStepZ - WorldZCube ; + } + } + else + { + ListTri[nbobjets].NumObj = n + TYPE_OBJ_3D ; + + } + ListTri[nbobjets].Z = ztri ; + nbobjets++ ; + + if( Shadow ) + { + if( !(ptrobj->Flags & NO_SHADOW) ) + { + if( (c=ptrobj->CarryBy) != -1 ) + { + ShadowX = ptrobj->PosObjX ; + ShadowY = ptrobj->PosObjY-1 ; + ShadowZ = ptrobj->PosObjZ ; + } + else + { + GetShadow( ptrobj->PosObjX,ptrobj->PosObjY,ptrobj->PosObjZ ) ; + } + + ListTri[nbobjets].Z = ztri - 1 ; + + /* ptrobj->PosObjX-xw + ptrobj->PosObjZ-zw - 1 ; */ + ListTri[nbobjets].NumObj = TYPE_SHADOW + n ; /* shadow */ + ListTri[nbobjets].Num = 2 ; + ListTri[nbobjets].Xw = ShadowX ; + ListTri[nbobjets].Yw = ShadowY ; + ListTri[nbobjets].Zw = ShadowZ ; + nbobjets++ ; + } + } + + if( FlagMCGA ) + { + if( n == NumObjFollow ) + { + xmin = Xp ; + ymin = Yp ; + } + } + } + } + } + +/*------------------------------------------------------------------------*/ +/* objet temporaires (throw, bonus...) */ + + ptrextra = ListExtra ; + for( n=0; nSprite != -1 ) + { + if( ptrextra->Flags & EXTRA_TIME_IN ) + { + if( (TimerRef - ptrextra->Timer) > 35 ) + { + ptrextra->Timer = TimerRef ; + ptrextra->Flags &= ~EXTRA_TIME_IN ; + + HQ_3D_MixSample( 11, 0x1000, 1, + ptrextra->PosX, ptrextra->PosY, ptrextra->PosZ ) ; + } + continue ; + } + + if( ptrextra->Flags & EXTRA_TIME_OUT ) + { + /* fait clignoter aff */ + if( ptrextra->Flags & EXTRA_FLASH ) + { + if( TimerRef >= ptrextra->Timer + ptrextra->TimeOut - 50 * 3 ) + { + if( (TimerRef+ptrextra->Timer) & 8 ) + continue ; + } + } + } + + ProjettePoint( ptrextra->PosX-WorldXCube, + ptrextra->PosY-WorldYCube, + ptrextra->PosZ-WorldZCube ) ; + + /* mettre test du preclip en fonction de la taille */ + + if( (Xp>VIEW_X0) AND (XpVIEW_Y0) AND (YpPosX-WorldXCube + ptrextra->PosZ-WorldZCube ; + ListTri[nbobjets].NumObj = n + TYPE_EXTRA ; + nbobjets++ ; + + /* les effets n'ont pas d'ombres */ + if( (Shadow==2) AND !(ptrextra->Sprite&32768) ) + { + GetShadow( ptrextra->PosX,ptrextra->PosY,ptrextra->PosZ ) ; + + ListTri[nbobjets].Z = ptrextra->PosX-WorldXCube + ptrextra->PosZ-WorldZCube - 1 ; + ListTri[nbobjets].NumObj = TYPE_SHADOW ; /* shadow */ +/* GetDxDyGraph( ptrextra->Sprite, &dx, &dy, PtrSpriteExtra ) ; */ + ListTri[nbobjets].Num = 0 ; + ListTri[nbobjets].Xw = ShadowX ; + ListTri[nbobjets].Yw = ShadowY ; + ListTri[nbobjets].Zw = ShadowZ ; + nbobjets++ ; + } + } + } + } + +/*------------------------------------------------------------------------*/ +/* tri objets */ + + SmallSort( ListTri, nbobjets, sizeof( T_SORT ) ) ; + + // corrections des erreurs de tri + + ptrobj = &ListObjet[NUM_PERSO] ; // Twinsen ZV + + // cherche twinsen + + if( (ptrobj->Body != -1) + AND (!(ptrobj->Flags&INVISIBLE)) ) + { + txmin = ptrobj->PosObjX + ptrobj->Xmin ; + tymin = ptrobj->PosObjY + ptrobj->Ymin ; + tzmin = ptrobj->PosObjZ + ptrobj->Zmin ; + txmax = ptrobj->PosObjX + ptrobj->Xmax ; + tymax = ptrobj->PosObjY + ptrobj->Ymax ; + tzmax = ptrobj->PosObjZ + ptrobj->Zmax ; + + twinsenpos = -1 ; + ptrtri = ListTri ; + for( n=0; nNumObj == NUM_PERSO + TYPE_OBJ_3D ) + { + twinsenpos = n ; + twinsenz = ptrtri->Z ; + break ; + } + } + + // cherche bug porte + if( twinsenpos != -1 ) + { + ptrtri = ListTri ; + for( n=0; nNumObj ; + typeobj = numobj & ~1023 ; + numobj &= 1023 ; + ptrobj = &ListObjet[ numobj ] ; + + switch( typeobj ) + { + case TYPE_OBJ_SPRITE: + + if( ptrobj->Flags & SPRITE_CLIP ) // tiens une porte ? + { + pxmin = ptrobj->AnimStepX + ptrobj->Xmin ; + pymin = ptrobj->AnimStepY + ptrobj->Ymin ; + pzmin = ptrobj->AnimStepZ + ptrobj->Zmin ; + pxmax = ptrobj->AnimStepX + ptrobj->Xmax ; + pymax = ptrobj->AnimStepY + ptrobj->Ymax ; + pzmax = ptrobj->AnimStepZ + ptrobj->Zmax ; + + if( (pxmax > txmin) AND (pxmin < txmax) ) + { + // axe des x commun + // regarde Z + + if( pzmax <= tzmin ) // twinsen apr‚s + { + if( twinsenz < ptrtri->Z ) + { + // correction erreur + + ListTri[twinsenpos].Z = ptrtri->Z ; + ListTri[twinsenpos].NumObj = ptrtri->NumObj ; + + ptrtri->NumObj = NUM_PERSO + TYPE_OBJ_3D ; + ptrtri->Z = twinsenz ; + + twinsenpos = n ; + numobj = -1 ; + break ; + } + } + + if( pzmin >= tzmax ) // twinsen avant + { + if( twinsenz > ptrtri->Z ) + { + // correction erreur + + ListTri[twinsenpos].Z = ptrtri->Z ; + ListTri[twinsenpos].NumObj = ptrtri->NumObj ; + + ptrtri->NumObj = NUM_PERSO + TYPE_OBJ_3D ; + ptrtri->Z = twinsenz ; + + twinsenpos = n ; + numobj = -1 ; + break ; + } + } + + // axe des Z commun + // regarde Y min + + // tanpis + break ; + } + + if( (pzmax > tzmin) AND (pzmin < tzmax ) ) + { + // axe des Z commun + // regarde X + + if( pxmax <= txmin ) // twinsen apr‚s + { + if( twinsenz < ptrtri->Z ) + { + // correction erreur + + ListTri[twinsenpos].Z = ptrtri->Z ; + ListTri[twinsenpos].NumObj = ptrtri->NumObj ; + + ptrtri->NumObj = NUM_PERSO + TYPE_OBJ_3D ; + ptrtri->Z = twinsenz ; + + twinsenpos = n ; + numobj = -1 ; + break ; + } + } + else + { // twinsen avant + if( twinsenz > ptrtri->Z ) + { + // correction erreur + + ListTri[twinsenpos].Z = ptrtri->Z ; + ListTri[twinsenpos].NumObj = ptrtri->NumObj ; + + ptrtri->NumObj = NUM_PERSO + TYPE_OBJ_3D ; + ptrtri->Z = twinsenz ; + + twinsenpos = n ; + numobj = -1 ; + break ; + } + } + } + } + break ; + + } + + if( numobj == -1 ) break ; + } + } + } + +/*------------------------------------------------------------------------*/ +/* boucle aff all objs */ + + shadowtwinsen = FALSE ; + + NbPhysBox = 0 ; + for( n=0; nAnim ) ; + ptrbody = PtrBody[ ptrobj->Body ] ; + + SetInterAnimObjet2( ptrobj->Frame, ptranim, ptrbody ) ; + + err = AffObjetIso( ptrobj->PosObjX-WorldXCube, ptrobj->PosObjY-WorldYCube, ptrobj->PosObjZ-WorldZCube, + 0, ptrobj->Beta, 0, + ptrbody ) ; + + if( !err ) /* objet pas tout clipp‚ */ + { + SetClip( ScreenXmin, ScreenYmin, ScreenXmax, ScreenYmax ) ; + if( ClipXmin <= ClipXmax + AND ClipYmin <= ClipYmax ) + { + ptrobj->WorkFlags |= WAS_DRAWN ; + + xm = ((ptrobj->PosObjX+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + ym = ((ptrobj->PosObjY)/SIZE_BRICK_Y) ; + if( (ptrobj->Col&127) != 0 ) ym++ ; + zm = ((ptrobj->PosObjZ+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + DrawOverBrick( xm, ym, zm ) ; + AddPhysBox( ClipXmin, ClipYmin, ClipXmax, ClipYmax ) ; + + if( (ptrobj->Flags & OBJ_BACKGROUND) + AND (flagflip == TRUE) ) + { + CopyBlock( ClipXmin, ClipYmin, ClipXmax, ClipYmax, Log, + ClipXmin, ClipYmin, Screen ) ; + } + +//DrawZV( &ListObjet[numobj] ) ; + + } + } + break ; + + /*------------------------------------------------------------------------*/ + case TYPE_OBJ_SPRITE: + + ProjettePoint( ptrobj->PosObjX-WorldXCube, + ptrobj->PosObjY-WorldYCube, + ptrobj->PosObjZ-WorldZCube ) ; + + num = ptrobj->Body ; + + GetDxDyGraph( 0, &dx, &dy, HQR_Get(HQRPtrSpriteExtra,num) ) ; + + ScreenXmin = Xp + PtrZvExtra[ num*8 + 0 ] ; + ScreenYmin = Yp + PtrZvExtra[ num*8 + 1 ] ; + ScreenXmax = ScreenXmin + dx ; + ScreenYmax = ScreenYmin + dy ; + + if( ptrobj->Flags & SPRITE_CLIP ) + { + SetClip(ptrobj->Info+XpOrgw, ptrobj->Info1+YpOrgw, + ptrobj->Info2+XpOrgw, ptrobj->Info3+YpOrgw ) ; + } + else + { + SetClip( ScreenXmin, ScreenYmin, ScreenXmax, ScreenYmax ) ; + } + + if( ClipXmin <= ClipXmax + AND ClipYmin <= ClipYmax ) + { + AffGraph( 0, ScreenXmin, ScreenYmin, HQR_Get(HQRPtrSpriteExtra,num) ) ; + + ptrobj->WorkFlags |= WAS_DRAWN ; + + if( ptrobj->Flags & SPRITE_CLIP ) + { + xm = ((ptrobj->AnimStepX+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + ym = ((ptrobj->AnimStepY)/SIZE_BRICK_Y) ; + /* if( ptrobj->Col != 0 ) ym++ ; */ + zm = ((ptrobj->AnimStepZ+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + DrawOverBrick3( xm, ym, zm ) ; + } + else + { + xm = ((ptrobj->PosObjX+ptrobj->Xmax+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + ym = ((ptrobj->PosObjY)/SIZE_BRICK_Y) ; + if( (ptrobj->Col&127) != 0 ) ym++ ; + zm = ((ptrobj->PosObjZ+ptrobj->Zmax+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + + DrawOverBrick3( xm, ym, zm ) ; + } + + AddPhysBox( ClipXmin, ClipYmin, ClipXmax, ClipYmax ) ; + + if( (ptrobj->Flags & OBJ_BACKGROUND) + AND (flagflip == TRUE) ) + { + CopyBlock( ClipXmin, ClipYmin, ClipXmax, ClipYmax, Log, + ClipXmin, ClipYmin, Screen ) ; + } + } + break ; + + /*------------------------------------------------------------------------*/ + case TYPE_SHADOW: + + if( numobj == NUM_PERSO ) shadowtwinsen = TRUE ; + + ProjettePoint( ListTri[n].Xw-WorldXCube, + ListTri[n].Yw-WorldYCube, + ListTri[n].Zw-WorldZCube ) ; + + GetDxDyGraph( ListTri[n].Num, &dx, &dy, BufferShadow ) ; + + ScreenXmin = Xp -(dx/2) ; + ScreenXmax = Xp +(dx/2) ; + ScreenYmin = Yp -(dy/2) ; + ScreenYmax = Yp +(dy/2) ; + SetClip( ScreenXmin, ScreenYmin, ScreenXmax, ScreenYmax ) ; + + /* mettre affpoly (lba2) */ + + if( ClipXmin <= ClipXmax + AND ClipYmin <= ClipYmax ) + { + AffGraph( ListTri[n].Num, ScreenXmin, ScreenYmin, BufferShadow ) ; + +// ptrobj = ListObjet ; ? + xm = ((ListTri[n].Xw+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + ym = ((ListTri[n].Yw)/SIZE_BRICK_Y) ; + zm = ((ListTri[n].Zw+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + DrawOverBrick( xm, ym, zm ) ; + + AddPhysBox( ClipXmin, ClipYmin, ClipXmax, ClipYmax ) ; + } + break ; + + /*------------------------------------------------------------------------*/ + case TYPE_EXTRA: + + ptrextra = &ListExtra[ numobj ] ; + + ProjettePoint( ptrextra->PosX-WorldXCube, + ptrextra->PosY-WorldYCube, + ptrextra->PosZ-WorldZCube ) ; + + num = ptrextra->Sprite ; + if( num & 32768 ) /* effet sp‚cial */ + { + AffSpecial( numobj, Xp, Yp ) ; + } + else /* sprite */ + { + GetDxDyGraph( 0, &dx, &dy, HQR_Get(HQRPtrSpriteExtra,num) ) ; + + ScreenXmin = Xp + PtrZvExtra[ num*8 + 0 ] ; + ScreenYmin = Yp + PtrZvExtra[ num*8 + 1 ] ; + ScreenXmax = ScreenXmin + dx ; + ScreenYmax = ScreenYmin + dy ; + + AffGraph( 0, ScreenXmin, ScreenYmin, HQR_Get(HQRPtrSpriteExtra,num) ) ; + } + + SetClip( ScreenXmin, ScreenYmin, ScreenXmax, ScreenYmax ) ; + if( ClipXmin <= ClipXmax + AND ClipYmin <= ClipYmax ) + { + xm = ((ptrextra->PosX+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + ym = ((ptrextra->PosY)/SIZE_BRICK_Y) ; + zm = ((ptrextra->PosZ+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + + DrawOverBrick( xm, ym, zm ) ; + + AddPhysBox( ClipXmin, ClipYmin, ClipXmax, ClipYmax ) ; + } + + break ; + /*------------------------------------------------------------------------*/ + } /* end switch typeobj */ + UnSetClip() ; + + } /* end for nbobjets */ + +/*------------------------------------------------------------------------*/ +// special incrust disp + + ptrdisp = ListIncrustDisp ; + for( n=0; nNum == -1 ) continue ; + + switch( ptrdisp->Move ) + { + case 0: // wait nb sec and die + if( TimerRef > ptrdisp->TimerEnd ) + { + ptrdisp->Num = -1 ; + continue ; + } + break ; + + case 1: // follow obj coor for nb sec and die + num = ptrdisp->Info ; + + ProjettePoint( ListObjet[num].PosObjX - WorldXCube, + ListObjet[num].PosObjY + ListObjet[num].Ymax - WorldYCube, + ListObjet[num].PosObjZ - WorldZCube ) ; + + ptrdisp->X = Xp ; + ptrdisp->Y = Yp ; + + if( TimerRef > ptrdisp->TimerEnd ) + { + ptrdisp->Num = -1 ; + continue ; + } + break ; + } + + switch( ptrdisp->Type ) + { + case INCRUST_NUM: + + strcpy( string, Itoa( ptrdisp->Num ) ) ; + dx = SizeFont( string ) ; + dy = 48 ; + + ScreenXmin = ptrdisp->X - dx/2 ; + ScreenYmin = ptrdisp->Y - dy/2 ; + ScreenXmax = ScreenXmin + dx ; + ScreenYmax = ScreenYmin + dy ; + + SetClip( ScreenXmin, ScreenYmin, ScreenXmax, ScreenYmax ) ; + CoulFont( ptrdisp->Info ) ; + Font( ScreenXmin, ScreenYmin, string ) ; + + if( ClipXmin <= ClipXmax + AND ClipYmin <= ClipYmax ) + { + AddPhysBox( ClipXmin, ClipYmin, ClipXmax, ClipYmax ) ; + } + break ; + + case INCRUST_TEXT: + + GetMultiText( ptrdisp->Num, string ) ; + dx = SizeFont( string ) + 1 ; // because /2 + dy = 48 ; + + ScreenXmin = ptrdisp->X - dx/2 ; + ScreenYmin = ptrdisp->Y - dy/2 ; + ScreenXmax = ScreenXmin + dx ; + ScreenYmax = ScreenYmin + dy ; + + if( ScreenXmax >= 640 ) + { + ScreenXmin -= ScreenXmax - 639 ; + ScreenXmax = 639 ; + } + + if( ScreenXmin < 0 ) + { + ScreenXmax = dx ; + ScreenXmin = 0 ; + } + + if( ScreenYmax >= 480 ) + { + ScreenYmin -= ScreenYmax - 479 ; + ScreenYmax = 479 ; + } + + if( ScreenYmin < 0 ) + { + ScreenYmax = dy ; + ScreenYmin = 0 ; + } + + SetClip( ScreenXmin, ScreenYmin, ScreenXmax, ScreenYmax ) ; +// CoulFont( 0 ) ; +// Font( ClipXmin+2, ClipYmin+4, string ) ; + CoulFont( ListObjet[ptrdisp->Info].CoulObj*16 + 14 ) ; + Font( ClipXmin, ClipYmin, string ) ; + + if( ClipXmin <= ClipXmax + AND ClipYmin <= ClipYmax ) + { + AddPhysBox( ClipXmin, ClipYmin, ClipXmax, ClipYmax ) ; + } + break ; + + case INCRUST_SPRITE: + + GetDxDyGraph( 0, &dx, &dy, HQR_Get(HQRPtrSpriteExtra,ptrdisp->Num) ) ; + ScreenXmin = ptrdisp->X + PtrZvExtra[ ptrdisp->Num*8 + 0 ] ; + ScreenYmin = ptrdisp->Y + PtrZvExtra[ ptrdisp->Num*8 + 1 ] ; + ScreenXmax = ScreenXmin + dx ; + ScreenYmax = ScreenYmin + dy ; + + SetClip( ScreenXmin, ScreenYmin, ScreenXmax, ScreenYmax ) ; + AffGraph( 0, ScreenXmin, ScreenYmin, HQR_Get(HQRPtrSpriteExtra,ptrdisp->Num) ) ; + if( ClipXmin <= ClipXmax + AND ClipYmin <= ClipYmax ) + { + AddPhysBox( ClipXmin, ClipYmin, ClipXmax, ClipYmax ) ; + } + break ; + + case INCRUST_CMPT: + + cmpt = ptrdisp->TimerEnd-TimerRef ; + c = BoundRegleTrois( ptrdisp->Info, ptrdisp->Num, 50*2, cmpt-50 ) ; + + strcpy( string, Itoa( c ) ) ; + dx = SizeFont( string ) ; + dy = 48 ; + + ScreenXmin = ptrdisp->X ; + ScreenYmin = ptrdisp->Y - dy/2 ; + ScreenXmax = ScreenXmin + dx ; + ScreenYmax = ScreenYmin + dy ; + + SetClip( ScreenXmin, ScreenYmin, ScreenXmax, ScreenYmax ) ; + CoulFont( 155 ) ; + Font( ScreenXmin, ScreenYmin, string ) ; + + if( ClipXmin <= ClipXmax + AND ClipYmin <= ClipYmax ) + { + AddPhysBox( ClipXmin, ClipYmin, ClipXmax, ClipYmax ) ; + } + break ; + + case INCRUST_OBJ: + { + UBYTE *ptr3do ; + + Box( 10, 10, 69, 69, 0 ) ; + SetClip( 10, 10, 69, 69 ) ; + + ptr3do = HQR_Get( InventoryObj, ptrdisp->Num ) ; + if( HQR_Flag ) + { + PatchObjet( ptr3do ) ; + } + + SetProjection( 40,40, 128,200,200 ) ; + + SetFollowCamera( 0,0,0, 60,0,0, 16000 ) ; + AffObjetIso( 0,0,0, 0,BetaUsedObj+=8,0, ptr3do ) ; + + DrawCadre( 10, 10, 69, 69 ) ; + AddPhysBox( 10, 10, 69, 69 ) ; + + Init3DGame() ; + } + break ; + } + } + UnSetClip() ; + +/*------------------------------------------------------------------------*/ +/* flip boxes */ + + if( FlagVsync ) Vsync() ; + if( FlagMCGA ) + { + CopyBlockPhysMCGA( xmin, ymin, xmax, ymax ) ; + FlipOptList() ; + if( flagflip ) RestoreTimer() ; + } + else + { + if( !flagflip ) + { + FlipBoxes() ; /* Flip Log vers Phys */ + } + else + { + Flip() ; + FlipOptList() ; + RestoreTimer() ; + } + } + if( FlagFade ) + { + if( FlagPalettePcx ) FadeToPal( PalettePcx ) ; + else FadeToPal( PtrPal ) ; + FlagFade = FALSE ; + } +} +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ßßßÛß ÛßßßÛ ÛÛÜ Û Ûßßßß ÛßßßÜ Ûßßßß Ûßßßß + ÜÛ ÛÛ Û ÛÛßÛÛ ÛÛßß ÛÛ Û ÛÛßß ÛÛ + ßßßßß ßßßßß ßß ß ßßßßß ßßßßß ßßßß ßßßßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void CheckZoneSce( T_OBJET *ptrobj, WORD numobj ) +{ + WORD n ; + T_ZONE *ptrz ; + WORD x,y,z ; + WORD flaggrm = FALSE ; + + x = ptrobj->PosObjX ; + y = ptrobj->PosObjY ; + z = ptrobj->PosObjZ ; + + ptrz = ListZone ; + + ptrobj->ZoneSce = -1 ; + + if( numobj == NUM_PERSO ) + { + FlagClimbing = FALSE ; + } + + for( n=0; n= ptrz->X0 + AND x <= ptrz->X1 + AND y >= ptrz->Y0 + AND y <= ptrz->Y1 + AND z >= ptrz->Z0 + AND z <= ptrz->Z1 ) + { + // si type test angle + + switch( ptrz->Type ) + { + case 0: // change cube perso + if( numobj == NUM_PERSO ) + { + // protection meurt dans un autre cube + if( ptrobj->LifePoint > 0 ) + { + NewCube = ptrz->Num ; + NewPosX = ptrobj->PosObjX - ptrz->X0 + ptrz->Info0 ; + NewPosY = ptrobj->PosObjY - ptrz->Y0 + ptrz->Info1 ; + NewPosZ = ptrobj->PosObjZ - ptrz->Z0 + ptrz->Info2 ; + FlagChgCube = 1 ; + return ; + } + } + break ; + + case 1: // set pos camera + if( numobj == NumObjFollow ) + { + // signale pos forc‚e + CameraZone = TRUE ; + + if( StartXCube != ptrz->Info0 + OR StartYCube != ptrz->Info1 + OR StartZCube != ptrz->Info2 ) + { + StartXCube = ptrz->Info0 ; + StartYCube = ptrz->Info1 ; + StartZCube = ptrz->Info2 ; + FirstTime = TRUE ; + } + } + break ; + + case 2: // zone scenarique + ptrobj->ZoneSce = ptrz->Num ; + break ; + + case 3: // zone grm + if( numobj == NumObjFollow ) + { + flaggrm = TRUE ; + if( ZoneGrm != ptrz->Num ) + { + if( ZoneGrm != -1 ) + CopyMapToCube() ; + ZoneGrm = ptrz->Num ; + IndexGrm = n ; + SaveTimer() ; + IncrustGrm( ptrz->Num ) ; + RestoreTimer() ; + } + } + break ; + + case 4: // zone giver + if( numobj == NUM_PERSO ) + { + if( ActionNormal ) + { + InitAnim( GEN_ANIM_ACTION, ANIM_THEN, GEN_ANIM_RIEN, NUM_PERSO ) ; + ZoneGiveExtraBonus( ptrz ) ; + } + } + break ; + + case 5: // zone message + if( numobj == NUM_PERSO ) + { + if( ActionNormal ) + { + SaveTimer() ; + TestRestoreModeSVGA( TRUE ) ; + TestCoulDial( ptrz->Info0 ) ; +#ifdef CDROM + NumObjSpeak = NUM_PERSO ; +#endif + Dial( ptrz->Num ) ; + RestoreTimer() ; + + AffScene(TRUE) ; + + WaitReleaseSpace() ; + } + } + break ; + + case 6: // echelle + if( (numobj==NUM_PERSO) AND (Comportement!=C_PROTOPACK) ) + { + if( ( ptrobj->GenAnim == GEN_ANIM_MARCHE ) + OR ( ptrobj->GenAnim == GEN_ANIM_ECHELLE ) + OR ( ptrobj->GenAnim == GEN_ANIM_MONTE ) ) + { + Rotate( ptrobj->Xmin, ptrobj->Zmin, ptrobj->Beta + 896 + 512 ) ; + X0 += Nxw ; + Y0 += Nzw ; + + if( (X0 >= 0) AND (Y0 >= 0) + AND (X0 <= 63*SIZE_BRICK_XZ) AND (Y0 <= 63*SIZE_BRICK_XZ) + AND (WorldColBrick( X0, ptrobj->PosObjY+256, Y0 ) != 0) ) + { + FlagClimbing = TRUE ; + + if( ptrobj->PosObjY >= ((ptrz->Y0+ptrz->Y1)/2) ) + { + InitAnim( GEN_ANIM_ECHELLE, ANIM_ALL_THEN, GEN_ANIM_RIEN, numobj ) ; + } + else + { + InitAnim( GEN_ANIM_MONTE, ANIM_REPEAT, NO_ANIM, numobj ) ; + } + } + } + } + break ; + } + } + ptrz++ ; + } + + if( flaggrm == FALSE + AND numobj == NumObjFollow + AND ZoneGrm != -1 ) + { + IndexGrm = ZoneGrm = -1 ; + CopyMapToCube() ; + FirstTime = TRUE; + } +} + +#ifdef DEBUG_TOOLS +void ClearZoneSce() +{ + WORD n ; + T_ZONE *ptrz ; + + ptrz = ListZone ; + + for( n=0; nType ) + { + case 4: // zone giver + + ptrz->Info2 = 0 ; + break ; + } + ptrz++ ; + } +} +#endif diff --git a/SOURCES/OBJECT.DEF b/SOURCES/OBJECT.DEF new file mode 100644 index 0000000..34096a5 --- /dev/null +++ b/SOURCES/OBJECT.DEF @@ -0,0 +1,28 @@ +extern void InitObject(short ); +extern void StartInitObj(short ); +extern void StartInitAllObjs(void); +extern void LoadFicPerso(void); +extern void InitPerso(void); +extern void SetComportement(short ); +extern void RestartPerso(void); +extern void ClearFlagsCube(void); +extern void ClearScene(void); +extern void ChangeCube(void); +extern void HitObj(short ,short ,short ,short ); +extern long CheckZvOnZv(short ,short ); +extern short CheckObjCol(short ); +extern void CheckCarrier(short ); +extern long CheckValidObjPos(short ); +extern void InitBody(unsigned char ,short ); +extern void InitSprite(short ,short ); +extern short InitAnim(unsigned char ,short ,unsigned char ,short ); +extern void ReajustPos(unsigned char ); +extern void ReceptionObj(void); +extern void DoCornerReajust(short ,short ,short ,short ); +extern void DoCornerReajustTwinkel(short ,short ,short ,short ); +extern void DoAnim(short ); +extern void ManualRealAngle(T_OBJET *); +extern void ClearRealAngle(T_OBJET *); +extern void DoDir(short ); +extern void AffScene(long ); +extern void CheckZoneSce(T_OBJET *,short ); diff --git a/SOURCES/PERSO.C b/SOURCES/PERSO.C new file mode 100644 index 0000000..025e950 --- /dev/null +++ b/SOURCES/PERSO.C @@ -0,0 +1,1478 @@ +#include "c_extern.h" + +#include + +extern char *Version ; + +extern LONG MixMusic ; +extern LONG MaxVolume ; // Max Music Volume if no Mixer +extern UWORD GameVolumeMenu[] ; +extern UWORD GameOptionMenu[] ; +extern LONG FlecheForcee ; +#ifdef CDROM +extern LONG FlagDisplayText ; +extern UBYTE *BufMemoSeek ; +#endif + +ULONG SpriteMem, SampleMem, AnimMem ; + +//WORD Lig=0 ; +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +#ifdef DEBUG_TOOLS +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +ULONG MemoMemory ; +ULONG MemoDosMemory ; +ULONG MemoMinDosMemory ; +ULONG UsedHQMemory = 0 ; + +UBYTE NamePcxSave[256] ; +WORD NumPcxSave = 0 ; + +WORD MinNbf = 1000 ; +WORD MaxNbf = 0 ; + +LONG NbNbf = 0 ; +LONG TotalNbf = 0 ; + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void AffDebugMenu() +{ + LONG flag ; + LONG xm, ym ; + WORD select ; + WORD lig = 0 ; + + CoulText( 15, 0 ) ; + + Text( 0,lig+=9, "%FIsland: %d", Island ) ; + Text( 0,lig+=9, "%FCube: %d", NumCube ) ; + Text( 0,lig+=9, "%FChapter: %d", Chapitre ) ; + + Text( 0,lig+=10,"%FSceZoom: %d", SceZoom ) ; + Text( 0,lig+=9, "%FFlagCredits: %d", FlagCredits ) ; + Text( 0,lig+=9, "%FCmptMemoTimer: %d", CmptMemoTimerRef ) ; + Text( 0,lig+=9, "%FNb Objs: %d", NbObjets ) ; + Text( 0,lig+=9, "%FNb Bodys: %d", NbBodys ) ; + Text( 0,lig+=9, "%FNb Zones: %d", NbZones ) ; + Text( 0,lig+=9, "%fNb Tracks: %d", NbBrickTrack ) ; + + Text( 0,lig+=10,"%FNbFPS: %d", NbFramePerSecond ) ; + Text( 0,lig+=9, "%FFree(K): %d", ((LONG)Malloc(-1L))/1024 ) ; + + Text( 0,lig+=10, "%FMemory at start: %d Ko", MemoMemory/1024 ) ; + Text( 0,lig+=9, "%FSize HQM_Memory: %d Ko", Size_HQM_Memory/1024 ) ; + Text( 0,lig+=9, "%FMax Used HQM_Memory: %d Ko", UsedHQMemory/1024 ) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void CheckSavePcx() +{ + if( Key == K_F9 ) + { + CopyScreen( Log, Screen ) ; + strcpy( NamePcxSave, "LBA" ) ; + strcat( NamePcxSave, itoa( NumPcxSave," ",10 ) ) ; + AddExt( NamePcxSave, ".PCX" ) ; + + Save_Pcx( NamePcxSave, Screen, PtrPal ) ; + + NumPcxSave++ ; + while( Key ) ; + FirstTime = TRUE ; + } +} + +#endif + + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + Û ÛÛÜ Û Û ßßÛßß ÛÛßßß + ÛÛ ÛÛßÛÛ ÛÛ ÛÛ ßßßßÛ + ßß ßß ß ßß ßß ßßßßß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +void InitGameLists() +{ + LONG i ; + + ClearExtra() ; + + for( i=0; i 500 ) Vsync() ; + + +/* CoulText( 15, 0 ) ; + Text( 0,0, "%FTimerRef: %l", TimerRef ) ; */ + +/*-------------------------------------------------------------------------*/ + if( NewCube != -1 ) + { + ChangeCube() ; + } + +#ifdef DEMO + if( NumCube == 3 ) return 2 ; +#endif + +/*-------------------------------------------------------------------------*/ + + LastFire = MyFire ; + + MyJoy = Joy ; + MyFire = Fire ; //& ~32 ; + MyKey = Key ; + +/*-------------------------------------------------------------------------*/ +/* gestion clavier */ /* tools */ + +#ifdef DEBUG_TOOLS + + if( MyKey == K_C ) + { + ClearZoneSce() ; + } + + if( MyKey == K_T ) + { + TimerRef += 10 ; + } + + if( MyKey == K_I ) + { + AffDebugMenu() ; + } + + if( MyKey == K_F11 ) + { + AsciiMode ^= 1 ; + while( Key ) ; + } + + if( MyKey == K_W ) + { + if( MagicBall != -1 ) + { + ListObjet[NUM_PERSO].PosObjX = ListExtra[MagicBall].PosX ; + ListObjet[NUM_PERSO].PosObjY = ListExtra[MagicBall].PosY ; + ListObjet[NUM_PERSO].PosObjZ = ListExtra[MagicBall].PosZ ; + } + } + + CheckSavePcx() ; + +//CoulText( 15,0 ) ; +//Text( 0,472, "%F%l ", (LONG)NbFramePerSecond ) ; + +#endif // debug tools + +/*-------------------------------------------------------------------------*/ +/* gestion clavier */ /* game */ + + if( FlagCredits ) + { +#ifdef CDROM + if( GetMusicCD() != 8 ) PlayCdTrack( 8 ) ; +#else + if( !IsMidiPlaying() ) PlayMidiFile( 9 ) ; +#endif + if( Key OR Joy OR Fire ) + { +// FlagCredits = FALSE ; + break ; + } + } + else + if( !FlagFade ) + { + if( (MyKey == K_ESC) + AND (ListObjet[NUM_PERSO].LifePoint > 0) + AND (ListObjet[NUM_PERSO].Body != -1) + AND (!(ListObjet[NUM_PERSO].Flags&INVISIBLE)) + ) + { + // confirmation sortie + TestRestoreModeSVGA( TRUE ) ; + SaveTimer() ; + + if( QuitMenu() ) + { + RestoreTimer() ; + AffScene( TRUE ) ; + + SaveTimer() ; + SaveGame() ; + RestoreTimer() ; + break ; + } + else + { + RestoreTimer() ; + AffScene( TRUE ) ; + } + } + + if( MyKey == K_F6 ) // options menu + { + LONG memoflagspeak = FlagSpeak ; + + SaveTimer() ; + TestRestoreModeSVGA( TRUE ) ; + HQ_StopSample(); + GameOptionMenu[5] = 15 ; // retour au jeu + + FlagSpeak = FALSE ; + InitDial( 0 ) ; // SYS + + OptionsMenu() ; + + FlagSpeak = memoflagspeak ; + InitDial( START_FILE_ISLAND+Island ) ; + + // rustine scenarique pour twinsun cafe et credits + + if( NumCube == 80 ) + { + if( ListFlagGame[90] == 1 ) + { +#ifdef CDROM + PlayCdTrack( 8 ) ; // funkyrock +#endif + } + else + { + PlayMusic( CubeJingle ) ; + } + } + else + { + PlayMusic( CubeJingle ) ; + } + + RestoreTimer() ; + AffScene( TRUE ) ; + } + + InventoryAction = -1 ; + if( (MyFire & F_SHIFT) + AND (ListObjet[NUM_PERSO].Body != -1) + AND (ListObjet[NUM_PERSO].Move == MOVE_MANUAL) ) + { + SaveTimer() ; + TestRestoreModeSVGA( TRUE ) ; + Inventory() ; + switch( InventoryAction ) + { + case 0: // holomap + HoloMap() ; + FlagFade = TRUE ; + break ; + + case 1: // balle magique + if( Weapon == 1 ) + { + InitBody( GEN_BODY_NORMAL, NUM_PERSO ) ; + } + Weapon = 0 ; + break ; + + case 2: // sabre magique + if( ListObjet[NUM_PERSO].GenBody != GEN_BODY_SABRE ) + { + if( Comportement == C_PROTOPACK ) + { + SetComportement( C_NORMAL ) ; + } + // anim degaine sabre + InitBody( GEN_BODY_SABRE, NUM_PERSO ) ; + InitAnim( GEN_ANIM_DEGAINE, ANIM_THEN, GEN_ANIM_RIEN, NUM_PERSO ) ; + } + Weapon = 1 ; + break ; + + case 5: // livre de b– + + FadeToBlack( PtrPal ) ; + Load_HQR( PATH_RESSOURCE"ress.hqr", Screen, RESS_TWINSUN_PCR ) ; + CopyScreen( Screen, Log ) ; + Load_HQR( PATH_RESSOURCE"ress.hqr", PalettePcx, RESS_TWINSUN_PAL ) ; + Flip() ; + FadeToPal( PalettePcx ) ; + + InitDial( 2 ) ; + + FlagMessageShade = FALSE ; + BigWinDial() ; + TestCoulDial( 15 ) ; +#ifdef CDROM + memoflagdisplaytext = FlagDisplayText ; + FlagDisplayText = TRUE ; +#endif + Dial( 161 ) ; +#ifdef CDROM + FlagDisplayText = memoflagdisplaytext ; +#endif + NormalWinDial() ; + FlagMessageShade = TRUE ; + InitDial( START_FILE_ISLAND+Island ) ; + FadeToBlack( PalettePcx ) ; + Cls() ; + Flip() ; + FlagFade = TRUE ; + break ; + + case 12: // protopack + if( ListFlagGame[FLAG_MEDAILLON] ) + { + ListObjet[NUM_PERSO].GenBody = GEN_BODY_NORMAL ; // avec m‚daillon + } + else + { + ListObjet[NUM_PERSO].GenBody = GEN_BODY_TUNIQUE ; // sans m‚daillon + } + if( Comportement == C_PROTOPACK ) + { + SetComportement( C_NORMAL ) ; + } + else + { + SetComportement( C_PROTOPACK ) ; + } + Weapon = 0 ; // balle magique + break ; + + case 14: // meca pingouin + ptrobj = &ListObjet[NumPingouin] ; + + Rotate( 0,800, ListObjet[NUM_PERSO].Beta ) ; + + ptrobj->PosObjX = ListObjet[NUM_PERSO].PosObjX + X0 ; + ptrobj->PosObjY = ListObjet[NUM_PERSO].PosObjY ; + ptrobj->PosObjZ = ListObjet[NUM_PERSO].PosObjZ + Y0 ; + + ptrobj->Beta = ListObjet[NUM_PERSO].Beta ; + + if( CheckValidObjPos( NumPingouin ) ) + { + ptrobj->LifePoint = 50 ; + ptrobj->GenBody = NO_BODY ; + InitBody( GEN_BODY_NORMAL, NumPingouin ) ; + + ptrobj->WorkFlags &= ~OBJ_DEAD ; + ptrobj->Col = 0 ; + + InitRealAngleConst( ptrobj->Beta, + ptrobj->Beta, + ptrobj->SRot, + &ptrobj->RealAngle ) ; + + *(ULONG*)(&ptrobj->Info) = TimerRef + 30 * 50 ; + + ListFlagGame[FLAG_MECA_PINGOUIN] = 0 ; // a plus + } + + break ; + + case 27: // four leaf clover + if( ListObjet[NUM_PERSO].LifePoint < 50 ) + { + if( NbFourLeafClover != 0 ) + { + NbFourLeafClover-- ; + + MagicPoint = MagicLevel * 20 ; + ListObjet[NUM_PERSO].LifePoint = 50 ; + + // mettre aff des barres de point + InitIncrustDisp( INCRUST_OBJ, + FLAG_CLOVER, + 0, 0, + 0, 0, 3 ) ; + } + } + break ; + + case 26: // liste emplacements + { + LONG memoflagspeak = FlagSpeak ; + + RestoreTimer() ; + AffScene( TRUE ) ; + SaveTimer() ; + FlagSpeak = FALSE ; + InitDial( 2 ) ; + BigWinDial() ; + TestCoulDial( 15 ) ; + Dial( 162 ) ; + NormalWinDial() ; + FlagSpeak = memoflagspeak ; + InitDial( START_FILE_ISLAND+Island ) ; + } + break ; + } + RestoreTimer() ; + AffScene( TRUE ) ; + } + + if( (MyFire & F_CTRL) + AND (ListObjet[NUM_PERSO].Body != -1) + AND (ListObjet[NUM_PERSO].Move == MOVE_MANUAL) ) + { + SaveTimer() ; + TestRestoreModeSVGA( TRUE ) ; + MenuComportement() ; + RestoreTimer() ; + AffScene(TRUE) ; + } + + if( (MyKey >= K_F1) AND (MyKey <= K_F4) + AND (ListObjet[NUM_PERSO].Body != -1) + AND (ListObjet[NUM_PERSO].Move == MOVE_MANUAL) ) + { + SaveTimer() ; + TestRestoreModeSVGA( TRUE ) ; + SetComportement( C_NORMAL + MyKey - K_F1 ) ; + MenuComportement() ; + RestoreTimer() ; + AffScene(TRUE) ; + } + + if( MyFire & F_RETURN ) /* recentre sur perso */ + { + if( !CameraZone ) /* si pas camera forc‚e */ + { + StartXCube = ((ListObjet[NumObjFollow].PosObjX+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + StartYCube = ((ListObjet[NumObjFollow].PosObjY+SIZE_BRICK_Y)/SIZE_BRICK_Y) ; + StartZCube = ((ListObjet[NumObjFollow].PosObjZ+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + FirstTime = TRUE ; + } + } + + if( (MyKey == K_H) + AND (ListFlagGame[FLAG_HOLOMAP] == 1) + AND (ListFlagGame[FLAG_CONSIGNE] == 0) ) + { + SaveTimer() ; + TestRestoreModeSVGA( TRUE ) ; + HoloMap() ; + FlagFade = TRUE ; + RestoreTimer() ; + AffScene(TRUE) ; + } + + if( MyKey == K_P ) + { + WavePause() ; + SaveTimer() ; + if( !FlagMCGA ) + { + CoulFont( 15 ) ; + Font( 5,446, "Pause" ) ; + CopyBlockPhys( 5,446,100,479 ) ; + } + while( Key ) ; + while( !Key AND !Joy AND !Fire ) ; + if( !FlagMCGA ) + { + CopyBlock( 5,446,100,479, Screen, 5,446, Log ) ; + CopyBlockPhys( 5,446,100,479 ) ; + } + RestoreTimer() ; + WaveContinue() ; + } + + if( MyKey == K_F5 ) // zoom on/off + { + if( FlagMCGA ^= 1 ) + { + ExtInitMcga() ; + while( Key ) ; + } + else + { + ExtInitSvga() ; + FirstTime = TRUE ; + while( Key ) ; + } + } +/* + if( MyKey == K_B ) + { + if( Wave_Driver_Enable ) + { + if( (SamplesEnable ^= 1) == 0 ) + { + HQ_StopSample() ; + Message( "Samples OFF", TRUE ) ; + } + else + { + Message( "Samples ON", TRUE ) ; + } + } + } +*/ + } // if !flagfade + +/*-------------------------------------------------------------------------*/ +/* gere l'ambiance */ + + /* vitesse de chute propor pour tous les objets */ + StepFalling = GetRealValue( &RealFalling ) ; + if( StepFalling == 0 ) StepFalling = 1 ; + InitRealValue( 0, -256, 5, &RealFalling ) ; + + CameraZone = FALSE ; + + GereAmbiance() ; + +/*-------------------------------------------------------------------------*/ +/* gere les objets */ + + // asm + ptrobj = ListObjet ; + for( i=0; iHitBy = -1 ; + } + + GereExtras() ; + + ptrobj = ListObjet ; + for( i=0; iWorkFlags & OBJ_DEAD ) continue ; + + // test mort d'un objet + + if( ptrobj->LifePoint == 0 ) + { + if( i == NUM_PERSO ) // twinsen + { + InitAnim( GEN_ANIM_MORT, ANIM_SET, GEN_ANIM_RIEN, NUM_PERSO ) ; + ptrobj->Move = NO_MOVE ; + } + else // tout objet + { + // sample specifique mort ? + HQ_3D_MixSample( 37, 0x1000+Rnd(2000)-(2000/2), 1, + ptrobj->PosObjX, ptrobj->PosObjY, ptrobj->PosObjZ ) ; + + // 'explosion' de l'objet +/* InitSpecial( ptrobj->PosObjX, + ptrobj->PosObjY+1000, + ptrobj->PosObjZ, + 2 ) ; +*/ + if( i == NumPingouin ) + { + ExtraExplo( ptrobj->PosObjX, ptrobj->PosObjY, ptrobj->PosObjZ ) ; + } + } + + if( (ptrobj->OptionFlags & EXTRA_MASK) + AND !(ptrobj->OptionFlags & EXTRA_GIVE_NOTHING) ) + { + GiveExtraBonus( ptrobj ) ; + } + } + + DoDir( i ) ; + + ptrobj->OldPosX = ptrobj->PosObjX ; + ptrobj->OldPosY = ptrobj->PosObjY ; + ptrobj->OldPosZ = ptrobj->PosObjZ ; + + if( ptrobj->OffsetTrack != -1 ) + { + DoTrack( i ) ; + } + DoAnim( i ) ; + + if( ptrobj->Flags & CHECK_ZONE ) + { + CheckZoneSce( ptrobj, i ) ; + } + + if( ptrobj->OffsetLife != -1 ) + { + DoLife( i ) ; + } + + if( FlagTheEnd != -1 ) return FlagTheEnd ; // mmm violent + + // test des codes jeu ici ? + + if( ptrobj->Flags & CHECK_CODE_JEU ) + { + ptrobj->CodeJeu = WorldCodeBrick(ptrobj->PosObjX, + ptrobj->PosObjY-1, + ptrobj->PosObjZ ) ; + + if( (ptrobj->CodeJeu & 0xF0) == 0xF0 ) + { + switch( ptrobj->CodeJeu & 0x0F ) + { + case 1: // eau + if( i == NUM_PERSO ) + { + if( (Comportement == C_PROTOPACK) + AND (ptrobj->GenAnim == GEN_ANIM_MARCHE) ) + break ; + + if( !FlagWater ) + { + InitAnim( GEN_ANIM_NOYADE, ANIM_SET, GEN_ANIM_RIEN, NUM_PERSO ) ; + + ProjettePoint( ptrobj->PosObjX, ptrobj->PosObjY, ptrobj->PosObjZ ) ; + FlagWater = Yp ; + + // init clipping Y noyade + } + + ProjettePoint( ptrobj->PosObjX-WorldXCube, + ptrobj->PosObjY-WorldYCube, + ptrobj->PosObjZ-WorldZCube ) ; + FlagWater = Yp ; + + ptrobj->Move = NO_MOVE ; + ptrobj->LifePoint = -1 ; + ptrobj->Flags |= NO_SHADOW ; + } + else // tout objet meurt dans l'eau + { + HQ_3D_MixSample( 37, 0x1000+Rnd(2000)-(2000/2), 1, + ptrobj->PosObjX, ptrobj->PosObjY, ptrobj->PosObjZ ) ; + // 'explosion' de l'objet + + if( (ptrobj->OptionFlags & EXTRA_MASK) + AND !(ptrobj->OptionFlags & EXTRA_GIVE_NOTHING) ) + { + GiveExtraBonus( ptrobj ) ; + } + ptrobj->LifePoint = 0 ; + } + break ; + } + } + } + + + // si apr‚s la vie on … toujours 0 point de vie + // destruction definitive + if( ptrobj->LifePoint <= 0 ) + { + if( i == NUM_PERSO ) + { + if( ptrobj->WorkFlags & ANIM_END ) + { + if( NbFourLeafClover > 0 ) + { + FlagWater = FALSE ; + + // restart + NbFourLeafClover-- ; + + ListObjet[NUM_PERSO].PosObjX = SceneStartX ; + ListObjet[NUM_PERSO].PosObjY = SceneStartY ; + ListObjet[NUM_PERSO].PosObjZ = SceneStartZ ; + + NewCube = NumCube ; + FlagChgCube = 3 ; + + ListObjet[NUM_PERSO].LifePoint = 50 ; + MagicPoint = MagicLevel * 20 ; + + StartXCube = ((ListObjet[NUM_PERSO].PosObjX+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + StartYCube = ((ListObjet[NUM_PERSO].PosObjY+SIZE_BRICK_Y)/SIZE_BRICK_Y) ; + StartZCube = ((ListObjet[NUM_PERSO].PosObjZ+DEMI_BRICK_XZ)/SIZE_BRICK_XZ) ; + + FirstTime = TRUE ; + FlagFade = TRUE ; + goto startloop ; + } + else // game over + { + + NbFourLeafClover = NbCloverBox / 2 ; + ListObjet[NUM_PERSO].LifePoint = 25 ; + MagicPoint = (MagicLevel*20) / 2 ; + Comportement = SaveComportement ; + ListObjet[NUM_PERSO].Beta = SaveBeta ; + + if( GameOverCube != NumCube ) + { + NumCube = GameOverCube ; + SceneStartX = SceneStartY = SceneStartZ = -1 ; // mean use startpos + } + SaveGame() ; + + GameOver() ; + + return 0 ; + } + } + } + else // autre obj + { + CheckCarrier( i ) ; + ptrobj->WorkFlags |= OBJ_DEAD ; + ptrobj->Body = -1 ; + ptrobj->ZoneSce = -1 ; + } + } + + if( NewCube != -1 ) + { + goto startloop ; + } + } + +/* +ptrobj = &ListObjet[ 4 ] ; +CoulText( 15, 0 ) ; + +Text( 10,10, "%F GenAnim: %d ", ptrobj->GenAnim ) ; +Text( 10,20, "%F Anim: %d ", ptrobj->Anim ) ; +Text( 10,30, "%F Frame: %d ", ptrobj->Frame ) ; +Text( 10,40, "%F GenBody: %d ", ptrobj->GenBody ) ; +Text( 10,50, "%F Body: %d ", ptrobj->Body ) ; +Text( 10,60, "%F LabelTrack: %d ", ptrobj->LabelTrack ) ; +Text( 10,70, "%FMemoLabelTrack: %d ", ptrobj->MemoLabelTrack ) ; +*/ + +// Text( 0,110, "%FListFlagGame[134] = %d",ListFlagGame[134] ) ; + + +/*-------------------------------------------------------------------------*/ +/* recentre sur hero (numobjfollow) */ + + if( !CameraZone ) + { + T_OBJET *ptrobj ; + + ptrobj = &ListObjet[ NumObjFollow ] ; + + ProjettePoint( ptrobj->PosObjX-StartXCube*SIZE_BRICK_XZ, + ptrobj->PosObjY-StartYCube*SIZE_BRICK_Y, + ptrobj->PosObjZ-StartZCube*SIZE_BRICK_XZ ) ; + + if( Xp<80 OR Xp>539 OR Yp<80 OR Yp>429 ) + { + xm = (ptrobj->PosObjX+DEMI_BRICK_XZ)/SIZE_BRICK_XZ ; + ym = ptrobj->PosObjY/SIZE_BRICK_Y ; + zm = (ptrobj->PosObjZ+DEMI_BRICK_XZ)/SIZE_BRICK_XZ ; + + StartXCube = xm + ((xm-StartXCube))/2; + StartYCube = ym ; + StartZCube = zm + ((zm-StartZCube))/2; + + if( StartXCube >= SIZE_CUBE_X ) StartXCube = SIZE_CUBE_X - 1 ; + if( StartZCube >= SIZE_CUBE_Z ) StartZCube = SIZE_CUBE_Z - 1 ; + + FirstTime = TRUE ; + } + } + +/*-------------------------------------------------------------------------*/ +/* affiche tout */ + + AffScene( FirstTime ) ; + + FirstTime = FALSE ; + + CmptFrame++ ; + +#ifdef DEBUG_TOOLS + if( NbFramePerSecond < MinNbf ) MinNbf = NbFramePerSecond ; + if( NbFramePerSecond > MaxNbf ) MaxNbf = NbFramePerSecond ; + + TotalNbf += NbFramePerSecond ; + NbNbf++ ; +#endif + } + + return 0 ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛÜ ÜÛ ÛßßßÛ Û ÛÛÜ Û + ÛÛß Û ÛÛßßÛ ÛÛ ÛÛßÛÛ + ßß ß ßß ß ßß ßß ß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void ReadVolumeSettings() +{ + ULONG i ; + LONG BSample, BMusic, BCD, BLine, BMaster ; + +// Test which settings are available + + BSample = BMusic = BCD = BLine = BMaster = 0 ; + + MixerGetInfo( &BSample, + &BMusic, + &BCD, + &BLine, + &BMaster ) ; + + MixMusic = BMusic ; + + // Build the menu + + + GameVolumeMenu[4+2] = 1 ; + GameVolumeMenu[4+3] = 10 ; + + i = 2 ; + if (BSample) + { + GameVolumeMenu[4+i*2] = 2 ; + GameVolumeMenu[4+i*2+1] = 11 ; + i++; + } + if (BCD) + { + GameVolumeMenu[4+i*2] = 3 ; + GameVolumeMenu[4+i*2+1] = 12 ; + i++; + } + if (BLine) + { + GameVolumeMenu[4+i*2] = 4 ; + GameVolumeMenu[4+i*2+1] = 13 ; + i++; + } + if (BMaster) + { + GameVolumeMenu[4+i*2] = 5 ; + GameVolumeMenu[4+i*2+1] = 14 ; + i++; + } + GameVolumeMenu[4+i*2] = 0 ; + GameVolumeMenu[4+i*2+1] = 16 ; + + GameVolumeMenu[1] = i+1; + +// Read mixer settings + + MixerGetVolume( &SampleVolume, + &MusicVolume, + &CDVolume, + &LineVolume, + &MasterVolume ) ; + +// Read config file + + Def_ReadValue2( PathConfigFile, "WaveVolume", &SampleVolume ) ; + Def_ReadValue2( PathConfigFile, "MusicVolume", &MusicVolume ) ; + Def_ReadValue2( PathConfigFile, "CDVolume", &CDVolume ) ; + Def_ReadValue2( PathConfigFile, "LineVolume", &LineVolume ) ; + Def_ReadValue2( PathConfigFile, "MasterVolume", &MasterVolume ) ; + + +// Reset the mixer to correct values + + if (!MixMusic) + { + MaxVolume = MusicVolume ; + VolumeMidi( 100 ) ; + } + + MixerChangeVolume( SampleVolume, + MusicVolume, + CDVolume, + LineVolume, + MasterVolume ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void WriteVolumeSettings() +{ + Def_WriteValue( PathConfigFile, "WaveVolume", SampleVolume ) ; + Def_WriteValue( PathConfigFile, "MusicVolume", MusicVolume ) ; + Def_WriteValue( PathConfigFile, "CDVolume", CDVolume ) ; + Def_WriteValue( PathConfigFile, "LineVolume", LineVolume ) ; + Def_WriteValue( PathConfigFile, "MasterVolume", MasterVolume ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void InitProgram() +{ + InitAdelineSystem( "LBA.CFG", INIT_SVGA + + INIT_WAVE + + INIT_MIXER + + INIT_MIDI ) ; + +#ifdef TRACE + AsciiMode = TRUE ; +#endif + +#ifdef CDROM + InitVoiceFile() ; +#endif +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void TheEnd( WORD num, UBYTE *error ) +{ +#ifdef DEBUG_TOOLS + MemoMinDosMemory = (ULONG)DosMalloc( -1, NULL ) ;// Dos memory after inits +#endif + +#ifdef CDROM + ClearVoiceFile() ; + ClearCDR() ; +#endif + ClearAdelineSystem() ; + + printf( Version ) ; /* dans version.c */ + +#ifdef DEBUG_TOOLS + printf( "* Start Extended Memory was %ld\n", MemoMemory ) ; + printf( "* Start Dos Memory was %ld\n", MemoDosMemory ) ; + printf( "* Min Dos Memory was %ld\n", MemoMinDosMemory ) ; + printf( "* HQR Sprite: %ld\n", SpriteMem ) ; + printf( " Sample: %ld\n", SampleMem ) ; + printf( " Anim: %ld\n", AnimMem ) ; + + printf( "* Size HQM Memory was %ld\n", Size_HQM_Memory ) ; + printf( "* Max Used HQM memory was %ld\n", UsedHQMemory ) ; +#endif + switch( num ) + { + case ERROR_FILE_NOT_FOUND: + printf( "File not found: %s\n", error ) ; + break ; + + case NAME_NOT_FOUND: + printf( "Critical error: ident name not found: %s\n", error ) ; + break ; + + case NOT_ENOUGH_MEM: + printf( "Not Enough Memory: %s (SEE README.TXT)\n", error ) ; + break ; + + case PROGRAM_OK: +#ifdef DEBUG_TOOLS + if( NbNbf ) + { + printf( "* Frame speed status:\n" ) ; +// printf( " Minimal frame rate occured: %d\n", MinNbf ) ; + printf( " Maximal frame rate occured: %d\n", MaxNbf ) ; +// printf( " number of frame is %f\n", NbNbf ) ; +// printf( " (total of frame's NbFramePerSecon is %f )\n", TotalNbf ) ; + printf( " Average frame rate was %d\n", TotalNbf/NbNbf ) ; + printf( "%s\n", error ) ; + } +#endif + printf( "%s\n", error ) ; + printf( "\nOK.\n" ) ; + break ; + } + RestoreDiskEnv() ; + exit( 0 ) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +int __far Critical_Error_Handler( unsigned deverr, + unsigned errcode, + unsigned far *devhdr ) +{ + return( _HARDERR_RETRY ) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +#ifdef DEBUG_TOOLS +void Message( UBYTE *mess, WORD flag ) +{ + WORD x ; + + CoulText( 15, 0 ) ; + PalOne( 15, 255, 255, 255 ) ; + x = (strlen(mess)*8)/2 ; + MemoClip() ; + + Text( 320-x,236, "%s", mess ) ; + Rect( 320-x-4, 234, 320+x+4, 248, 15 ) ; + CopyBlockPhys( 320-x-4, 234, 320+x+4, 248 ) ; + + if( flag ) + { + while( Key OR Joy OR Fire ) ; + while( !Key AND !Joy AND !Fire ) ; + } + RestoreClip() ; +} +#else +void Message( UBYTE *mess, WORD flag ) +{ +} +#endif + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + +void main( int argc, UBYTE *argv[] ) +{ + WORD n ; + ULONG memory ; + ULONG memotimer ; + + _harderr_( Critical_Error_Handler ) ; + +#ifdef DEBUG_TOOLS + MemoMemory = (ULONG)Malloc( -1 ) ; // memory at start + MemoDosMemory = (ULONG)DosMalloc( -1, NULL ) ;// Dos memory at start +#endif + + GetDiskEnv( argv[0] ) ; /* org path program path... */ + + InitProgram() ; /* init graphmode timer ... */ + +// infos from lba.cfg + + ReadVolumeSettings() ; + + Version_US = Def_ReadValue( "setup.lst", "Version_US" ) ; + + InitLanguage() ; // multilangue + +// d‚clarations HQR ressource + + if( Midi_Driver_Enable ) + { + if( MidiFM ) + { + HQR_Midi = HQR_Init_Ressource( + PATH_RESSOURCE"midi_sb.hqr", +// ATTENTION size du plus gros xmi + 32000, + 2 ) ; + } + else + { + HQR_Midi = HQR_Init_Ressource( + PATH_RESSOURCE"midi_mi.hqr", +// ATTENTION size du plus gros xmi + 32000, + 2 ) ; + } + + if( !HQR_Midi ) + { + Message( "HQR_Midi not enough memory", TRUE ) ; + Midi_Driver_Enable = FALSE ; + } + +// InitPathMidiSampleFile( PATH_RESSOURCE ) ; + } + +// presentation + + Screen = Malloc( 640*480 + 500 ) ; // + decomp marge + if( !Screen ) TheEnd( NOT_ENOUGH_MEM, "Screen" ) ; + +#ifndef DEBUG_TOOLS + +// logo adeline + AdelineLogo() ; + +// pause logo + memotimer = TimerRef ; + while( TimerRef < (memotimer+50*4) ) ; +#endif + +// check cd rom + +#ifdef DEMO + FlaFromCD = TRUE ; // fla sur HD + strcpy( PathFla, "" ) ; // version demo fla in current dir +#else + +#ifdef CDROM + if( InitCDR( "CD_LBA" ) ) + { + UBYTE *drive = "D:" ; + + // cherche un fichier pour version preview + + drive[0] = 'A' + DriveCDR ; + strcpy( PathFla, drive ) ; + strcat( PathFla, "\\LBA\\FLA\\" ) ; + } + else TheEnd(PROGRAM_OK, "No CD") ; + + if ( ProgDrive[0]-'A' == DriveCDR )// A=0 , B=1 etc. + TheEnd(PROGRAM_OK, "Type INSTALL") ; + +#else + strcpy( PathFla, "FLA\\" ) ; // version cdrom sur hd (fla only) +#endif + +#endif + +// divers malloc + + BufSpeak = DosMalloc( 256*1024 + 34, NULL ) ; + if( !BufSpeak ) TheEnd( NOT_ENOUGH_MEM, "BufSpeak (Dos Memory)" ) ; + +#ifdef CDROM + BufMemoSeek = SmartMalloc( 2048L ) ; + if( !BufMemoSeek ) TheEnd( NOT_ENOUGH_MEM, "BufMemoSeek" ) ; +#endif + BufText = SmartMalloc( 25000L ) ; + if( !BufText ) TheEnd( NOT_ENOUGH_MEM, "BufText" ) ; + + BufOrder = SmartMalloc( 1024L ) ; + if( !BufOrder ) TheEnd( NOT_ENOUGH_MEM, "BufOrder" ) ; + + + PtrBufferAnim = BufferAnim = SmartMalloc( 5000L ) ; + if( !BufferAnim ) TheEnd( NOT_ENOUGH_MEM, "Buffer Anim" ) ; + + InitBufferCube() ; + + InventoryObj = HQR_Init_Ressource( PATH_RESSOURCE"invobj.hqr", 20000, 30 ) ; + if( !InventoryObj ) TheEnd( NOT_ENOUGH_MEM, "HQR Inventory" ) ; + + if( !HQM_Init_Memory( 400000 ) ) + { + TheEnd( NOT_ENOUGH_MEM, "HQMemory" ) ; + } + +// load ressources diverses + + PtrPal = LoadMalloc_HQR( PATH_RESSOURCE"ress.hqr", RESS_PAL ) ; + BufferShadow = LoadMalloc_HQR( PATH_RESSOURCE"ress.hqr", RESS_SHADOW_GPH ) ; + PtrZvExtra = LoadMalloc_HQR( PATH_RESSOURCE"ress.hqr", RESS_GOODIES_GPC ) ; + LbaFont = LoadMalloc_HQR( PATH_RESSOURCE"ress.hqr", RESS_FONT_GPM ) ; + if( !LbaFont ) TheEnd( NOT_ENOUGH_MEM, "LbaFont" ) ; + + SetFont( LbaFont, 2, 8 ) ; + CoulFont( 14 ) ; + CoulDial( 136, 143, 2 ) ; + +// buffers variables en fonctions de la m‚moire dispo + +// Message( Itoa( Malloc(-1) ), TRUE ) ; + + memory = (ULONG)Malloc( -1 ) ; + + SpriteMem = (memory/8) ; + SampleMem = (memory/8)*4 ; + AnimMem = (memory/8)*2 ; + + if( SpriteMem < 50000 ) SpriteMem = 50000 ; + if( SampleMem < 200000 ) SampleMem = 200000 ; + if( AnimMem < 100000 ) AnimMem = 100000 ; + + if( SpriteMem > 400000 ) SpriteMem = 400000 ; + if( SampleMem > 4500000 ) SampleMem = 4500000 ; + if( AnimMem > 300000 ) AnimMem = 300000 ; + +// buffer sprites + + HQRPtrSpriteExtra = HQR_Init_Ressource( + PATH_RESSOURCE"sprites.hqr", + SpriteMem, + SpriteMem/1000 ) ; + + if( !HQRPtrSpriteExtra ) TheEnd( NOT_ENOUGH_MEM, "HQRPtrSpriteExtra" ) ; + +// buffer samples + + if( Wave_Driver_Enable ) + { + // d‚clare ressource samples buffer + HQR_Samples = HQR_Init_Ressource( + PATH_RESSOURCE"samples.hqr", + SampleMem, + SampleMem/5000 ) ; + + SamplesEnable = TRUE ; + + if( !HQR_Samples ) + { + Message( "HQR_Samples not enough memory", TRUE ) ; + Wave_Driver_Enable = FALSE ; + SamplesEnable = FALSE ; + } + } + +// buffer animations + + HQR_Anims = HQR_Init_Ressource( + PATH_RESSOURCE"Anim.hqr", + AnimMem, + AnimMem/800 ) ; + + if( !HQR_Anims ) + { + TheEnd( NOT_ENOUGH_MEM, "HQR_Anims" ) ; + } + + +#ifndef DEBUG_TOOLS +// bumper + FadeToBlack( PalettePcx ) ; + + if( Version_US ) RessPict( RESS_BUMPER_PCR ) ; + else RessPict( RESS_BUMPER2_PCR ) ; + + TimerPause( 4 ) ; + FadeToBlack( PalettePcx ) ; + +// logo EA + + RessPict( RESS_BUMPER_EA_PCR ) ; + TimerPause( 2 ) ; + FadeToBlack( PalettePcx ) ; + +// FLA intro + + PlayAnimFla( "DRAGON3" ) ; +#endif + +// main game menu + +// FadeToBlack( PalettePcx ) ; + + Load_HQR( PATH_RESSOURCE"ress.hqr", Screen, RESS_MENU_PCR ) ; + CopyScreen( Screen, Log ) ; + Flip() ; + FadeToPal( PtrPal ) ; + + MainGameMenu() ; + + TheEnd( PROGRAM_OK, "" ) ; +} + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ + + + + + + diff --git a/SOURCES/PERSO.DEF b/SOURCES/PERSO.DEF new file mode 100644 index 0000000..997cae5 --- /dev/null +++ b/SOURCES/PERSO.DEF @@ -0,0 +1,11 @@ +extern void InitGameLists(void); +extern void InitGame(int ,unsigned char **); +extern void Introduction(void); +extern long MainLoop(void); +extern void ReadVolumeSettings(void); +extern void WriteVolumeSettings(void); +extern void InitProgram(void); +extern void TheEnd(short ,unsigned char *); +extern int __far Critical_Error_Handler(unsigned int ,unsigned int ,unsigned int __far *); +extern void Message(unsigned char *,short ); +extern void main(int ,unsigned char **); diff --git a/SOURCES/PLAYFLA.C b/SOURCES/PLAYFLA.C new file mode 100644 index 0000000..4d6263e --- /dev/null +++ b/SOURCES/PLAYFLA.C @@ -0,0 +1,703 @@ +// ************************************************************** +// * P L A Y F L A . C * +// * (c) Adeline 1994 * +// ************************************************************** +#include "c_extern.h" + +typedef struct { ULONG SizeFile ; + ULONG CompressedSizeFile ; + WORD CompressMethod ; /* 0 stored */ + /* 1 LZS */ + } T_HEADER ; + +/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ* + ÛßßßÛ Û ÛßßßÛ Û Üß Ûßßßß Û ÛßßßÛ + ÛÛßßß ÛÛ ÛÛßßÛ ÛÛß ÛÛßß ÛÛ ÛÛßßÛ + ßß ßßßßß ßß ß ßß ßß ßßßßß ßß ß + *ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +#define FLI 2 +#define FLA 3 +#define X_POS_MENU_PRINCIPAL 480 +#define Y_POS_MENU_PRINCIPAL 10 +#define X_POS_MENU_STORYBOARD 0 +#define Y_POS_MENU_STORYBOARD 335 + +// Define pour les fichiers format FLI +#define FLI_COLOR 11 +#define FLI_LC 12 +#define FLI_BLACK 13 +#define FLI_BRUN 15 +#define FLI_COPY 16 + +// Structures utilis‚es pour les fichiers format FLI +typedef struct + { + LONG size ; + UWORD type ;/* = FLIH_MAGIC */ + UWORD frame_count ; + UWORD width ; + UWORD height ; + UWORD bits_a_pixel ; + WORD flags ; + WORD speed ; + LONG next_head ; + LONG frames_in_table ; + WORD file ; + LONG frame1_off ; + LONG strokes ; + LONG session ; + BYTE reserved[88] ; + } T_HEADER_FLI ; + +typedef struct + { + ULONG size ; + UWORD typedata ; + UBYTE image[] ; + } T_HEADER_IMAGE ; + +typedef struct + { + ULONG offset ; + UWORD signature ; + UWORD nbpasse ; + UBYTE reserved[6+2] ; + } T_HEADER_SUB ; + +// Define pour les fichiers format FLA +#define VERSION "V1.3" +#define FLA_PALETTE 1 +#define FLA_INFO 2 +#define FLA_SAMPLE 3 +#define FLA_SAMPLE_BALANCE 4 +#define FLA_SAMPLE_STOP 5 +#define FLA_LC 6 +#define FLA_BLACK 7 +#define FLA_BRUN 8 +#define FLA_COPY 9 + +// Structures utilis‚es pour les fichiers format FLA +typedef struct // entete de fichier FLA + { + char Version[5] ; + ULONG NbFrame ; + UBYTE CadenceAnimation; + UWORD ResolutionX ; + UWORD ResolutionY ; + } T_HEADER_FLA; + +typedef struct // header de passe + { + UBYTE NbPasse ; + ULONG OffsetFrameSuivante ; + } T_HEADER_FLA_PASSE; + +typedef struct // structure d'un type de passe + { + UBYTE Type; + UWORD OffsetPasseSuivante; + } T_FLA_TYPE; + +typedef struct // structure d'un element d'une liste de son + { + WORD NbSample; + WORD OffsetFrameOne; + } T_FLA_SAMPLE_LIST; + +typedef struct // structure d'une info + { + WORD Info ; + } T_FLA_INFO; + +typedef struct // structure d'un son + { + WORD Numero ; + WORD Decalage; + WORD Repetition; + UBYTE Balance; + UBYTE VolumeG; + UBYTE VolumeD; + } T_FLA_SAMPLE; + +typedef struct // structure d'un son + { + WORD Numero ; + UBYTE Offset ; + WORD Balance ; + UBYTE VolumeG ; + UBYTE VolumeD ; + } T_FLA_BALANCE; + +typedef struct // structure d'arret de son + { + UWORD Numero ; + } T_FLA_SAMPLE_STOP; + +typedef struct // structure d'une palette + { + UWORD NbCouleur; + UWORD CouleurDepart; + } T_FLA_PALETTE; + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +UBYTE *BufferFrame ; + +//UBYTE TypeAnimCharge = FALSE ; +UBYTE PaletteOrg[768] ; + +T_HEADER_FLA HeaderFla ; +T_FLA_SAMPLE_LIST HeaderSampleListFla; +T_HEADER_FLA_PASSE HeaderPasseFla ; +T_FLA_SAMPLE HeaderSampleFlaNew; +T_FLA_BALANCE HeaderBalanceFlaNew; +T_FLA_SAMPLE_STOP HeaderSampleStopFlaNew; +T_FLA_INFO HeaderInfo ; + +LONG HandleFla ; +LONG DeltaX, DeltaY ; +LONG MaxPass ; +LONG MaxFrame ; +ULONG NbTip ; + +WORD CouleurDepart ; +WORD NombreDeCouleur ; +ULONG ImageCadence = 12 ; +//WORD Frame =0 ; +//WORD ImageCourante = 0 ; +//WORD ImageDebut = 0 ; +//WORD ImageFin = 0 ; + +WORD FlagFirst = TRUE ; + +// ************************************************************************* + +// ************************************************************************** +void ChangeBalance( WORD numsample, UBYTE offset, UBYTE volg, UBYTE vold ) +{ + WORD i; + BYTE flagtrouve = FALSE; + +#ifndef SAMPLE_FLA_HQR + i = NbSampleJoue; + + while ( (i > 0) AND ( flagtrouve == FALSE) ) + { + if ( (PtrSampleJoue[i] & 0x0000ffff) == numsample ) + { + // Message( Itoa(PtrSampleJoue[i]), FALSE ); + // Message( Itoa((LONG)volg), TRUE ); + // Message( Itoa((LONG)vold), TRUE ); + WaveChangeVolume( PtrSampleJoue[i], (ULONG)volg, (ULONG)vold ); + flagtrouve = TRUE; + } + i--; + } +#endif +} + +/*-------------------------------------------------------------------------*/ +void LoadNextFrameFla() +{ + Read( HandleFla, &HeaderPasseFla, sizeof( T_HEADER_FLA_PASSE)) ; + + MaxPass = HeaderPasseFla.NbPasse ;/* pti->nbpasse*/ + + // Texte pour le debug +/* Box(10,420,500,450,0); + AffString (10,420,"Structure entete de passe:"); + Text (10,430,"header_passe.NbPasse=%L", HeaderPasseFla.NbPasse); + Text (10,440,"header_passe.OffsetFrameSuivante=%L", HeaderPasseFla.OffsetFrameSuivante); + CopyBlockPhys(10,420,500,450); */ + + Read( HandleFla, BufferFrame, HeaderPasseFla.OffsetFrameSuivante); +} + +/*-------------------------------------------------------------------------*/ +void DrawNextFrameFla() +{ + T_FLA_TYPE header_type; + T_FLA_PALETTE header_palette; + + UBYTE *ptr_buffer, *ptr_donnee; + LONG i ; + LONG compteur ; + + LoadNextFrameFla() ; + + ptr_buffer = BufferFrame; + + for ( i = 0 ; i < MaxPass ; i++ ) + { + header_type = *(T_FLA_TYPE *)ptr_buffer; + + ptr_buffer += sizeof(T_FLA_TYPE) ;/* Jump header type */ + ptr_donnee = ptr_buffer ; + + switch( header_type.Type ) + { + case FLA_PALETTE: + header_palette = *(T_FLA_PALETTE *)ptr_donnee; + ptr_donnee += sizeof(T_FLA_PALETTE) ;/* Jump header type */ + MovMem( ptr_donnee, PaletteOrg + header_palette.CouleurDepart * 3, header_palette.NbCouleur * 3 ); + CouleurDepart = header_palette.CouleurDepart; + NombreDeCouleur = header_palette.NbCouleur; + break; + + case FLA_SAMPLE: + HeaderSampleFlaNew = *(T_FLA_SAMPLE *)ptr_donnee; + ptr_donnee += sizeof(T_FLA_SAMPLE) ;/* Jump header type */ + if( SamplesEnable ) + { + HQ_MixSample( HeaderSampleFlaNew.Numero, + HeaderSampleFlaNew.Decalage, + HeaderSampleFlaNew.Repetition, + HeaderSampleFlaNew.VolumeG, + HeaderSampleFlaNew.VolumeD ); + } + break; + + case FLA_SAMPLE_BALANCE: + HeaderBalanceFlaNew = *(T_FLA_BALANCE *)ptr_donnee; + ptr_donnee += sizeof(T_FLA_BALANCE) ;/* Jump header type */ + if( SamplesEnable ) + { + ChangeBalance( HeaderBalanceFlaNew.Numero, + HeaderBalanceFlaNew.Offset, + HeaderBalanceFlaNew.VolumeG, + HeaderBalanceFlaNew.VolumeD ); + } + break; + + case FLA_SAMPLE_STOP: + HeaderSampleStopFlaNew = *(T_FLA_SAMPLE_STOP *)ptr_donnee; + ptr_donnee += sizeof(T_FLA_SAMPLE_STOP) ;/* Jump header type */ + if ( SamplesEnable == TRUE ) + { + if ( HeaderSampleStopFlaNew.Numero == -1 ) + { + HQ_StopSample(); + } + else + { + HQ_StopOneSample ( HeaderSampleStopFlaNew.Numero ); + } + } + break; + + case FLA_INFO: + HeaderInfo = *(T_FLA_INFO *)ptr_donnee; + ptr_donnee += sizeof(T_FLA_INFO) ;/* Jump header type */ + switch( HeaderInfo.Info ) + { + case 1: // fla flute + if( Midi_Driver_Enable ) + { + if( (26 != NumXmi) + OR (!IsMidiPlaying()) ) + { + StopMusicMidi() ; + PtrXmi = HQR_Get( HQR_Midi, 26 ) ; + NumXmi = 26 ; + PlayMidi( PtrXmi ) ; + VolumeMidi( 100 ) ; + } + } + break ; + + case 2: + FadeToBlack( PaletteOrg ) ; + break ; + + case 3: + FlagFirst = TRUE ; + break ; + + case 4: + FadeMusicMidi( 1 ) ; + break ; + } + break; + + + case FLA_BLACK: + BlackFrame() ; + break ; + case FLA_COPY: + CopyFrame( ptr_donnee); + break ; + case FLA_BRUN: + DrawFrame( ptr_donnee, 320, DeltaY ) ; + break ; + case FLA_LC: + UpdateFrame( ptr_donnee, 320 ) ; + break ; + case FLI_COPY: + CopyFrame( ptr_donnee ); + break ; + default: + break ; + } + + ptr_buffer += header_type.OffsetPasseSuivante ; + + } // fin boucle de passe +} + +/*-------------------------------------------------------------------------*/ +/* +void SeekFla() +{ + T_FLA_SAMPLE_LIST header_sample_list; + + Seek( HandleFla, sizeof(T_HEADER_FLA), SEEK_START ) ; + Read( HandleFla, &HeaderSampleListFla, sizeof(T_FLA_SAMPLE_LIST)); + Seek( HandleFla, HeaderSampleListFla.OffsetFrameOne, SEEK_CURRENT ); +} +*/ +/*-------------------------------------------------------------------------*/ +WORD InitFla( char *name ) +{ + char chaine[128] ; + UBYTE *ptr_list_sample ; + WORD i ; + WORD numero_sample ; + WORD nb_fois_joue ; + LONG size ; + + BufferFrame = Screen ; // Malloc( 80000L ) For One Frame(image, couleur...) + + HandleFla = OpenRead( name ) ; + +#ifdef DEBUG_TOOLS + if ( !HandleFla ) return(FALSE) ; // protect CD ? +#endif +#ifdef DEMO + if ( !HandleFla ) return(FALSE) ; // protect CD ? +#endif + + if( SamplesEnable ) + { + UBYTE string[256] ; + + strcpy( string, PathFla ) ; + strcat( string, "FLASAMP.HQR" ) ; + + HQR_Change_Ressource( HQR_Samples, string ) ; + } + + // lecture de l'entˆte principale + Read( HandleFla, &HeaderFla, sizeof(T_HEADER_FLA)) ; + + MaxFrame = HeaderFla.NbFrame; + DeltaX = HeaderFla.ResolutionX ; + DeltaY = HeaderFla.ResolutionY ; + ImageCadence = HeaderFla.CadenceAnimation; + + // lecture de la liste des samples + Read( HandleFla, &HeaderSampleListFla, sizeof(T_FLA_SAMPLE_LIST)); + + for ( i = 0; i < HeaderSampleListFla.NbSample; i++ ) + { + Read( HandleFla, &numero_sample, sizeof(WORD)); + Read( HandleFla, &nb_fois_joue, sizeof(WORD)); + + // preload samples (if enough space) + // (but if not, stupid method. need to write the + // list reversed) + if( SamplesEnable ) + { + HQR_GetSample( HQR_Samples, numero_sample ) ; + } + } + + // texte de debug +/* AffString (10,330,"Structure entete de fichier FLA:"); + Text( 10,340,"HeaderFla.Version=%S", HeaderFla.Version ); + Text( 10,350,"HeaderFla.NbFrame=%L", HeaderFla.NbFrame ); + Text( 10,360,"HeaderFla.CadenceAnimation=%L", HeaderFla.CadenceAnimation ); + Text( 10,370,"HeaderFla.ResolutionX=%L", HeaderFla.ResolutionX ); + Text( 10,380,"HeaderFla.ResolutionY=%L", HeaderFla.ResolutionY ); + Flip(); */ + + return TRUE ; +} + +/*-------------------------------------------------------------------------*/ +void ClearFla() +{ + if( SamplesEnable ) + { + HQR_Change_Ressource( HQR_Samples, PATH_RESSOURCE"samples.hqr" ) ; + } + + Close( HandleFla ) ; +} + +/*--------------------- GESTION PALETTE PENDANT ANIM ----------------------*/ +void GestionPalette() +{ + WORD compteur; + + if( FlagFirst ) + { + FadeToPal( PaletteOrg ) ; + NombreDeCouleur = 0 ; + FlagFirst = FALSE ; + } + + if ( NombreDeCouleur != 0 ) + { + if ( NombreDeCouleur == 256 ) + { + Palette( PaletteOrg ) ; + } + else + { +/* for ( compteur=0; compteur 32 ) n++ ; + ptrd[-1] = 0 ; + n++ ; + + if( !stricmp( name_anim, string ) ) + { + do + { + *ptrlist++ = atoi( ptrtxt ) ; + nb++ ; + while( *ptrtxt++ > 32 ) n++ ; + n++ ; + } + while( *ptrtxt > 32 ) ; + return nb ; + } + while( *ptrtxt++ >= 32 ) n++ ; + n++ ; + while( *ptrtxt++ < 32 ) n++ ; + n++ ; + ptrtxt-- ; + } + while( n < maxsize ) ; + + return 0 ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + +void PlayDiskFla( UBYTE *name_anim ) +{ + UBYTE *ptrtxt ; + UBYTE string[256] ; + LONG size,n, nb, timer ; + UBYTE listindex[20] ; + + size = HQRM_Load( PATH_RESSOURCE"ress.hqr", RESS_FLA_PCX, &ptrtxt ) ; + CHECK_MEMORY + if( !ptrtxt ) + { + Message( "Not Enough Memory for fla_gif list", TRUE ) ; + return ; + } + strcpy( string, name_anim ) ; + CutPoint( string ) ; + + nb = SearchFla( string, ptrtxt, size, listindex ) ; + + if( !nb ) return ; + +// FadeToBlack( PtrPal ) ; + + for( n=0; n= nbbloc ) + { + Close( handle ) ; + break ; + } + Seek( handle, listindex[n] * 4L, SEEK_START ) ; + Read( handle, &seekindex, 4L ) ; + Seek( handle, seekindex, SEEK_START ) ; + Read( handle, &header, sizeof( header ) ) ; + // methode de compression: stored + + // lit un gif normal + Read_Gif( handle, Log, PalettePcx, BufSpeak ) ; + + Close( handle ) ; + } + break; + } + Flip() ; + FadeToPal( PalettePcx ) ; + + timer = TimerRef + 4 * 50 ; + while( TimerRef < timer ) if( Key == K_ESC ) break ; + + if( Key == K_ESC ) break ; + + FadeToBlack( PalettePcx ) ; + } + + SetBlackPal() ; + Cls() ; + Flip() ; + HQM_Free( ptrtxt ) ; +} + +/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ + diff --git a/SOURCES/PLAYFLA.DEF b/SOURCES/PLAYFLA.DEF new file mode 100644 index 0000000..114fd51 --- /dev/null +++ b/SOURCES/PLAYFLA.DEF @@ -0,0 +1,10 @@ +extern void ChangeBalance(short ,unsigned char ,unsigned char ,unsigned char ); +extern void LoadNextFrameFla(void); +extern void DrawNextFrameFla(void); +extern short InitFla(char *); +extern void ClearFla(void); +extern void GestionPalette(void); +extern void PlayAnimFla(char *); +extern void CutPoint(unsigned char *); +extern short SearchFla(unsigned char *,unsigned char *,long ,unsigned char *); +extern void PlayDiskFla(unsigned char *); diff --git a/SOURCES/SETUP.DBG b/SOURCES/SETUP.DBG new file mode 100644 index 0000000..6f9505a --- /dev/null +++ b/SOURCES/SETUP.DBG @@ -0,0 +1,108 @@ +* window settings +display assembly /open {Assembly: *} 24,34,1,66 +display command /close {Command Window} 3,8,47,66 {} +display dialogue /open {Dialogue: *} 43,49,1,80 +display fpu /close {FPU} 3,12,1,73 +display memory /open {Memory Window} 35,42,1,80,0000:0000 +display prompt /open {} 50 +display register /open {CPU} 3,22,67,80 +display source /open {Source: *} 3,23,1,66 +display stack /open {Stack} 23,34,67,80 +display thread /close {Threads} 38,49,10,32 +* window colours +paint assembly plain black,white +paint assembly active black,red +paint assembly standout black,cyan +paint assembly title bright blue,white +paint assembly gadget bright blue,white +paint command plain black,white +paint command active black,red +paint command standout black,cyan +paint command title bright blue,white +paint command gadget bright blue,white +paint dialogue plain black,white +paint dialogue active black,red +paint dialogue standout black,cyan +paint dialogue title bright blue,white +paint dialogue gadget bright blue,white +paint fpu plain black,white +paint fpu active black,red +paint fpu standout black,cyan +paint fpu title bright blue,white +paint fpu gadget bright blue,white +paint memory plain black,white +paint memory active black,red +paint memory standout black,cyan +paint memory title bright blue,white +paint memory gadget bright blue,white +paint prompt plain black,white +paint prompt active black,red +paint prompt standout black,cyan +paint prompt title bright blue,white +paint prompt gadget bright blue,white +paint register plain black,white +paint register active black,red +paint register standout black,cyan +paint register title bright blue,white +paint register gadget bright blue,white +paint source plain black,white +paint source active black,red +paint source standout black,cyan +paint source title bright blue,white +paint source gadget bright blue,white +paint stack plain black,white +paint stack active black,red +paint stack standout black,cyan +paint stack title bright blue,white +paint stack gadget bright blue,white +paint thread plain black,white +paint thread active black,red +paint thread standout black,cyan +paint thread title bright blue,white +paint thread gadget bright blue,white +* debugger settings +set assembly lower outside +set bell on +set call /near(eax,edx,ebx,ecx)eax +set dclick 250 +set fpu decimal +set implicit on +set input prompt +set pfkey 1 {help} +set pfkey 4 { if !?_dbg@pf_4 {/_dbg@pf_4=0}; if (++_dbg@pf_4)&1 {disp fpu /o} {disp fpu /c} } +set pfkey 5 {reg -1} +set pfkey 6 {reg +1} +set pfkey 7 {/++_dbg@dbg$wind_split; + +#ifdef DEMO +char *Version = "LBA Demo (" + __DATE__ + " / " + __TIME__ + ")\n" ; +#else +char *Version = "LBA/Relentless (" + __DATE__ + " / " + __TIME__ + ")\n" ; +#endif \ No newline at end of file diff --git a/SOURCES/WD.BAT b/SOURCES/WD.BAT new file mode 100644 index 0000000..3682cca --- /dev/null +++ b/SOURCES/WD.BAT @@ -0,0 +1 @@ +wvideo /trap=rsi /vga50 /swap %1 %2 %3 %4 %5 %6 %7 %8 %9